Sha256: 05559e7fa3b616ef80f226db266897df5553510f78a6ec6e594b4e7c0d002947

Contents?: true

Size: 1.5 KB

Versions: 119

Compression:

Stored size: 1.5 KB

Contents

require 'travis/client'

module Travis
  module Client
    class Job < Entity
      include States, Restartable
      preloadable

      # @!parse attr_reader :repository_id, :build_id, :commit_id, :log_id, :number, :config, :state, :started_at, :finished_at, :queue, :allow_failure, :tags
      attributes :repository_id, :build_id, :commit_id, :log_id, :number, :config, :state, :started_at, :finished_at, :queue, :allow_failure, :tags
      time :started_at, :finished_at

      alias allow_failure? allow_failure

      # @!parse attr_reader :commit, :repository, :build
      has :commit, :repository, :build, :log

      one :job
      many :jobs

      def pull_request?
        build.pull_request?
      end

      def push?
        build.push?
      end

      def branch_info
        build.branch_info
      end

      def allow_failures?
        return false unless config.include? 'matrix' and config['matrix'].include? 'allow_failures'
        config['matrix']['allow_failures'].any? do |allow|
          allow.all? { |key, value| config[key] == value }
        end
      end

      def duration
        attributes['duration'] ||= begin
          start  = started_at  || Time.now
          finish = finished_at || Time.now
          (finish - start).to_i
        end
      end

      def delete_log(reason = {})
        log.delete_body(reason)
      end

      def pusher_channels
        build.pusher_channels + ["job-#{id}"]
      end

      def inspect_info
        "#{repository.slug}##{number}"
      end
    end
  end
end

Version data entries

119 entries across 119 versions & 2 rubygems

Version Path
travis-1.11.1 lib/travis/client/job.rb
travis-1.11.0 lib/travis/client/job.rb
travis-1.10.1.travis.1341.9 lib/travis/client/job.rb
travis-1.10.1.travis.1321.9 lib/travis/client/job.rb
travis-1.10.1.travis.1312.9 lib/travis/client/job.rb
travis-1.10.1.travis.1311.9 lib/travis/client/job.rb
travis-1.10.1.travis.1305.9 lib/travis/client/job.rb
travis-1.10.0 lib/travis/client/job.rb
travis-1.9.2.travis.1304.9 lib/travis/client/job.rb
travis-1.9.2.travis.1303.9 lib/travis/client/job.rb
travis-1.10.0.pre.rc4 lib/travis/client/job.rb
travis-1.10.0.pre.rc3 lib/travis/client/job.rb
travis-1.10.0.pre.rc2 lib/travis/client/job.rb
travis-1.9.2.travis.1288.9 lib/travis/client/job.rb
travis-1.9.2.travis.1285.9 lib/travis/client/job.rb
travis-1.9.2.travis.1279.9 lib/travis/client/job.rb
travis-1.10.0.pre.rc1 lib/travis/client/job.rb
travis-1.9.2.travis.1254.9 lib/travis/client/job.rb
travis-1.9.2.travis.1236.9 lib/travis/client/job.rb
travis-1.9.2.travis.1224.9 lib/travis/client/job.rb