Sha256: b7b28a3da91f53549a7db02a732ec52da2f3d391f4cc6583e94830013c0c54f7

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

require 'cgi'

module Concourse
  #
  # A job belongs to a pipeline
  # A job has many builds
  # A job has one finished_build
  # A job has one next_build
  #
  class Job
    attr_reader :pipeline

    def initialize(pipeline, info)
      @pipeline = pipeline
      @info = info
    end

    def name
      @info['name']
    end

    def to_s
      "#{self.class.name.split('::').last.downcase} #{name} of #{pipeline}"
    end

    def builds
      JSON.parse(@pipeline.get("/#{CGI.escape(name)}/builds")).map do |build|
        Build.new(self, build)
      end
    end

    def finished_build
      Build.new(self, @info['finished_build']) if @info['finished_build']
    end

    def next_build
      next_build = @info['next_build']
      Build.new(self, next_build) if next_build
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbar-concourse-1.1 lib/concourse/job.rb