Class: Bugzilla::Bug

Inherits:
APITemplate show all
Defined in:
lib/bugzilla/bug.rb

Overview

rdoc

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 =
%w[id product component status severity summary].freeze
FIELDS_DETAILS =
FIELDS_SUMMARY + %w[assigned_to internals priority resolution]
FIELDS_ALL =
%w[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].freeze

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 = FIELDS_SUMMARY) ⇒ Object

rdoc

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.



60
61
62
63
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
# File 'lib/bugzilla/bug.rb', line 60

def get_bugs(bugs, fields = FIELDS_SUMMARY)
  params = {}

  params['ids'] = case bugs
  when Array
    bugs
  when Integer || String
    [bugs]
  else
    raise ArgumentError, format('Unknown type of arguments: %s', bugs.class)
  end

  unless fields.nil?
    unless (fields - FIELDS_ALL).empty?
      raise ArgumentError, format('Invalid fields: %s', (FIELDS_ALL - fields).join(' '))
    end
    params['include_fields'] = fields
  end

  result = get(params)

  if fields.nil? || fields == FIELDS_ALL
    get_comments(bugs).each do |id, c|
      result['bugs'].each do |r|
        next unless r['id'].to_s == id.to_s
        r['comments'] = c['comments']
        r['comments'] = [] if r['comments'].nil?
        break
      end
    end
  end

  # 'bugs' is only in interests.
  # XXX: need to deal with 'faults' ?
  result['bugs']
end

#get_comments(bugs) ⇒ Object

rdoc

Bugzilla::Bug#get_comments(bugs)



102
103
104
105
106
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
# File 'lib/bugzilla/bug.rb', line 102

def get_comments(bugs)

  params = {}

  # TODO
  # this construction should be refactored to a method
  params['ids'] = case bugs
  when Array
    bugs
  when Integer || String
    [bugs]
  else
    raise ArgumentError, format('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]
    ret.each do |_id, o|
      o['comments'].each do |c|
        c['creation_time'] = c['time'] unless c.include?('creation_time')
      end
    end
  end

  ret
end