Class: GoApiClient::Pipeline

Inherits:
Object
  • Object
show all
Includes:
Helpers::SimpleAttributesSupport
Defined in:
lib/go_api_client/pipeline.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, attributes = {}) ⇒ Pipeline

Returns a new instance of Pipeline.



7
8
9
10
# File 'lib/go_api_client/pipeline.rb', line 7

def initialize(root, attributes={})
  @root = root
  super(attributes)
end

Instance Attribute Details

#authorsObject

Returns the value of attribute authors.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def authors
  @authors
end

#branch_nameObject

Returns the value of attribute branch_name.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def branch_name
  @branch_name
end

#commitsObject

Returns the value of attribute commits.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def commits
  @commits
end

#counterObject

Returns the value of attribute counter.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def counter
  @counter
end

#http_fetcherObject

Returns the value of attribute http_fetcher.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def http_fetcher
  @http_fetcher
end

#identifierObject

Returns the value of attribute identifier.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def identifier
  @identifier
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def label
  @label
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def name
  @name
end

#schedule_timeObject

Returns the value of attribute schedule_time.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def schedule_time
  @schedule_time
end

#stagesObject

Returns the value of attribute stages.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def stages
  @stages
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/go_api_client/pipeline.rb', line 3

def url
  @url
end

Class Method Details

.from(url, attributes = {}) ⇒ Object



13
14
15
16
17
# File 'lib/go_api_client/pipeline.rb', line 13

def from(url, attributes = {})
  attributes[:http_fetcher] ||= GoApiClient::HttpFetcher.new
  doc = Nokogiri::XML(attributes[:http_fetcher].get!(url))
  self.new(doc.root, attributes).parse!
end

Instance Method Details

#parse!Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/go_api_client/pipeline.rb', line 24

def parse!
  self.name          = @root.attributes["name"].value
  self.label         = @root.attributes["label"].value
  self.counter       = @root.attributes["counter"].value.to_i
  self.url           = href_from(@root.xpath("./link[@rel='self']"))
  self.identifier    = @root.xpath("./id").first.content
  self.schedule_time = Time.parse(@root.xpath('./scheduleTime').first.content).utc
  self.commits       = @root.xpath('./materials/material[@type = "GitMaterial"]/modifications/changeset').collect do |changeset|
    Commit.new(changeset).parse!
  end

  @root = nil
  self
end