26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/go_api_client/api/config.rb', line 26
def pipelines(options={})
options = ({:group_name => nil, :pipeline_name => nil, :config_uri => nil, :eager_parser => []}).merge(options)
uri = options[:config_uri] ? options[:config_uri] : "#{@base_uri}/api/admin/config.xml"
group_args = []
group_args << "@group='#{options[:group_name]}'" if options[:group_name]
pipeline_args= []
pipeline_args << "@name='#{options[:pipeline_name]}'" if options[:pipeline_name]
xpath_args = []
xpath_args << (group_args.empty? ? 'pipelines' : "pipelines[#{group_args.join(' and ')}]")
xpath_args << (pipeline_args.empty? ? 'pipeline' : "pipeline[#{pipeline_args.join(' and ')}]")
xpath_str = './'
unless xpath_args.empty?
xpath_str = "#{xpath_str}#{xpath_args.join('/')}"
end
doc = Nokogiri::XML(@http_fetcher.get!(uri)).remove_namespaces!
if doc.root
doc.root.xpath(xpath_str).collect do |element|
pipeline = GoApiClient::Parsers::Config::Pipeline.parse(element)
if options[:eager_parser] && options[:eager_parser].include?(:template) && pipeline.template
pipeline.parsed_template = templates(options.merge({:template_name => pipeline.template}))
end
pipeline
end
else
[]
end
end
|