Class: GoApiClient::Stage
- Inherits:
-
Object
- Object
- GoApiClient::Stage
- Includes:
- Helpers::SimpleAttributesSupport
- Defined in:
- lib/go_api_client/stage.rb
Instance Attribute Summary collapse
-
#authors ⇒ Object
Returns the value of attribute authors.
-
#completed_at ⇒ Object
Returns the value of attribute completed_at.
-
#counter ⇒ Object
Returns the value of attribute counter.
-
#http_fetcher ⇒ Object
Returns the value of attribute http_fetcher.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#jobs ⇒ Object
Returns the value of attribute jobs.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pipeline ⇒ Object
Returns the value of attribute pipeline.
-
#pipeline_cache ⇒ Object
Returns the value of attribute pipeline_cache.
-
#result ⇒ Object
Returns the value of attribute result.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(root, attributes = {}) ⇒ Stage
constructor
A new instance of Stage.
- #parse! ⇒ Object
- #passed? ⇒ Boolean
Constructor Details
Instance Attribute Details
#authors ⇒ Object
Returns the value of attribute authors.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def @authors end |
#completed_at ⇒ Object
Returns the value of attribute completed_at.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def completed_at @completed_at end |
#counter ⇒ Object
Returns the value of attribute counter.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def counter @counter end |
#http_fetcher ⇒ Object
Returns the value of attribute http_fetcher.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def http_fetcher @http_fetcher end |
#identifier ⇒ Object
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def identifier @identifier end |
#jobs ⇒ Object
Returns the value of attribute jobs.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def jobs @jobs end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def name @name end |
#pipeline ⇒ Object
Returns the value of attribute pipeline.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def pipeline @pipeline end |
#pipeline_cache ⇒ Object
Returns the value of attribute pipeline_cache.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def pipeline_cache @pipeline_cache end |
#result ⇒ Object
Returns the value of attribute result.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def result @result end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/go_api_client/stage.rb', line 4 def url @url end |
Class Method Details
.from(url, attributes = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/go_api_client/stage.rb', line 14 def from(url, attributes = {}) attributes[:http_fetcher] ||= GoApiClient::HttpFetcher.new doc = Nokogiri::XML(attributes[:http_fetcher].get_response_body(url)) self.new(doc.root, attributes).parse! end |
Instance Method Details
#failed? ⇒ Boolean
42 43 44 |
# File 'lib/go_api_client/stage.rb', line 42 def failed? "Failed" == @result end |
#parse! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/go_api_client/stage.rb', line 21 def parse! self.name = @root.attributes['name'].value self.counter = @root.attributes['counter'].value.to_i self.url = href_from(@root.xpath("./link[@rel='self']")) self.result = @root.xpath("./result").first.content self.completed_at = Time.parse(@root.xpath("./updated").first.content).utc self.jobs = @root.xpath("./jobs/job").collect do |job_element| Job.from(job_element.attributes["href"].value, :http_fetcher => http_fetcher) end self.identifier = @root.xpath('./id').first.content pipeline_link = @root.xpath("./pipeline").first.attributes["href"].value pipeline = @pipeline_cache[pipeline_link] || Pipeline.from(pipeline_link, :http_fetcher => http_fetcher) pipeline.stages << self self.pipeline_cache[pipeline_link] ||= pipeline @root = nil self end |
#passed? ⇒ Boolean
46 47 48 |
# File 'lib/go_api_client/stage.rb', line 46 def passed? !failed? end |