Class: GoApiClient::Api::Cctray
- Inherits:
-
AbstractApi
- Object
- GoApiClient::AttributeHelper
- AbstractApi
- GoApiClient::Api::Cctray
- Defined in:
- lib/go_api_client/api/cctray.rb
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Cctray
constructor
A new instance of Cctray.
- #projects(options = {}) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Cctray
Returns a new instance of Cctray.
7 8 9 10 |
# File 'lib/go_api_client/api/cctray.rb', line 7 def initialize(attributes = {}) super(attributes) @cctray_uri = "#{@base_uri}/cctray.xml" end |
Instance Method Details
#projects(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 40 41 42 43 44 45 46 47 |
# File 'lib/go_api_client/api/cctray.rb', line 12 def projects(={}) = ({:pipeline_name => nil, :stage_name => nil, :job_name => nil, :activity => nil, :web_uri => nil, :eager_parser => []}).merge() name_args = [] name_args << "starts-with(@name, '#{options[:pipeline_name]}')" if [:pipeline_name] name_args << "starts-with(substring-after(@name, ' :: '), '#{options[:stage_name]}')" if [:stage_name] name_args << "starts-with(substring-after(substring-after(@name, ' :: '), ' :: '), '#{options[:job_name]}')" if [:job_name] xpath_args = [] xpath_args << name_args.join(' and ') unless name_args.empty? xpath_args << "@activity='#{options[:activity]}'" if [:activity] xpath_args << "@webUrl='#{options[:web_uri]}'" if [:web_uri] xpath_str = './Project' unless xpath_args.empty? xpath_str = "#{xpath_str}[#{xpath_args.join(' and ')}]" end doc = Nokogiri::XML(@http_fetcher.get!(@cctray_uri)) if doc.root if [:eager_parser] && [:eager_parser].include?(:stage) stage_api = GoApiClient::Api::Stage.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher}) end doc.root.xpath(xpath_str).collect do |element| project = GoApiClient::Parsers::Project.parse(element) project.parsed_pipeline_name, project.parsed_stage_name, project.parsed_job_name = project.name.split('::').map(&:strip) if [:eager_parser] && [:eager_parser].include?(:stage) && ! project.parsed_job_name project.parsed_stage = stage_api.stage(.merge({:stage_uri => "#{project.web_uri}.xml"})) end project end else [] end end |