ruby-bugzilla 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +158 -503
- data/README.rdoc +9 -1
- data/bin/bzconsole +8 -10
- data/lib/bugzilla/api_tmpl.rb +6 -8
- data/lib/bugzilla/api_tmpl.rb~ +1 -0
- data/lib/bugzilla/bug.rb +27 -8
- data/lib/bugzilla/bug.rb~ +26 -3
- data/lib/bugzilla/bugzilla.rb +28 -8
- data/lib/bugzilla/bugzilla.rb~ +2 -1
- data/lib/bugzilla/classification.rb +76 -0
- data/lib/bugzilla/group.rb +46 -0
- data/lib/bugzilla/group.rb~ +66 -0
- data/lib/bugzilla/plugin.rb +6 -8
- data/lib/bugzilla/product.rb +68 -33
- data/lib/bugzilla/product.rb~ +156 -0
- data/lib/bugzilla/skeleton.rb +6 -8
- data/lib/bugzilla/skeleton.rb~ +50 -0
- data/lib/bugzilla/user.rb +15 -8
- data/lib/bugzilla/version.rb +7 -9
- data/lib/bugzilla/version.rb~ +33 -0
- data/lib/bugzilla/xmlrpc.rb +6 -8
- data/lib/bugzilla/xmlrpc.rb~ +81 -0
- data/lib/bugzilla.rb +24 -0
- data/lib/bugzilla.rb~ +24 -0
- data/lib/ruby-bugzilla/rhbugzilla.rb +7 -9
- data/lib/ruby-bugzilla/rhbugzilla.rb~ +1 -1
- metadata +11 -2
data/README.rdoc
CHANGED
@@ -4,15 +4,23 @@ This aims to provide similar features in Ruby to access to Bugzilla
|
|
4
4
|
through {WebService APIs}[http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService.html]. currently the following
|
5
5
|
APIs are available:
|
6
6
|
|
7
|
+
* Bugzilla::WebService::Bug[http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html]
|
7
8
|
* Bugzilla::WebService::Bugzilla[http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html]
|
9
|
+
* Bugzilla::WebService::Classification[http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Classification.html]
|
8
10
|
* Bugzilla::WebService::Product[http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html]
|
9
|
-
* Bugzilla::WebService::Bug[http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html]
|
10
11
|
* Bugzilla::WebService::User[http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/User.html]
|
11
12
|
|
12
13
|
== Copyright
|
13
14
|
|
14
15
|
Copyright (c) 2010-2012 Red Hat, Inc. See COPYING for details.
|
15
16
|
|
17
|
+
== License
|
18
|
+
|
19
|
+
This library is free software: you can redistribute it and/or
|
20
|
+
modify it under the terms of the GNU Lesser General Public
|
21
|
+
License as published by the Free Software Foundation, either
|
22
|
+
version 3 of the License, or (at your option) any later version.
|
23
|
+
|
16
24
|
== Authors
|
17
25
|
|
18
26
|
Akira TAGOH
|
data/bin/bzconsole
CHANGED
@@ -1,25 +1,23 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
# bzconsole
|
3
|
+
# bzconsole
|
4
4
|
# Copyright (C) 2010-2012 Red Hat, Inc.
|
5
5
|
#
|
6
6
|
# Authors:
|
7
7
|
# Akira TAGOH <tagoh@redhat.com>
|
8
8
|
#
|
9
|
-
# This library is free software
|
9
|
+
# This library is free software: you can redistribute it and/or
|
10
10
|
# modify it under the terms of the GNU Lesser General Public
|
11
|
-
# License as published by the Free Software Foundation
|
12
|
-
# version
|
11
|
+
# License as published by the Free Software Foundation, either
|
12
|
+
# version 3 of the License, or (at your option) any later version.
|
13
13
|
#
|
14
14
|
# This library is distributed in the hope that it will be useful,
|
15
15
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
#
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
18
|
#
|
19
|
-
# You should have received a copy of the GNU
|
20
|
-
#
|
21
|
-
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
22
|
-
# Boston, MA 02111-1307, USA.
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
23
21
|
|
24
22
|
require 'optparse'
|
25
23
|
require 'time'
|
data/lib/bugzilla/api_tmpl.rb
CHANGED
@@ -4,20 +4,18 @@
|
|
4
4
|
# Authors:
|
5
5
|
# Akira TAGOH <tagoh@redhat.com>
|
6
6
|
#
|
7
|
-
# This
|
8
|
-
# it under the terms of the GNU General Public
|
9
|
-
# the Free Software Foundation
|
10
|
-
# (at your option) any later version.
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
11
|
#
|
12
|
-
# This
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
13
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
14
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
15
|
# GNU General Public License for more details.
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program
|
19
|
-
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
-
# Boston, MA 02111-1307, USA.
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
19
|
|
22
20
|
require 'bugzilla/skeleton'
|
23
21
|
require 'bugzilla/bugzilla'
|
data/lib/bugzilla/api_tmpl.rb~
CHANGED
data/lib/bugzilla/bug.rb
CHANGED
@@ -4,20 +4,18 @@
|
|
4
4
|
# Authors:
|
5
5
|
# Akira TAGOH <tagoh@redhat.com>
|
6
6
|
#
|
7
|
-
# This
|
8
|
-
# it under the terms of the GNU General Public
|
9
|
-
# the Free Software Foundation
|
10
|
-
# (at your option) any later version.
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
11
|
#
|
12
|
-
# This
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
13
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
14
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
15
|
# GNU General Public License for more details.
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program
|
19
|
-
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
-
# Boston, MA 02111-1307, USA.
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
19
|
|
22
20
|
require 'bugzilla/api_tmpl'
|
23
21
|
|
@@ -175,6 +173,8 @@ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html
|
|
175
173
|
Raw Bugzilla API to obtain the information about particular
|
176
174
|
bugs in the database.
|
177
175
|
|
176
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html
|
177
|
+
|
178
178
|
=end
|
179
179
|
|
180
180
|
=begin rdoc
|
@@ -184,6 +184,8 @@ bugs in the database.
|
|
184
184
|
Raw Bugzilla API to obtain the history of changes for
|
185
185
|
particular bugs in the database.
|
186
186
|
|
187
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html
|
188
|
+
|
187
189
|
=end
|
188
190
|
|
189
191
|
=begin rdoc
|
@@ -193,6 +195,18 @@ particular bugs in the database.
|
|
193
195
|
Raw Bugzilla API to search for bugs based on particular
|
194
196
|
criteria.
|
195
197
|
|
198
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html
|
199
|
+
|
200
|
+
=end
|
201
|
+
|
202
|
+
=begin rdoc
|
203
|
+
|
204
|
+
==== Bugzilla::Bug#create(params)
|
205
|
+
|
206
|
+
Raw Bugzilla API to create a new bug in Bugzilla.
|
207
|
+
|
208
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html
|
209
|
+
|
196
210
|
=end
|
197
211
|
|
198
212
|
protected
|
@@ -341,6 +355,11 @@ criteria.
|
|
341
355
|
# FIXME
|
342
356
|
end # def _update_see_also
|
343
357
|
|
358
|
+
def __update_tags(cmd, *args)
|
359
|
+
requires_version(cmd, 4.4)
|
360
|
+
# FIXME
|
361
|
+
end # def _update_tags
|
362
|
+
|
344
363
|
end # class Bug
|
345
364
|
|
346
365
|
end # module Bugzilla
|
data/lib/bugzilla/bug.rb~
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# bug.rb
|
2
2
|
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
3
|
#
|
4
4
|
# Authors:
|
@@ -294,8 +294,31 @@ criteria.
|
|
294
294
|
@iface.call(cmd, args[0])
|
295
295
|
end # def _search
|
296
296
|
|
297
|
-
def
|
298
|
-
|
297
|
+
def _create(cmd, *args)
|
298
|
+
raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash)
|
299
|
+
|
300
|
+
required_fields = [:product, :component, :summary, :version]
|
301
|
+
defaulted_fields = [:description, :op_sys, :platform, :priority, :severity]
|
302
|
+
|
303
|
+
res = check_version("3.0.4")
|
304
|
+
unless res[0] then
|
305
|
+
required_fields.push(*defaulted_fields)
|
306
|
+
end
|
307
|
+
required_fields.each do |f|
|
308
|
+
raise ArgumentError, sprintf("Required fields isn't given: %s", f) unless args[0].include?(f)
|
309
|
+
end
|
310
|
+
res = check_version(4.0)
|
311
|
+
unless res[0] then
|
312
|
+
raise ArgumentError, "groups field isn't available in this bugzilla" if args[0].include?("groups")
|
313
|
+
raise ArgumentError, "comment_is_private field isn't available in this bugzilla" if args[0].include?("comment_is_private")
|
314
|
+
else
|
315
|
+
if args[0].include?("commentprivacy") then
|
316
|
+
args[0]["comment_is_private"] = args[0]["commentprivacy"]
|
317
|
+
args[0].delete("commentprivacy")
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
@iface.call(cmd, args[0])
|
299
322
|
end # def _create
|
300
323
|
|
301
324
|
def __add_attachment(cmd, *args)
|
data/lib/bugzilla/bugzilla.rb
CHANGED
@@ -4,20 +4,18 @@
|
|
4
4
|
# Authors:
|
5
5
|
# Akira TAGOH <tagoh@redhat.com>
|
6
6
|
#
|
7
|
-
# This
|
8
|
-
# it under the terms of the GNU General Public
|
9
|
-
# the Free Software Foundation
|
10
|
-
# (at your option) any later version.
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
11
|
#
|
12
|
-
# This
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
13
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
14
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
15
|
# GNU General Public License for more details.
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program
|
19
|
-
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
-
# Boston, MA 02111-1307, USA.
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
19
|
|
22
20
|
require 'bugzilla/skeleton'
|
23
21
|
|
@@ -112,6 +110,16 @@ running on.
|
|
112
110
|
|
113
111
|
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
|
114
112
|
|
113
|
+
=end
|
114
|
+
|
115
|
+
=begin rdoc
|
116
|
+
|
117
|
+
==== Bugzilla::Bugzilla#parameters
|
118
|
+
|
119
|
+
Raw Bugzilla API to obtain parameter values currently used in Bugzilla.
|
120
|
+
|
121
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.html
|
122
|
+
|
115
123
|
=end
|
116
124
|
|
117
125
|
protected
|
@@ -136,6 +144,18 @@ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bugzilla.ht
|
|
136
144
|
@iface.call(cmd)
|
137
145
|
end # def _time
|
138
146
|
|
147
|
+
def _parameters(cmd, *args)
|
148
|
+
requires_version(cmd, 4.4)
|
149
|
+
|
150
|
+
@iface.call(cmd)
|
151
|
+
end # def _parameters
|
152
|
+
|
153
|
+
def __last_audit_time(cmd, *args)
|
154
|
+
requires_version(cmd, 4.4)
|
155
|
+
|
156
|
+
# FIXME
|
157
|
+
end # def _last_audit_time
|
158
|
+
|
139
159
|
end # class Bugzilla
|
140
160
|
|
141
161
|
end # module Bugzilla
|
data/lib/bugzilla/bugzilla.rb~
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
# classification.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'bugzilla/api_tmpl'
|
21
|
+
|
22
|
+
module Bugzilla
|
23
|
+
|
24
|
+
=begin rdoc
|
25
|
+
|
26
|
+
=== Bugzilla::Classification
|
27
|
+
|
28
|
+
Bugzilla::Classification class is to access
|
29
|
+
the Bugzilla::WebService::Classification API that allows you
|
30
|
+
to deal with the available Classifications.
|
31
|
+
|
32
|
+
=end
|
33
|
+
|
34
|
+
class Classification < APITemplate
|
35
|
+
|
36
|
+
=begin rdoc
|
37
|
+
|
38
|
+
==== Bugzilla::Classification#get(params)
|
39
|
+
|
40
|
+
Raw Bugzilla API to obtain the information about a set of
|
41
|
+
classifications.
|
42
|
+
|
43
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Classification.html
|
44
|
+
|
45
|
+
=end
|
46
|
+
|
47
|
+
def _get(cmd, args[0])
|
48
|
+
requires_version(cmd, 4.4)
|
49
|
+
|
50
|
+
params = {}
|
51
|
+
|
52
|
+
if ids.kind_of?(Hash) then
|
53
|
+
raise ArgumentError, sprintf("Invalid parameter: %s", ids.inspect) unless ids.include?('ids') || ids.include?('names')
|
54
|
+
params[:ids] = ids['ids'] || ids['names']
|
55
|
+
elsif ids.kind_of?(Array) then
|
56
|
+
r = ids.map {|x| x.kind_of?(Integer) ? x : nil}.compact
|
57
|
+
if r.length != ids.length then
|
58
|
+
params[:names] = ids
|
59
|
+
else
|
60
|
+
params[:ids] = ids
|
61
|
+
end
|
62
|
+
else
|
63
|
+
if ids.kind_of?(Integer) then
|
64
|
+
params[:ids] = [ids]
|
65
|
+
else
|
66
|
+
params[:names] = [ids]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
@iface.call(cmd, params)
|
71
|
+
end # def _get
|
72
|
+
|
73
|
+
end # class Classification
|
74
|
+
|
75
|
+
end # module Bugzilla
|
76
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# group.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'bugzilla/api_tmpl'
|
21
|
+
|
22
|
+
module Bugzilla
|
23
|
+
|
24
|
+
=begin rdoc
|
25
|
+
|
26
|
+
=== Bugzilla::Group
|
27
|
+
|
28
|
+
Bugzilla::Group class is to access
|
29
|
+
the Bugzilla::WebService::Group API that allows you to
|
30
|
+
create Groups and get information about them.
|
31
|
+
|
32
|
+
=end
|
33
|
+
|
34
|
+
class Group < APITemplate
|
35
|
+
|
36
|
+
def __create(cmd, *args)
|
37
|
+
# FIXME
|
38
|
+
end # def _create
|
39
|
+
|
40
|
+
def __update(cmd, *args)
|
41
|
+
# FIXME
|
42
|
+
end # def _update
|
43
|
+
|
44
|
+
end # class Group
|
45
|
+
|
46
|
+
end # module Bugzilla
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# group.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'bugzilla/api_tmpl'
|
21
|
+
|
22
|
+
module Bugzilla
|
23
|
+
|
24
|
+
=begin rdoc
|
25
|
+
|
26
|
+
=== Bugzilla::Group
|
27
|
+
|
28
|
+
Bugzilla::Group class is to access
|
29
|
+
the Bugzilla::WebService::Group API that allows you to
|
30
|
+
create Groups and get information about them.
|
31
|
+
|
32
|
+
=end
|
33
|
+
|
34
|
+
class Group < APITemplate
|
35
|
+
|
36
|
+
=begin rdoc
|
37
|
+
|
38
|
+
==== Bugzilla::Group#create(params)
|
39
|
+
|
40
|
+
Raw Bugzilla API to create a new group in Bugzilla.
|
41
|
+
|
42
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Group.html
|
43
|
+
|
44
|
+
=end
|
45
|
+
|
46
|
+
=begin rdoc
|
47
|
+
|
48
|
+
==== Bugzilla::Group#update(params)
|
49
|
+
|
50
|
+
Raw Bugzilla APi to update a group in Bugzilla.
|
51
|
+
|
52
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Group.html
|
53
|
+
|
54
|
+
=end
|
55
|
+
|
56
|
+
def __create(cmd, *args)
|
57
|
+
# FIXME
|
58
|
+
end # def _create
|
59
|
+
|
60
|
+
def __update(cmd, *args)
|
61
|
+
# FIXME
|
62
|
+
end # def _update
|
63
|
+
|
64
|
+
end # class Group
|
65
|
+
|
66
|
+
end # module Bugzilla
|
data/lib/bugzilla/plugin.rb
CHANGED
@@ -4,20 +4,18 @@
|
|
4
4
|
# Authors:
|
5
5
|
# Akira TAGOH <tagoh@redhat.com>
|
6
6
|
#
|
7
|
-
# This
|
8
|
-
# it under the terms of the GNU General Public
|
9
|
-
# the Free Software Foundation
|
10
|
-
# (at your option) any later version.
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
11
|
#
|
12
|
-
# This
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
13
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
14
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
15
|
# GNU General Public License for more details.
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program
|
19
|
-
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
-
# Boston, MA 02111-1307, USA.
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
19
|
|
22
20
|
|
23
21
|
module Bugzilla
|
data/lib/bugzilla/product.rb
CHANGED
@@ -4,20 +4,18 @@
|
|
4
4
|
# Authors:
|
5
5
|
# Akira TAGOH <tagoh@redhat.com>
|
6
6
|
#
|
7
|
-
# This
|
8
|
-
# it under the terms of the GNU General Public
|
9
|
-
# the Free Software Foundation
|
10
|
-
# (at your option) any later version.
|
7
|
+
# This library is free software: you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation, either
|
10
|
+
# version 3 of the License, or (at your option) any later version.
|
11
11
|
#
|
12
|
-
# This
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
13
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
14
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
15
|
# GNU General Public License for more details.
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program
|
19
|
-
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
-
# Boston, MA 02111-1307, USA.
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
19
|
|
22
20
|
require 'bugzilla/api_tmpl'
|
23
21
|
|
@@ -39,54 +37,57 @@ list the available Products and get information about them.
|
|
39
37
|
|
40
38
|
==== Bugzilla::Product#selectable_products
|
41
39
|
|
42
|
-
Returns the products that the user
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
Returns Hash table for the products information that the user
|
41
|
+
can search on. the Hash key is the product name and containing
|
42
|
+
a Hash table which contains id, name, description,
|
43
|
+
is_active, default_milestone, has_uncomfirmed, classification,
|
44
|
+
components, versions and milestones. please see
|
45
|
+
http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html#get
|
46
|
+
for more details.
|
48
47
|
|
49
48
|
=end
|
50
49
|
|
51
50
|
def selectable_products
|
52
51
|
ids = get_selectable_products
|
53
|
-
get(ids)
|
52
|
+
Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
|
54
53
|
end # def selectable_products
|
55
54
|
|
56
55
|
=begin rdoc
|
57
56
|
|
58
57
|
==== Bugzilla::Product#enterable_products
|
59
58
|
|
60
|
-
Returns the products that the user
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
Returns Hash table for the products information that the user
|
60
|
+
can enter bugs against. the Hash key is the product name and
|
61
|
+
containing a Hash table which contains id, name, description,
|
62
|
+
is_active, default_milestone, has_uncomfirmed, classification,
|
63
|
+
components, versions and milestones. please see
|
64
|
+
http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html#get
|
65
|
+
for more details.
|
66
66
|
|
67
67
|
=end
|
68
68
|
|
69
69
|
def enterable_products
|
70
70
|
ids = get_enterable_products
|
71
|
-
get(ids)
|
71
|
+
Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
|
72
72
|
end # def enterable_products
|
73
73
|
|
74
74
|
=begin rdoc
|
75
75
|
|
76
76
|
==== Bugzilla::Product#accessible_products
|
77
77
|
|
78
|
-
Returns the products that the user
|
79
|
-
|
80
|
-
and
|
81
|
-
|
82
|
-
|
83
|
-
|
78
|
+
Returns Hash table for the products information that the user
|
79
|
+
can search or enter bugs against. the Hash key is the product
|
80
|
+
name and containing a Hash table which contains id, name, description,
|
81
|
+
is_active, default_milestone, has_uncomfirmed, classification,
|
82
|
+
components, versions and milestones. please see
|
83
|
+
http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html#get
|
84
|
+
for more details.
|
84
85
|
|
85
86
|
=end
|
86
87
|
|
87
88
|
def accessible_products
|
88
89
|
ids = get_accessible_products
|
89
|
-
get(ids)
|
90
|
+
Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
|
90
91
|
end # def accessible_products
|
91
92
|
|
92
93
|
=begin rdoc
|
@@ -120,6 +121,17 @@ search or enter bugs against.
|
|
120
121
|
|
121
122
|
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
|
122
123
|
|
124
|
+
=end
|
125
|
+
|
126
|
+
=begin rdoc
|
127
|
+
|
128
|
+
==== Bugzilla::Product#get(params)
|
129
|
+
|
130
|
+
Raw Bugzilla API to obtain a list of information about the products
|
131
|
+
passed to it.
|
132
|
+
|
133
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
|
134
|
+
|
123
135
|
=end
|
124
136
|
|
125
137
|
protected
|
@@ -137,20 +149,43 @@ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.htm
|
|
137
149
|
end # def _get_accessible_products
|
138
150
|
|
139
151
|
def _get(cmd, ids, *args)
|
152
|
+
# This is still in experimental and apparently the behavior was changed since 4.2.
|
153
|
+
# We don't keep the backward-compatibility and just require the proper version here.
|
154
|
+
requires_version(cmd, 4.2)
|
155
|
+
|
140
156
|
params = {}
|
141
157
|
|
142
158
|
if ids.kind_of?(Hash) then
|
143
|
-
raise ArgumentError, sprintf("Invalid parameter: %s", ids.inspect) unless ids.include?('ids')
|
144
|
-
params[:ids] = ids['ids']
|
159
|
+
raise ArgumentError, sprintf("Invalid parameter: %s", ids.inspect) unless ids.include?('ids') || ids.include?('names')
|
160
|
+
params[:ids] = ids['ids'] || ids['names']
|
145
161
|
elsif ids.kind_of?(Array) then
|
146
|
-
|
162
|
+
r = ids.map {|x| x.kind_of?(Integer) ? x : nil}.compact
|
163
|
+
if r.length != ids.length then
|
164
|
+
params[:names] = ids
|
165
|
+
else
|
166
|
+
params[:ids] = ids
|
167
|
+
end
|
147
168
|
else
|
148
|
-
|
169
|
+
if ids.kind_of?(Integer) then
|
170
|
+
params[:ids] = [ids]
|
171
|
+
else
|
172
|
+
params[:names] = [ids]
|
173
|
+
end
|
149
174
|
end
|
150
175
|
|
151
176
|
@iface.call(cmd, params)
|
152
177
|
end # def _get
|
153
178
|
|
179
|
+
def __create(cmd, *args)
|
180
|
+
# FIXME
|
181
|
+
end # def _create
|
182
|
+
|
183
|
+
def __update(cmd, *args)
|
184
|
+
requires_version(cmd, 4.4)
|
185
|
+
|
186
|
+
# FIXME
|
187
|
+
end # def _update
|
188
|
+
|
154
189
|
end # class Product
|
155
190
|
|
156
191
|
end # module Bugzilla
|