Sha256: 4d6dff8a37230cacf7eb538c353a73af4236c8264c37c2dd9c60964c42aa81a0

Contents?: true

Size: 1.47 KB

Versions: 59

Compression:

Stored size: 1.47 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, :annotation_ids
      time :started_at, :finished_at

      alias allow_failure? allow_failure

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

      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 pusher_channels
        build.pusher_channels + ["job-#{id}"]
      end

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

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
travis-1.6.12.travis.528.6 lib/travis/client/job.rb
travis-1.6.12.travis.524.6 lib/travis/client/job.rb
travis-1.6.12.travis.523.6 lib/travis/client/job.rb
travis-1.6.12.travis.521.6 lib/travis/client/job.rb
travis-1.6.12.travis.520.6 lib/travis/client/job.rb
travis-1.6.12.travis.517.6 lib/travis/client/job.rb
travis-1.6.11 lib/travis/client/job.rb
travis-1.6.11.travis.516.6 lib/travis/client/job.rb
travis-1.6.11.travis.511.6 lib/travis/client/job.rb
travis-1.6.11.travis.510.6 lib/travis/client/job.rb
travis-1.6.11.travis.507.6 lib/travis/client/job.rb
travis-1.6.11.travis.503.6 lib/travis/client/job.rb
travis-1.6.10 lib/travis/client/job.rb
travis-1.6.11.travis.502.6 lib/travis/client/job.rb
travis-1.6.9 lib/travis/client/job.rb
travis-1.6.9.travis.484.6 lib/travis/client/job.rb
travis-1.6.9.travis.483.6 lib/travis/client/job.rb
travis-1.6.9.travis.479.6 lib/travis/client/job.rb
travis-1.6.9.travis.463.6 lib/travis/client/job.rb
travis-1.6.9.travis.462.6 lib/travis/client/job.rb