Class: GoApiClient::Job
- Inherits:
-
Object
- Object
- GoApiClient::Job
- Includes:
- Helpers::SimpleAttributesSupport
- Defined in:
- lib/go_api_client/job.rb
Constant Summary collapse
- PROPERTIES =
{ :duration => :cruise_job_duration, :result => :cruise_job_result, :scheduled => :cruise_timestamp_01_scheduled, :assigned => :cruise_timestamp_02_assigned, :preparing => :cruise_timestamp_03_preparing, :building => :cruise_timestamp_04_building, :completing => :cruise_timestamp_05_completing, :completed => :cruise_timestamp_06_completed, }
Instance Attribute Summary collapse
-
#artifacts_uri ⇒ Object
Returns the value of attribute artifacts_uri.
-
#console_log_url ⇒ Object
Returns the value of attribute console_log_url.
-
#http_fetcher ⇒ Object
Returns the value of attribute http_fetcher.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root, attributes = {}) ⇒ Job
constructor
A new instance of Job.
- #parse! ⇒ Object
Constructor Details
Instance Attribute Details
#artifacts_uri ⇒ Object
Returns the value of attribute artifacts_uri.
3 4 5 |
# File 'lib/go_api_client/job.rb', line 3 def artifacts_uri @artifacts_uri end |
#console_log_url ⇒ Object
Returns the value of attribute console_log_url.
3 4 5 |
# File 'lib/go_api_client/job.rb', line 3 def console_log_url @console_log_url end |
#http_fetcher ⇒ Object
Returns the value of attribute http_fetcher.
3 4 5 |
# File 'lib/go_api_client/job.rb', line 3 def http_fetcher @http_fetcher end |
#identifier ⇒ Object
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/go_api_client/job.rb', line 3 def identifier @identifier end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/go_api_client/job.rb', line 3 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/go_api_client/job.rb', line 3 def url @url end |
Class Method Details
.from(url, attributes = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/go_api_client/job.rb', line 26 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
#parse! ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/go_api_client/job.rb', line 33 def parse! self.artifacts_uri = @root.xpath("./artifacts").first.attributes["baseUri"].value self.url = href_from(@root.xpath("./link[@rel='self']")) self.identifier = @root.xpath('./id').first.content self.name = @root.attributes['name'].value PROPERTIES.each do |variable, property_name| property_value = @root.xpath("./properties/property[@name='#{property_name}']").first.content rescue nil next if property_value.nil? || property_value.empty? if property_name =~ /timestamp/ property_value = Time.parse(property_value).utc elsif property_value =~ /^\d+$/ property_value = property_value.to_i end self.send("#{variable}=", property_value) end @root = nil self end |