Class: ActiveBugzilla::Service
- Inherits:
-
Object
- Object
- ActiveBugzilla::Service
- Defined in:
- lib/active_bugzilla/service.rb
Constant Summary collapse
- CLONE_FIELDS =
[ :assigned_to, :cc, :cf_devel_whiteboard, :cf_internal_whiteboard, :comments, :component, :description, :groups, :keywords, :op_sys, :platform, :priority, :product, :qa_contact, :severity, :summary, :target_release, :url, :version, :whiteboard ]
Instance Attribute Summary collapse
-
#bugzilla_request_hostname ⇒ Object
readonly
Returns the value of attribute bugzilla_request_hostname.
-
#bugzilla_request_uri ⇒ Object
readonly
Returns the value of attribute bugzilla_request_uri.
-
#bugzilla_uri ⇒ Object
Returns the value of attribute bugzilla_uri.
-
#last_command ⇒ Object
Returns the value of attribute last_command.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #add_comment(bug_id, comment, params = {}) ⇒ Object
-
#clone(bug_id, overrides = {}) ⇒ Fixnum
Clone of an existing bug.
- #comments(params = {}) ⇒ Object
- #create(params) ⇒ Object
-
#execute(action, params) ⇒ Object
Bypass python-bugzilla and use the xmlrpc API directly.
- #fields(params = {}) ⇒ Object
-
#get(bug_ids, params = {}) ⇒ Array
www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService/Bug.html#get XMLRPC Bug Query of an existing bug.
-
#initialize(bugzilla_uri, username, password) ⇒ Service
constructor
A new instance of Service.
- #inspect ⇒ Object
- #product ⇒ Object
- #search(params = {}) ⇒ Object
- #timeout ⇒ Object
- #update(ids, params = {}) ⇒ Object
Constructor Details
#initialize(bugzilla_uri, username, password) ⇒ Service
Returns a new instance of Service.
61 62 63 64 65 66 67 |
# File 'lib/active_bugzilla/service.rb', line 61 def initialize(bugzilla_uri, username, password) raise ArgumentError, "username and password must be set" if username.nil? || password.nil? self.bugzilla_uri = bugzilla_uri self.username = username self.password = password end |
Instance Attribute Details
#bugzilla_request_hostname ⇒ Object (readonly)
Returns the value of attribute bugzilla_request_hostname.
29 30 31 |
# File 'lib/active_bugzilla/service.rb', line 29 def bugzilla_request_hostname @bugzilla_request_hostname end |
#bugzilla_request_uri ⇒ Object (readonly)
Returns the value of attribute bugzilla_request_uri.
29 30 31 |
# File 'lib/active_bugzilla/service.rb', line 29 def bugzilla_request_uri @bugzilla_request_uri end |
#bugzilla_uri ⇒ Object
Returns the value of attribute bugzilla_uri.
28 29 30 |
# File 'lib/active_bugzilla/service.rb', line 28 def bugzilla_uri @bugzilla_uri end |
#last_command ⇒ Object
Returns the value of attribute last_command.
28 29 30 |
# File 'lib/active_bugzilla/service.rb', line 28 def last_command @last_command end |
#password ⇒ Object
Returns the value of attribute password.
28 29 30 |
# File 'lib/active_bugzilla/service.rb', line 28 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
28 29 30 |
# File 'lib/active_bugzilla/service.rb', line 28 def username @username end |
Class Method Details
.product ⇒ Object
47 48 49 |
# File 'lib/active_bugzilla/service.rb', line 47 def self.product defined?(@@product) && @@product end |
.product=(value) ⇒ Object
43 44 45 |
# File 'lib/active_bugzilla/service.rb', line 43 def self.product=(value) @@product = value end |
.timeout ⇒ Object
35 36 37 |
# File 'lib/active_bugzilla/service.rb', line 35 def self.timeout defined?(@@timeout) && @@timeout end |
.timeout=(value) ⇒ Object
31 32 33 |
# File 'lib/active_bugzilla/service.rb', line 31 def self.timeout=(value) @@timeout = value end |
Instance Method Details
#add_comment(bug_id, comment, params = {}) ⇒ Object
79 80 81 82 83 |
# File 'lib/active_bugzilla/service.rb', line 79 def add_comment(bug_id, comment, params = {}) params[:id] = bug_id params[:comment] = comment execute('add_comment', params)["id"] end |
#clone(bug_id, overrides = {}) ⇒ Fixnum
Clone of an existing bug
Example:
# Perform a clone of an existing bug, and return the new bug ID.
bz.clone(948970)
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/active_bugzilla/service.rb', line 143 def clone(bug_id, overrides = {}) raise ArgumentError, "bug_id must be numeric" unless bug_id.to_s =~ /^\d+$/ existing_bz = get(bug_id, :include_fields => CLONE_FIELDS).first clone_description, clone_comment_is_private = assemble_clone_description(existing_bz) params = {} CLONE_FIELDS.each do |field| next if field == :comments params[field] = existing_bz[field.to_s] end # Apply overrides overrides.each do |param, value| params[param] = value end # Apply base clone fields params[:cf_clone_of] = bug_id params[:description] = clone_description params[:comment_is_private] = clone_comment_is_private create(params)[:id.to_s] end |
#comments(params = {}) ⇒ Object
74 75 76 |
# File 'lib/active_bugzilla/service.rb', line 74 def comments(params = {}) execute('comments', params) end |
#create(params) ⇒ Object
128 129 130 |
# File 'lib/active_bugzilla/service.rb', line 128 def create(params) execute('create', params) end |
#execute(action, params) ⇒ Object
Bypass python-bugzilla and use the xmlrpc API directly.
170 171 172 173 174 175 176 177 178 |
# File 'lib/active_bugzilla/service.rb', line 170 def execute(action, params) cmd = "Bug.#{action}" params[:Bugzilla_login] ||= username params[:Bugzilla_password] ||= password self.last_command = command_string(cmd, params) xmlrpc_client.call(cmd, params) end |
#fields(params = {}) ⇒ Object
86 87 88 |
# File 'lib/active_bugzilla/service.rb', line 86 def fields(params = {}) execute('fields', params)['fields'] end |
#get(bug_ids, params = {}) ⇒ Array
www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService/Bug.html#get XMLRPC Bug Query of an existing bug
Example:
# Perform an xmlrpc query for a single bug.
bz.get(948970)
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/active_bugzilla/service.rb', line 99 def get(bug_ids, params = {}) bug_ids = Array(bug_ids) raise ArgumentError, "bug_ids must be all Numeric" unless bug_ids.all? { |id| id.to_s =~ /^\d+$/ } params[:ids] = bug_ids results = execute('get', params)['bugs'] return [] if results.nil? results end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/active_bugzilla/service.rb', line 69 def inspect super.gsub(/@password=\".+?\", /, "") end |
#product ⇒ Object
51 52 53 |
# File 'lib/active_bugzilla/service.rb', line 51 def product self.class.product end |
#search(params = {}) ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/active_bugzilla/service.rb', line 111 def search(params = {}) params[:creation_time] &&= (params[:creation_time]) params[:last_change_time] &&= (params[:last_change_time]) params[:product] ||= product if product results = execute('search', params)['bugs'] return [] if results.nil? results end |
#timeout ⇒ Object
39 40 41 |
# File 'lib/active_bugzilla/service.rb', line 39 def timeout self.class.timeout end |
#update(ids, params = {}) ⇒ Object
122 123 124 125 |
# File 'lib/active_bugzilla/service.rb', line 122 def update(ids, params = {}) params[:ids] = Array(ids) execute('update', params)['bugs'] end |