Class: Bugzilla::Bug

Inherits:
APITemplate show all
Defined in:
lib/bugzilla/bug.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", "blocks", "cc", "classification",
"component", "creation_time", "creator", "deadline",
"depends_on", "dupe_of", "estimated_time", "groups",
"id", "is_cc_accessible", "is_confirmed", "is_open",
"is_creator_accessible", "keywords", "last_change_time",
"op_sys", "platform", "priority", "product", "qa_contact",
"remaining_time", "resolution", "see_also", "severity",
"status", "summary", "target_milestone", "update_token",
"url", "version", "whiteboard",
"external_bugs", "internals"]

Instance Method Summary collapse

Methods inherited from APITemplate

#initialize, #method_missing

Methods inherited from Skeleton

#initialize, #method_missing

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.



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
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/bugzilla/bug.rb', line 64

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)



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/bugzilla/bug.rb', line 107

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".
  ret = result['bugs']
  # creation_time was added in Bugzilla 4.4. copy the 'time' value to creation_time if not available for compatibility.
  unless check_version(4.4)[0] then
    ret.each do |id, o|
      o['comments'].each do |c|
        unless c.include?('creation_time') then
          c['creation_time'] = c['time']
        end
      end
    end
  end

  ret
end