Class: Bugzilla::Bug
- Inherits:
-
APITemplate
- Object
- Skeleton
- APITemplate
- Bugzilla::Bug
- Defined in:
- lib/bugzilla.rb
Overview
Bugzilla::Bug
Bugzilla::Bug class is to access the Bugzilla::WebService::Bug API that allows you to file a new bug in Bugzilla or get information about bugs that have already been filed.
Constant Summary collapse
- FIELDS_SUMMARY =
["id", "product", "component", "status", "severity", "summary"]
- FIELDS_DETAILS =
FIELDS_SUMMARY + ["assigned_to", "internals", "priority", "resolution"]
- FIELDS_ALL =
["alias", "assigned_to", "component", "creation_time", "dupe_of", "external_bugs", "groups", "id", "internals", "is_open", "last_change_time", "priority", "product", "resolution", "severity", "status", "summary"]
Instance Method Summary collapse
-
#get_bugs(bugs, fields = ::Bugzilla::Bug::FIELDS_SUMMARY) ⇒ Object
Bugzilla::Bug#get_bugs(bugs, fields = Bugzilla::Bug::FIELDS_SUMMARY).
-
#get_comments(bugs) ⇒ Object
Bugzilla::Bug#get_comments(bugs).
Methods inherited from APITemplate
Methods inherited from Skeleton
Constructor Details
This class inherits a constructor from Bugzilla::APITemplate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bugzilla::APITemplate
Instance Method Details
#get_bugs(bugs, fields = ::Bugzilla::Bug::FIELDS_SUMMARY) ⇒ Object
Bugzilla::Bug#get_bugs(bugs, fields = Bugzilla::Bug::FIELDS_SUMMARY)
Get the bugs information from Bugzilla. either of String or Numeric or Array would be acceptable for bugs. you can specify the fields you want to look up with fields.
FWIW this name conflicts to Bugzilla API but this isn’s a primitive method since get_bugs method in WebService API is actually deprecated.
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
# File 'lib/bugzilla.rb', line 478 def get_bugs(bugs, fields = ::Bugzilla::Bug::FIELDS_SUMMARY) params = {} if bugs.kind_of?(Array) then params['ids'] = bugs elsif bugs.kind_of?(Integer) || bugs.kind_of?(String) then params['ids'] = [bugs] else raise ArgumentError, sprintf("Unknown type of arguments: %s", bugs.class) end unless fields.nil? then unless (fields - ::Bugzilla::Bug::FIELDS_ALL).empty? then raise ArgumentError, sprintf("Invalid fields: %s", (::Bugzilla::Bug::FIELDS_ALL - fields).join(' ')) end params['include_fields'] = fields end result = get(params) if fields.nil? || fields == ::Bugzilla::Bug::FIELDS_ALL then get_comments(bugs).each do |id, c| result['bugs'].each do |r| if r['id'].to_s == id then r['comments'] = c['comments'] r['comments'] = [] if r['comments'].nil? break end end end end # 'bugs' is only in interests. # XXX: need to deal with 'faults' ? result['bugs'] end |
#get_comments(bugs) ⇒ Object
Bugzilla::Bug#get_comments(bugs)
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/bugzilla.rb', line 521 def get_comments(bugs) params = {} if bugs.kind_of?(Array) then params['ids'] = bugs elsif bugs.kind_of?(Integer) || bugs.kind_of?(String) then params['ids'] = [bugs] else raise ArgumentError, sprintf("Unknown type of arguments: %s", bugs.class) end result = comments(params) # not supporting comment_ids. so drop "comments". result['bugs'] end |