Class: Bicho::Bug
- Inherits:
-
Object
- Object
- Bicho::Bug
- Defined in:
- lib/bicho/bug.rb
Overview
A single bug inside a bugzilla instance.
Class Method Summary collapse
-
.where(conditions = {}) ⇒ Array
ActiveRecord like interface.
Instance Method Summary collapse
- #[](name, subname = nil) ⇒ Object
-
#add_attachment(summary, file, **kwargs) ⇒ ID
Add an attachment to the bug For the params description, see the Client.add_attachment method.
-
#attachments ⇒ Array<Attachment>
Attachments for this bug.
- #format(format_string) ⇒ Object
-
#history ⇒ History
History for this bug.
- #id ⇒ Object
-
#initialize(client, data) ⇒ Bug
constructor
Normally you will not use this constructor as bugs will be constructed by a query result.
- #method_missing(method_name, *_args) ⇒ Object
-
#reopen!(comment, is_private = false) ⇒ Object
reopen a closed bug.
- #respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
- #to_h ⇒ Hash
- #to_s ⇒ Object
-
#url ⇒ Object
URL where the bug can be viewed Example: bugs.foo.com/2345.
Constructor Details
#initialize(client, data) ⇒ Bug
Normally you will not use this constructor as bugs will be constructed by a query result
56 57 58 59 |
# File 'lib/bicho/bug.rb', line 56 def initialize(client, data) @client = client @data = data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *_args) ⇒ Object
61 62 63 64 |
# 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 |
Class Method Details
Instance Method Details
#[](name, subname = nil) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# 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_attachment(summary, file, **kwargs) ⇒ ID
Add an attachment to the bug For the params description, see the Client.add_attachment method.
120 121 122 |
# File 'lib/bicho/bug.rb', line 120 def (summary, file, **kwargs) @client.(summary, file, id, **kwargs).first end |
#attachments ⇒ Array<Attachment>
Returns attachments for this bug.
112 113 114 |
# File 'lib/bicho/bug.rb', line 112 def @client.(id) end |
#format(format_string) ⇒ Object
125 126 127 128 |
# 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 |
#history ⇒ History
Returns history for this bug.
107 108 109 |
# File 'lib/bicho/bug.rb', line 107 def history @client.get_history(id).first end |
#id ⇒ Object
70 71 72 73 74 |
# File 'lib/bicho/bug.rb', line 70 def id # we define id to not get the deprecated # warning of object_id @data['id'] end |
#reopen!(comment, is_private = false) ⇒ Object
reopen a closed bug
96 97 98 |
# 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 |
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
66 67 68 |
# File 'lib/bicho/bug.rb', line 66 def respond_to_missing?(method_name, _include_private = false) @data.key?(method_name.to_s) || super end |
#to_h ⇒ Hash
131 132 133 |
# File 'lib/bicho/bug.rb', line 131 def to_h Hash[@data.to_a.map { |k, _| [k.to_sym, self[k.to_sym]] }] end |
#to_s ⇒ Object
76 77 78 |
# File 'lib/bicho/bug.rb', line 76 def to_s "##{id} - #{summary} (#{url})" end |
#url ⇒ Object
URL where the bug can be viewed Example: bugs.foo.com/2345
102 103 104 |
# File 'lib/bicho/bug.rb', line 102 def url "#{@client.site_url}/#{id}" end |