Class: Feta::Client
Constant Summary collapse
- KEEPER_XML_NS =
"http://inttools.suse.de/sxkeeper/schema/keeper"
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ Client
constructor
Construct a FATE client.
-
#search(query) ⇒ Array<Feature>
Search for features.
Methods included from Logging
Constructor Details
#initialize(url) ⇒ Client
Note:
Keeper behind iChain is not yet supported
Construct a FATE client
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/feta/client.rb', line 48 def initialize(url) RestClient.log = Feta::Logging.logger url = URI.parse(url) if not url.is_a?(URI) @url = url.clone @headers = Hash.new # Scan plugins [ File.join(ENV['HOME'], '.local/share/feta/plugins/*.rb'), File.join(File.dirname(__FILE__), 'plugins', '*.rb') ].each do |plugin_glob| Dir.glob(plugin_glob).each do |plugin| logger.debug("Loading file: #{plugin}") load plugin end end #instantiate plugins pl_instances = [] ::Feta::Plugins.constants.each do |cnt| pl_class = ::Feta::Plugins.const_get(cnt) pl_instances << pl_class.new end pl_instances.sort{|x,y| x.order <=> y.order}.each do |pl_instance| logger.debug("Loaded: #{pl_instance}") pl_instance.initialize_hook(url, logger, @headers) end @keeper_url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
40 41 42 |
# File 'lib/feta/client.rb', line 40 def url @url end |
Instance Method Details
#search(query) ⇒ Array<Feature>
Search for features
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/feta/client.rb', line 82 def search(query) url_query = "?query=#{CGI.escape(query.to_xquery)}" url = URI.parse("#{@keeper_url}/feature#{url_query}").to_s xml = RestClient.get(url, @headers).body features = [] doc = Nokogiri::XML(xml) doc.xpath('//feature', 'k' => KEEPER_XML_NS).each do |feat_element| feature = Feature.new(self) feature.feature_id = feat_element.xpath('./@k:id', 'k' => KEEPER_XML_NS).first.value feature.title = feat_element.xpath('./title', 'k' => KEEPER_XML_NS).first.content feat_element.xpath('./actor', 'k' => KEEPER_XML_NS).each do |actor| if actor.xpath('./role', 'k' => KEEPER_XML_NS).first.content == "infoprovider" feature.infoprovider = actor.xpath('.//email', 'k' => KEEPER_XML_NS).first.content end end feat_element.xpath('./productcontext', 'k' => KEEPER_XML_NS).each do |ctx_element| ctx = Feature::ProductContext.new product = ctx_element.xpath('./product/name').first.content ctx.status = ctx_element.xpath('./status').children.select {|x| x.element?}.first.name.to_sym feature.product_contexts[product] = ctx # Priorities ctx_element.xpath('./priority').each do |prio_element| prio = prio_element.children.select(&:element?).first.name.to_sym owner = prio_element.xpath('./owner/role').first.content.to_sym ctx.priorities[owner] = prio end end yield feature if block_given? features << feature end features end |