Class: GoApiClient::Api::Stage
- Inherits:
-
AbstractApi
- Object
- GoApiClient::AttributeHelper
- AbstractApi
- GoApiClient::Api::Stage
- Defined in:
- lib/go_api_client/api/stage.rb
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Stage
constructor
A new instance of Stage.
- #stage(options = {}) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Stage
Returns a new instance of Stage.
7 8 9 10 |
# File 'lib/go_api_client/api/stage.rb', line 7 def initialize(attributes = {}) attributes = ({:pipeline_cache => {}, :stage_cache => {}}).merge(attributes) super(attributes) end |
Instance Method Details
#stage(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/go_api_client/api/stage.rb', line 12 def stage( = {}) = ({:stage_uri => nil, :stage_id => nil, :pipeline_name => nil, :pipeline_tag => nil, :stage_name => nil, :stage_counter => nil, :eager_parser => []}).merge() if [:stage_uri] uri = [:stage_uri] elsif [:stage_id] uri = "#{@base_uri}/api/stages/#{[:stage_id]}.xml" else raise 'Insufficient arguments' unless [:pipeline_name] && [:pipeline_tag] && [:stage_name] && [:stage_counter] uri = "#{@base_uri}/pipelines/#{[:pipeline_name]}/#{[:pipeline_tag]}/#{[:stage_name]}/#{[:stage_counter]}.xml" end stage = GoApiClient::Parsers::Stage.parse(Nokogiri::XML(@http_fetcher.get!(uri)).root) @stage_cache[GoApiClient::Domain::InternalCache.new(stage.self_uri, )] ||= stage if [:eager_parser] if [:eager_parser].include?(:job) job_api = GoApiClient::Api::Job.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher}) stage.parsed_jobs = stage.jobs.collect do |job_uri| job_api.job(.merge({:job_uri => job_uri})) end end if [:eager_parser].include?(:pipeline) pipeline_api = GoApiClient::Api::Pipeline.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher, :pipeline_cache => @pipeline_cache, :stage_cache => @stage_cache}) pipeline = @pipeline_cache[GoApiClient::Domain::InternalCache.new(stage.pipeline_uri, )] || pipeline_api.pipeline(.merge({:pipeline_uri => stage.pipeline_uri})) @pipeline_cache[GoApiClient::Domain::InternalCache.new(stage.pipeline_uri, )] ||= pipeline stage.parsed_pipeline = pipeline end end stage end |