Class: Bicho::Client
Overview
Client to query bugzilla
Instance Attribute Summary (collapse)
-
- (Object) url
readonly
Returns the value of attribute url.
Instance Method Summary (collapse)
-
- (Object) get_bugs(*ids)
Retrieves one or more bugs by id.
- - (Object) handle_faults(ret)
-
- (Client) initialize(url)
constructor
A new instance of Client.
-
- (Object) search_bugs(query)
Search for a bug.
Methods included from Logging
Constructor Details
- (Client) initialize(url)
A new instance of Client
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/bicho/client.rb', line 64 def initialize(url) url = URI.parse(url) if not url.is_a?(URI) # save the unmodified (by plugins) url @url = url.clone url.path = '/xmlrpc.cgi' # Scan plugins plugin_glob = File.join(File.dirname(__FILE__), 'plugins', '*.rb') Dir.glob(plugin_glob).each do |plugin| logger.debug("Loading file: #{plugin}") load plugin end #instantiate plugins ::Bicho::Plugins.constants.each do |cnt| pl_class = ::Bicho::Plugins.const_get(cnt) pl_instance = pl_class.new logger.debug("Loaded: #{pl_instance}") pl_instance.initialize_hook(url, logger) end @client = XMLRPC::Client.new_from_uri(url.to_s, nil, 900) @client.set_debug end |
Instance Attribute Details
- (Object) url (readonly)
Returns the value of attribute url
62 63 64 |
# File 'lib/bicho/client.rb', line 62 def url @url end |
Instance Method Details
- (Object) get_bugs(*ids)
Retrieves one or more bugs by id
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/bicho/client.rb', line 118 def get_bugs(*ids) params = Hash.new params[:ids] = ids.collect(&:to_s) bugs = [] ret = @client.call("Bug.get", params) handle_faults(ret) ret['bugs'].each do |bug_data| bugs << Bug.new(self, bug_data) end bugs end |
- (Object) handle_faults(ret)
90 91 92 93 94 95 96 |
# File 'lib/bicho/client.rb', line 90 def handle_faults(ret) if ret.has_key?('faults') ret['faults'].each do |fault| logger.error fault end end end |
- (Object) search_bugs(query)
Search for a bug
query has to be either a Query object or a String that will be searched in the summary of the bugs.
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/bicho/client.rb', line 104 def search_bugs(query) # allow plain strings to be passed, interpretting them query = Query.new.summary(query) if query.is_a?(String) ret = @client.call("Bug.search", query.query_map) handle_faults(ret) bugs = [] ret['bugs'].each do |bug_data| bugs << Bug.new(self, bug_data) end bugs end |