Sha256: 5359194a816f846f39d2e8ace614e098c6f0f0018eb3ce266a2005762051a6f9

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 KB

Contents

require 'travis/client'

module Travis
  module Client
    class Job < Entity
      include States

      # @!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 restart
        session.restart(self)
      end

      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 inspect_info
        "#{repository.slug}##{number}"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
travis-1.4.0 lib/travis/client/job.rb
travis-1.3.1 lib/travis/client/job.rb
travis-1.3.0 lib/travis/client/job.rb
travis-1.2.8 lib/travis/client/job.rb
travis-1.2.7 lib/travis/client/job.rb
travis-1.2.6 lib/travis/client/job.rb
travis-1.2.5 lib/travis/client/job.rb
travis-1.2.4 lib/travis/client/job.rb
travis-1.2.3 lib/travis/client/job.rb
travis-1.2.2 lib/travis/client/job.rb
travis-1.2.1 lib/travis/client/job.rb
travis-1.2.0 lib/travis/client/job.rb