ruby-bugzilla 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/bzconsole +105 -11
- data/bin/bzconsole~ +100 -14
- data/lib/bugzilla/api_tmpl.rb +52 -0
- data/lib/bugzilla/api_tmpl.rb~ +51 -0
- data/lib/bugzilla/bug.rb +346 -0
- data/lib/bugzilla/bug.rb~ +323 -0
- data/lib/bugzilla/bugzilla.rb +141 -0
- data/lib/bugzilla/bugzilla.rb~ +140 -0
- data/lib/bugzilla/plugin.rb +82 -0
- data/lib/bugzilla/plugin.rb~ +82 -0
- data/lib/bugzilla/product.rb +156 -0
- data/lib/bugzilla/skeleton.rb +50 -0
- data/lib/bugzilla/skelton.rb~ +50 -0
- data/lib/bugzilla/user.rb +114 -0
- data/lib/bugzilla/user.rb~ +114 -0
- data/lib/bugzilla/version.rb +33 -0
- data/lib/bugzilla/xmlrpc.rb +81 -0
- data/lib/ruby-bugzilla/rhbugzilla.rb +1 -1
- data/lib/ruby-bugzilla/rhbugzilla.rb~ +173 -10
- metadata +101 -99
- data/lib/bugzilla.rb +0 -826
- data/lib/bugzilla.rb~ +0 -788
@@ -0,0 +1,156 @@
|
|
1
|
+
# product.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program 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, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
+
# Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
require 'bugzilla/api_tmpl'
|
23
|
+
|
24
|
+
module Bugzilla
|
25
|
+
|
26
|
+
=begin rdoc
|
27
|
+
|
28
|
+
=== Bugzilla::Product
|
29
|
+
|
30
|
+
Bugzilla::Product class is to access
|
31
|
+
the Bugzilla::WebService::Product API that allows you to
|
32
|
+
list the available Products and get information about them.
|
33
|
+
|
34
|
+
=end
|
35
|
+
|
36
|
+
class Product < APITemplate
|
37
|
+
|
38
|
+
=begin rdoc
|
39
|
+
|
40
|
+
==== Bugzilla::Product#selectable_products
|
41
|
+
|
42
|
+
Returns the products that the user can search on as Hash
|
43
|
+
contains the product name as the Hash key and Array as the
|
44
|
+
value. Array contains the list of _id_, _name_,
|
45
|
+
_description_ and _internals_ according to API documentation
|
46
|
+
though, actually the component, the version and the target
|
47
|
+
milestone.
|
48
|
+
|
49
|
+
=end
|
50
|
+
|
51
|
+
def selectable_products
|
52
|
+
ids = get_selectable_products
|
53
|
+
get(ids)
|
54
|
+
end # def selectable_products
|
55
|
+
|
56
|
+
=begin rdoc
|
57
|
+
|
58
|
+
==== Bugzilla::Product#enterable_products
|
59
|
+
|
60
|
+
Returns the products that the user can enter bugs against
|
61
|
+
as Hash contains the product name as the Hash key and Array
|
62
|
+
as the value. Array contains the list of _id_, _name_,
|
63
|
+
_description_ and _internals_ according to API documentation
|
64
|
+
though, actually the component, the version and the target
|
65
|
+
milestone.
|
66
|
+
|
67
|
+
=end
|
68
|
+
|
69
|
+
def enterable_products
|
70
|
+
ids = get_enterable_products
|
71
|
+
get(ids)
|
72
|
+
end # def enterable_products
|
73
|
+
|
74
|
+
=begin rdoc
|
75
|
+
|
76
|
+
==== Bugzilla::Product#accessible_products
|
77
|
+
|
78
|
+
Returns the products that the user can search or enter bugs
|
79
|
+
against as Hash contains the product name as the Hash key
|
80
|
+
and Array as the value. Array contains the list of _id_,
|
81
|
+
_name_, _description_ and _internals_ according to API
|
82
|
+
documentation though, actually the component, the version
|
83
|
+
and the target milestone.
|
84
|
+
|
85
|
+
=end
|
86
|
+
|
87
|
+
def accessible_products
|
88
|
+
ids = get_accessible_products
|
89
|
+
get(ids)
|
90
|
+
end # def accessible_products
|
91
|
+
|
92
|
+
=begin rdoc
|
93
|
+
|
94
|
+
==== Bugzilla::Product#get_selectable_products
|
95
|
+
|
96
|
+
Raw Bugzilla API to obtain the products that the user can
|
97
|
+
search on.
|
98
|
+
|
99
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
|
100
|
+
|
101
|
+
=end
|
102
|
+
|
103
|
+
=begin rdoc
|
104
|
+
|
105
|
+
==== Bugzilla::Product#get_enterable_products
|
106
|
+
|
107
|
+
Raw Bugzilla API to obtain the products that the user can
|
108
|
+
enter bugs against.
|
109
|
+
|
110
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
|
111
|
+
|
112
|
+
=end
|
113
|
+
|
114
|
+
=begin rdoc
|
115
|
+
|
116
|
+
==== Bugzilla::Product#get_accessible_products
|
117
|
+
|
118
|
+
Raw Bugzilla API to obtain the products that the user can
|
119
|
+
search or enter bugs against.
|
120
|
+
|
121
|
+
See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
|
122
|
+
|
123
|
+
=end
|
124
|
+
|
125
|
+
protected
|
126
|
+
|
127
|
+
def _get_selectable_products(cmd, *args)
|
128
|
+
@iface.call(cmd)
|
129
|
+
end # def _get_selectable_products
|
130
|
+
|
131
|
+
def _get_enterable_products(cmd, *args)
|
132
|
+
@iface.call(cmd)
|
133
|
+
end # def _get_entrable_products
|
134
|
+
|
135
|
+
def _get_accessible_products(cmd, *args)
|
136
|
+
@iface.call(cmd)
|
137
|
+
end # def _get_accessible_products
|
138
|
+
|
139
|
+
def _get(cmd, ids, *args)
|
140
|
+
params = {}
|
141
|
+
|
142
|
+
if ids.kind_of?(Hash) then
|
143
|
+
raise ArgumentError, sprintf("Invalid parameter: %s", ids.inspect) unless ids.include?('ids')
|
144
|
+
params[:ids] = ids['ids']
|
145
|
+
elsif ids.kind_of?(Array) then
|
146
|
+
params[:ids] = ids
|
147
|
+
else
|
148
|
+
params[:ids] = [ids]
|
149
|
+
end
|
150
|
+
|
151
|
+
@iface.call(cmd, params)
|
152
|
+
end # def _get
|
153
|
+
|
154
|
+
end # class Product
|
155
|
+
|
156
|
+
end # module Bugzilla
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# skeleton.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program 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, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
+
# Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
|
23
|
+
module Bugzilla
|
24
|
+
|
25
|
+
=begin rdoc
|
26
|
+
|
27
|
+
=== Bugzilla::Skeleton
|
28
|
+
|
29
|
+
=end
|
30
|
+
|
31
|
+
class Skeleton
|
32
|
+
|
33
|
+
def initialize(iface)
|
34
|
+
@iface = iface
|
35
|
+
end # def initialize
|
36
|
+
|
37
|
+
def method_missing(symbol, *args)
|
38
|
+
m = "_#{symbol}"
|
39
|
+
klass = self.class.to_s.sub(/\ABugzilla::/, '')
|
40
|
+
fm = "#{klass}.#{symbol}"
|
41
|
+
if self.respond_to?(m) then
|
42
|
+
__send__(m, fm, *args)
|
43
|
+
else
|
44
|
+
raise NoMethodError, sprintf("No such Bugzilla APIs: %s.%s", klass, symbol)
|
45
|
+
end
|
46
|
+
end # def method_missing
|
47
|
+
|
48
|
+
end # class Skeleton
|
49
|
+
|
50
|
+
end # module Bugzilla
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# skelton.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program 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, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
+
# Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
|
23
|
+
module Bugzilla
|
24
|
+
|
25
|
+
=begin rdoc
|
26
|
+
|
27
|
+
=== Bugzilla::Skeleton
|
28
|
+
|
29
|
+
=end
|
30
|
+
|
31
|
+
class Skeleton
|
32
|
+
|
33
|
+
def initialize(iface)
|
34
|
+
@iface = iface
|
35
|
+
end # def initialize
|
36
|
+
|
37
|
+
def method_missing(symbol, *args)
|
38
|
+
m = "_#{symbol}"
|
39
|
+
klass = self.class.to_s.sub(/\ABugzilla::/, '')
|
40
|
+
fm = "#{klass}.#{symbol}"
|
41
|
+
if self.respond_to?(m) then
|
42
|
+
__send__(m, fm, *args)
|
43
|
+
else
|
44
|
+
raise NoMethodError, sprintf("No such Bugzilla APIs: %s.%s", klass, symbol)
|
45
|
+
end
|
46
|
+
end # def method_missing
|
47
|
+
|
48
|
+
end # class Skeleton
|
49
|
+
|
50
|
+
end # module Bugzilla
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# user.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program 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, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
+
# Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
require 'bugzilla/api_tmpl'
|
23
|
+
|
24
|
+
module Bugzilla
|
25
|
+
|
26
|
+
=begin rdoc
|
27
|
+
|
28
|
+
=== Bugzilla::User
|
29
|
+
|
30
|
+
Bugzilla::User class is to access the
|
31
|
+
Bugzilla::WebService::User API that allows you to create
|
32
|
+
User Accounts and log in/out using an existing account.
|
33
|
+
|
34
|
+
=end
|
35
|
+
|
36
|
+
class User < APITemplate
|
37
|
+
|
38
|
+
=begin rdoc
|
39
|
+
|
40
|
+
==== Bugzilla::User#session(user, password)
|
41
|
+
|
42
|
+
Keeps the bugzilla session during doing something in the block.
|
43
|
+
|
44
|
+
=end
|
45
|
+
|
46
|
+
def session(user, password)
|
47
|
+
fname = File.join(ENV['HOME'], '.ruby-bugzilla-cookie.yml')
|
48
|
+
if File.exist?(fname) && File.lstat(fname).mode & 0600 == 0600 then
|
49
|
+
conf = YAML.load(File.open(fname).read)
|
50
|
+
host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)
|
51
|
+
cookie = conf[host]
|
52
|
+
unless cookie.nil? then
|
53
|
+
@iface.cookie = cookie
|
54
|
+
print "Using cookie\n"
|
55
|
+
yield
|
56
|
+
conf[host] = @iface.cookie
|
57
|
+
File.open(fname, 'w') {|f| f.chmod(0600); f.write(conf.to_yaml)}
|
58
|
+
return
|
59
|
+
end
|
60
|
+
end
|
61
|
+
if user.nil? || password.nil? then
|
62
|
+
yield
|
63
|
+
else
|
64
|
+
login({'login'=>user, 'password'=>password, 'remember'=>true})
|
65
|
+
yield
|
66
|
+
logout
|
67
|
+
end
|
68
|
+
|
69
|
+
end # def session
|
70
|
+
|
71
|
+
=begin rdoc
|
72
|
+
|
73
|
+
==== Bugzilla::User#login(params)
|
74
|
+
|
75
|
+
Raw Bugzilla API to log into Bugzilla.
|
76
|
+
|
77
|
+
=end
|
78
|
+
|
79
|
+
=begin rdoc
|
80
|
+
|
81
|
+
==== Bugzilla::User#logout
|
82
|
+
|
83
|
+
Raw Bugzilla API to log out the user.
|
84
|
+
|
85
|
+
=end
|
86
|
+
|
87
|
+
protected
|
88
|
+
|
89
|
+
def _login(cmd, *args)
|
90
|
+
raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash)
|
91
|
+
|
92
|
+
@iface.call(cmd,args[0])
|
93
|
+
end # def _login
|
94
|
+
|
95
|
+
def _logout(cmd, *args)
|
96
|
+
@iface.call(cmd)
|
97
|
+
end # def _logout
|
98
|
+
|
99
|
+
def __offer_account_by_email(cmd, *args)
|
100
|
+
# FIXME
|
101
|
+
end # def _offer_account_by_email
|
102
|
+
|
103
|
+
def __create(cmd, *args)
|
104
|
+
# FIXME
|
105
|
+
end # def _create
|
106
|
+
|
107
|
+
def __get(cmd, *args)
|
108
|
+
requires_version(cmd, 3.4)
|
109
|
+
# FIXME
|
110
|
+
end # def _get
|
111
|
+
|
112
|
+
end # class User
|
113
|
+
|
114
|
+
end # module Bugzilla
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# user.rb
|
2
|
+
# Copyright (C) 2010-2012 Red Hat, Inc.
|
3
|
+
#
|
4
|
+
# Authors:
|
5
|
+
# Akira TAGOH <tagoh@redhat.com>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program 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, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
+
# Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
require 'bugzilla/api_tmpl'
|
23
|
+
|
24
|
+
module Bugzilla
|
25
|
+
|
26
|
+
=begin rdoc
|
27
|
+
|
28
|
+
=== Bugzilla::User
|
29
|
+
|
30
|
+
Bugzilla::User class is to access the
|
31
|
+
Bugzilla::WebService::User API that allows you to create
|
32
|
+
User Accounts and log in/out using an existing account.
|
33
|
+
|
34
|
+
=end
|
35
|
+
|
36
|
+
class User < APITemplate
|
37
|
+
|
38
|
+
=begin rdoc
|
39
|
+
|
40
|
+
==== Bugzilla::User#session(user, password)
|
41
|
+
|
42
|
+
Keeps the bugzilla session during doing something in the block.
|
43
|
+
|
44
|
+
=end
|
45
|
+
|
46
|
+
def session(user, password)
|
47
|
+
fname = File.join(ENV['HOME'], '.ruby-bugzilla-cookie.yml')
|
48
|
+
if File.exist?(fname) && File.lstat(fname).mode & 0600 == 0600 then
|
49
|
+
conf = YAML.load(File.open(fname).read)
|
50
|
+
host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)
|
51
|
+
cookie = conf[host]
|
52
|
+
unless cookie.nil? then
|
53
|
+
@iface.cookie = cookie
|
54
|
+
print "Using cookie\n"
|
55
|
+
yield
|
56
|
+
conf[host] = @iface.cookie
|
57
|
+
File.open(fname, 'w') {|f| f.chmod(0600); f.write(conf.to_yaml)}
|
58
|
+
return
|
59
|
+
end
|
60
|
+
end
|
61
|
+
if user.nil? || password.nil? then
|
62
|
+
yield
|
63
|
+
else
|
64
|
+
login({'login'=>user, 'password'=>password, 'remember'=>true})
|
65
|
+
yield
|
66
|
+
logout
|
67
|
+
end
|
68
|
+
|
69
|
+
end # def session
|
70
|
+
|
71
|
+
=begin rdoc
|
72
|
+
|
73
|
+
==== Bugzilla::User#login(params)
|
74
|
+
|
75
|
+
Raw Bugzilla API to log into Bugzilla.
|
76
|
+
|
77
|
+
=end
|
78
|
+
|
79
|
+
=begin rdoc
|
80
|
+
|
81
|
+
==== Bugzilla::User#logout
|
82
|
+
|
83
|
+
Raw Bugzilla API to log out the user.
|
84
|
+
|
85
|
+
=end
|
86
|
+
|
87
|
+
protected
|
88
|
+
|
89
|
+
def _login(cmd, *args)
|
90
|
+
raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash)
|
91
|
+
|
92
|
+
@iface.call(cmd,args[0])
|
93
|
+
end # def _login
|
94
|
+
|
95
|
+
def _logout(cmd, *args)
|
96
|
+
@iface.call(cmd)
|
97
|
+
end # def _logout
|
98
|
+
|
99
|
+
def __offer_account_by_email(cmd, *args)
|
100
|
+
# FIXME
|
101
|
+
end # def _offer_account_by_email
|
102
|
+
|
103
|
+
def __create(cmd, *args)
|
104
|
+
# FIXME
|
105
|
+
end # def _create
|
106
|
+
|
107
|
+
def __get(cmd, *args)
|
108
|
+
requires_version(cmd, 3.4)
|
109
|
+
# FIXME
|
110
|
+
end # def _get
|
111
|
+
|
112
|
+
end # class User
|
113
|
+
|
114
|
+
end # module Bugzilla
|