Class: GoApiClient::Api::Config
- Inherits:
-
AbstractApi
- Object
- GoApiClient::AttributeHelper
- AbstractApi
- GoApiClient::Api::Config
- Defined in:
- lib/go_api_client/api/config.rb
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Config
constructor
A new instance of Config.
- #pipelines(options = {}) ⇒ Object
- #templates(options = {}) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Config
Returns a new instance of Config.
7 8 9 |
# File 'lib/go_api_client/api/config.rb', line 7 def initialize(attributes = {}) super(attributes) end |
Instance Method Details
#pipelines(options = {}) ⇒ Object
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(={}) = ({:group_name => nil, :pipeline_name => nil, :config_uri => nil, :eager_parser => []}).merge() uri = [:config_uri] ? [:config_uri] : "#{@base_uri}/api/admin/config.xml" group_args = [] group_args << "@group='#{options[:group_name]}'" if [:group_name] pipeline_args= [] pipeline_args << "@name='#{options[:pipeline_name]}'" if [: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 [:eager_parser] && [:eager_parser].include?(:template) && pipeline.template pipeline.parsed_template = templates(.merge({:template_name => pipeline.template})) end pipeline end else [] end end |
#templates(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/go_api_client/api/config.rb', line 11 def templates(={}) = ({:template_name => nil, :config_uri => nil}).merge() uri = [:config_uri] ? [:config_uri] : "#{@base_uri}/api/admin/config.xml" xpath_str = './templates/pipeline' + ([:template_name] ? "[@name='#{options[:template_name]}']" : '') doc = Nokogiri::XML(@http_fetcher.get!(uri)).remove_namespaces! if doc.root doc.root.xpath(xpath_str).collect do |element| GoApiClient::Parsers::Config::Pipeline.parse(element) end else [] end end |