class Bicho::Bug
A single bug inside a bugzilla instance.
Public Class Methods
Normally you will not use this constructor as bugs will be constructed by a query result
@param client [Bicho::Client] client where this bug gets its data @param data [Hash] retrieved data for this bug
# File lib/bicho/bug.rb, line 56 def initialize(client, data) @client = client @data = data end
ActiveRecord like interface
@example Searching for bugs
Bug.where(:summary => "crash").each do |bug| #...do something with bug end
Requires Bicho.client
to be set
@param [Hash] conds the conditions for the query. alias @option conds [String] The unique alias for this bug. @option conds assigned_to [String] The login name of a user that a bug is assigned to. @option conds component [String] The name of the Component that the bug is in. @option conds creation_time [DateTime] Searches for bugs that were created at this time or later. May not be an array. @option conds creator [String] The login name of the user who created the bug. @option conds id [Integer] The numeric id of the bug. @option conds last_change_time [DateTime] Searches for bugs that were modified at this time or later. May not be an array. @option conds limit [Integer] Limit the number of results returned to int records. @option conds offset [Integer] Used in conjunction with the limit argument, offset defines the starting position for the search. For example, given a search that would return 100 bugs, setting limit to 10 and offset to 10 would return bugs 11 through 20 from the set of 100. @option conds op_sys [String] The “Operating System” field of a bug. @option conds platform [String] The Platform (sometimes called “Hardware”) field of a bug. @option conds priority [String] The Priority field on a bug. @option conds product [String] The name of the Product that the bug is in. @option conds creator [String] The login name of the user who reported the bug. @option conds resolution [String] The current resolution–only set if a bug is closed. You can find open bugs by searching for bugs with an empty resolution. @option conds severity [String] The Severity field on a bug. @option conds status [String] The current status of a bug (not including its resolution, if it has one, which is a separate field above). @option conds summary [String] Searches for substrings in the single-line Summary field on bugs. If you specify an array, then bugs whose summaries match any of the passed substrings will be returned. @option conds target_milestone [String] The Target Milestone field of a bug. Note that even if this Bugzilla does not have the Target Milestone field enabled, you can still search for bugs by Target Milestone. However, it is likely that in that case, most bugs will not have a Target Milestone set (it defaults to “—” when the field isn't enabled). @option conds qa_contact [String] The login name of the bug's QA Contact. Note that even if this Bugzilla does not have the QA Contact field enabled, you can still search for bugs by QA Contact (though it is likely that no bug will have a QA Contact set, if the field is disabled). @option conds url [String] The “URL” field of a bug. @option conds version [String] The Version field of a bug. @option conds whiteboard [String] Search the “Status Whiteboard” field on bugs for a substring. Works the same as the summary field described above, but searches the Status Whiteboard field.
@return [Array]
@see www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html#search bugzilla search API and allowed attributes
# File lib/bicho/bug.rb, line 47 def self.where(conditions = {}) Query.new(conditions) end
Public Instance Methods
# File lib/bicho/bug.rb, line 80 def [](name, subname = nil) value = @data[name.to_s] value = value[subname.to_s] if subname # for 'internals' properties if value.is_a?(XMLRPC::DateTime) value.to_time else value end end
Add an attachment to the bug For the params description, see the Client.add_attachment
method.
@return [ID] of the new attachment
# File lib/bicho/bug.rb, line 120 def add_attachment(summary, file, **kwargs) @client.add_attachment(summary, file, id, **kwargs).first end
@return [Array<Attachment>] attachments for this bug
# File lib/bicho/bug.rb, line 112 def attachments @client.get_attachments(id) end
@param format_string For Kernel#sprintf; named params supplied by the bug
# File lib/bicho/bug.rb, line 125 def format(format_string) sym_data = Hash[@data.to_a.map { |k, v| [k.to_sym, v] }] Kernel.format(format_string, sym_data) end
@return [History] history for this bug
# File lib/bicho/bug.rb, line 107 def history @client.get_history(id).first end
# File lib/bicho/bug.rb, line 70 def id # we define id to not get the deprecated # warning of object_id @data['id'] end
# File lib/bicho/bug.rb, line 61 def method_missing(method_name, *_args) return super unless @data.key?(method_name.to_s) self[method_name] end
reopen a closed bug @param a String comment to add @param @optional a Boolean indicator if the new comment should be private (defaults to 'false')
@returns id of re-opened bug
# File lib/bicho/bug.rb, line 96 def reopen!(comment, is_private = false) @client.update_bug(id, status: 'REOPENED', comment: { body: comment.to_s, is_private: is_private.to_b }) end
# File lib/bicho/bug.rb, line 66 def respond_to_missing?(method_name, _include_private = false) @data.key?(method_name.to_s) || super end
@return [Hash]
# File lib/bicho/bug.rb, line 131 def to_h Hash[@data.to_a.map { |k, _| [k.to_sym, self[k.to_sym]] }] end
# File lib/bicho/bug.rb, line 76 def to_s "##{id} - #{summary} (#{url})" end
URL where the bug can be viewed Example: bugs.foo.com/2345
# File lib/bicho/bug.rb, line 102 def url "#{@client.site_url}/#{id}" end