ruby-bugzilla-nomagick 0.6.4.2

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.
@@ -0,0 +1,80 @@
1
+ # plugin.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
+
21
+ module Bugzilla
22
+
23
+ =begin rdoc
24
+
25
+ === Bugzilla::Plugin
26
+
27
+ =end
28
+
29
+ module Plugin
30
+
31
+ =begin rdoc
32
+
33
+ ==== Bugzilla::Plugin::Template
34
+
35
+ =end
36
+
37
+ class Template
38
+ @@plugins = []
39
+
40
+ def initialize
41
+ @hostname = nil
42
+ end # def initialize
43
+
44
+ attr_reader :hostname
45
+
46
+ def Template.inherited(subclass)
47
+ @@plugins << subclass
48
+ end # def inherited
49
+
50
+ def run(hook, host, *args)
51
+ @@plugins.each do |k|
52
+ i = k.new
53
+ if i.hostname == host || host.nil? then
54
+ case hook
55
+ when :parser
56
+ i.parserhook(*args)
57
+ when :pre
58
+ i.prehook(*args)
59
+ when :post
60
+ i.posthook(*args)
61
+ else
62
+ end
63
+ end
64
+ end
65
+ end # def run
66
+
67
+ def parserhook(parser, argv, opts)
68
+ end # def parserhook
69
+
70
+ def prehook(cmd, opts)
71
+ end # def prehook
72
+
73
+ def posthook(cmd, opts)
74
+ end # def posthook
75
+
76
+ end # class Template
77
+
78
+ end # module Plugin
79
+
80
+ end # module Bugzilla
@@ -0,0 +1,191 @@
1
+ # product.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::Product
27
+
28
+ Bugzilla::Product class is to access
29
+ the Bugzilla::WebService::Product API that allows you to
30
+ list the available Products and get information about them.
31
+
32
+ =end
33
+
34
+ class Product < APITemplate
35
+
36
+ =begin rdoc
37
+
38
+ ==== Bugzilla::Product#selectable_products
39
+
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.
47
+
48
+ =end
49
+
50
+ def selectable_products
51
+ ids = get_selectable_products
52
+ Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
53
+ end # def selectable_products
54
+
55
+ =begin rdoc
56
+
57
+ ==== Bugzilla::Product#enterable_products
58
+
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
+
67
+ =end
68
+
69
+ def enterable_products
70
+ ids = get_enterable_products
71
+ Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
72
+ end # def enterable_products
73
+
74
+ =begin rdoc
75
+
76
+ ==== Bugzilla::Product#accessible_products
77
+
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.
85
+
86
+ =end
87
+
88
+ def accessible_products
89
+ ids = get_accessible_products
90
+ Hash[*get(ids)['products'].map {|x| [x['name'], x]}.flatten]
91
+ end # def accessible_products
92
+
93
+ =begin rdoc
94
+
95
+ ==== Bugzilla::Product#get_selectable_products
96
+
97
+ Raw Bugzilla API to obtain the products that the user can
98
+ search on.
99
+
100
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
101
+
102
+ =end
103
+
104
+ =begin rdoc
105
+
106
+ ==== Bugzilla::Product#get_enterable_products
107
+
108
+ Raw Bugzilla API to obtain the products that the user can
109
+ enter bugs against.
110
+
111
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
112
+
113
+ =end
114
+
115
+ =begin rdoc
116
+
117
+ ==== Bugzilla::Product#get_accessible_products
118
+
119
+ Raw Bugzilla API to obtain the products that the user can
120
+ search or enter bugs against.
121
+
122
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Product.html
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
+
135
+ =end
136
+
137
+ protected
138
+
139
+ def _get_selectable_products(cmd, *args)
140
+ @iface.call(cmd)
141
+ end # def _get_selectable_products
142
+
143
+ def _get_enterable_products(cmd, *args)
144
+ @iface.call(cmd)
145
+ end # def _get_entrable_products
146
+
147
+ def _get_accessible_products(cmd, *args)
148
+ @iface.call(cmd)
149
+ end # def _get_accessible_products
150
+
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
+
156
+ params = {}
157
+
158
+ if ids.kind_of?(Hash) then
159
+ raise ArgumentError, sprintf("Invalid parameter: %s", ids.inspect) unless ids.include?('ids') || ids.include?('names')
160
+ params[:ids] = ids['ids'] || ids['names']
161
+ elsif ids.kind_of?(Array) then
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
168
+ else
169
+ if ids.kind_of?(Integer) then
170
+ params[:ids] = [ids]
171
+ else
172
+ params[:names] = [ids]
173
+ end
174
+ end
175
+
176
+ @iface.call(cmd, params)
177
+ end # def _get
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
+
189
+ end # class Product
190
+
191
+ end # module Bugzilla
@@ -0,0 +1,48 @@
1
+ # skeleton.rb
2
+ # Copyright (C) 2010-2014 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
+
21
+ module Bugzilla
22
+
23
+ =begin rdoc
24
+
25
+ === Bugzilla::Skeleton
26
+
27
+ =end
28
+
29
+ class Skeleton
30
+
31
+ def initialize(iface)
32
+ @iface = iface
33
+ end # def initialize
34
+
35
+ def method_missing(symbol, *args)
36
+ m = "_#{symbol}"
37
+ klass = self.class.to_s.sub(/\ABugzilla::/, '')
38
+ fm = "#{klass}.#{symbol}"
39
+ if self.respond_to?(m, true) then
40
+ __send__(m, fm, *args)
41
+ else
42
+ raise NoMethodError, sprintf("No such Bugzilla APIs: %s.%s", klass, symbol)
43
+ end
44
+ end # def method_missing
45
+
46
+ end # class Skeleton
47
+
48
+ end # module Bugzilla
@@ -0,0 +1,176 @@
1
+ # user.rb
2
+ # Copyright (C) 2010-2014 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 'yaml'
21
+ require 'bugzilla/api_tmpl'
22
+
23
+ module Bugzilla
24
+
25
+ =begin rdoc
26
+
27
+ === Bugzilla::User
28
+
29
+ Bugzilla::User class is to access the
30
+ Bugzilla::WebService::User API that allows you to create
31
+ User Accounts and log in/out using an existing account.
32
+
33
+ =end
34
+
35
+ class User < APITemplate
36
+
37
+ =begin rdoc
38
+
39
+ ==== Bugzilla::User#session(user, password)
40
+
41
+ Keeps the bugzilla session during doing something in the block.
42
+
43
+ =end
44
+
45
+ def session(user, password)
46
+ r = check_version('4.4.3')
47
+
48
+ if r[0] then
49
+ key = :token
50
+ fname = File.join(ENV['HOME'], '.ruby-bugzilla-token.yml')
51
+ else
52
+ key = :cookie
53
+ fname = File.join(ENV['HOME'], '.ruby-bugzilla-cookie.yml')
54
+ end
55
+ host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)
56
+ val = nil
57
+
58
+ if File.exist?(fname) && File.lstat(fname).mode & 0600 == 0600 then
59
+ conf = YAML.load(File.open(fname).read)
60
+ val = conf[host]
61
+ else
62
+ conf = {}
63
+ end
64
+ if !val.nil? then
65
+ if key == :token then
66
+ @iface.token = val
67
+ else
68
+ @iface.cookie = val
69
+ end
70
+ yield
71
+ elsif user.nil? || password.nil? then
72
+ yield
73
+ return
74
+ else
75
+ login({'login'=>user, 'password'=>password, 'remember'=>true})
76
+ yield
77
+ end
78
+ if key == :token then
79
+ conf[host] = @iface.token
80
+ else
81
+ conf[host] = @iface.cookie
82
+ end
83
+ File.open(fname, 'w') {|f| f.chmod(0600); f.write(conf.to_yaml)}
84
+
85
+ return key
86
+ end # def session
87
+
88
+ =begin rdoc
89
+
90
+ ==== Bugzilla::User#get_userinfo(params)
91
+
92
+ =end
93
+
94
+ def get_userinfo(user)
95
+ p = {}
96
+ ids = []
97
+ names = []
98
+
99
+ if user.kind_of?(Array) then
100
+ user.each do |u|
101
+ names << u if u.kind_of?(String)
102
+ id << u if u.kind_of?(Integer)
103
+ end
104
+ elsif user.kind_of?(String) then
105
+ names << user
106
+ elsif user.kind_of?(Integer) then
107
+ ids << user
108
+ else
109
+ raise ArgumentError, sprintf("Unknown type of arguments: %s", user.class)
110
+ end
111
+
112
+ result = get({'ids'=>ids, 'names'=>names})
113
+
114
+ result['users']
115
+ end # def get_userinfo
116
+
117
+ =begin rdoc
118
+
119
+ ==== Bugzilla::User#login(params)
120
+
121
+ Raw Bugzilla API to log into Bugzilla.
122
+
123
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/User.html
124
+
125
+ =end
126
+
127
+ =begin rdoc
128
+
129
+ ==== Bugzilla::User#logout
130
+
131
+ Raw Bugzilla API to log out the user.
132
+
133
+ See http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/User.html
134
+
135
+ =end
136
+
137
+ protected
138
+
139
+ def _login(cmd, *args)
140
+ raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash)
141
+
142
+ res = @iface.call(cmd,args[0])
143
+ unless res['token'].nil? then
144
+ @iface.token = res['token']
145
+ end
146
+
147
+ return res
148
+ end # def _login
149
+
150
+ def _logout(cmd, *args)
151
+ @iface.call(cmd)
152
+ end # def _logout
153
+
154
+ def __offer_account_by_email(cmd, *args)
155
+ # FIXME
156
+ end # def _offer_account_by_email
157
+
158
+ def __create(cmd, *args)
159
+ # FIXME
160
+ end # def _create
161
+
162
+ def __update(cmd, *args)
163
+ # FIXME
164
+ end # def _update
165
+
166
+ def _get(cmd, *args)
167
+ raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash)
168
+
169
+ requires_version(cmd, 3.4)
170
+ res = @iface.call(cmd, args[0])
171
+ # FIXME
172
+ end # def _get
173
+
174
+ end # class User
175
+
176
+ end # module Bugzilla
@@ -0,0 +1,31 @@
1
+ # version.rb
2
+ # Copyright (C) 2010-2015 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
+
21
+ =begin rdoc
22
+
23
+ == Bugzilla
24
+
25
+ =end
26
+
27
+ module Bugzilla
28
+
29
+ VERSION = "0.6.4.2"
30
+
31
+ end # module Bugzilla
@@ -0,0 +1,103 @@
1
+ # xmlrpc.rb
2
+ # Copyright (C) 2010-2014 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 'xmlrpc/client'
21
+
22
+ module Bugzilla
23
+
24
+ =begin rdoc
25
+
26
+ === Bugzilla::XMLRPC
27
+
28
+ =end
29
+
30
+ class XMLRPC
31
+
32
+ =begin rdoc
33
+
34
+ ==== Bugzilla::XMLRPC#new(host, port = 443, path = '/xmlrpc.cgi', proxy_host = nil, proxy_port = nil)
35
+
36
+ =end
37
+
38
+ def initialize(host, port = 443, path = '/xmlrpc.cgi', proxy_host = nil, proxy_port = nil, timeout = 60, http_basic_auth_user = nil, http_basic_auth_pass = nil)
39
+ path ||= '/xmlrpc.cgi'
40
+ use_ssl = port == 443 ? true : false
41
+ @xmlrpc = ::XMLRPC::Client.new(host, path, port, proxy_host, proxy_port, http_basic_auth_user, http_basic_auth_pass, use_ssl, timeout)
42
+
43
+ # workaround for https://bugs.ruby-lang.org/issues/8182
44
+ @xmlrpc.http_header_extra = {'accept-encoding' => 'identity'}
45
+ end # def initialize
46
+
47
+ =begin rdoc
48
+
49
+ ==== Bugzilla::XMLRPC#call(cmd, params, user = nil, password = nil)
50
+
51
+ =end
52
+
53
+ def call(cmd, params = {}, user = nil, password = nil)
54
+ params = {} if params.nil?
55
+ params['Bugzilla_login'] = user unless user.nil? || password.nil?
56
+ params['Bugzilla_password'] = password unless user.nil? || password.nil?
57
+ params['Bugzilla_token'] = @token unless @token.nil?
58
+ @xmlrpc.call(cmd, params)
59
+ end # def call
60
+
61
+ =begin rdoc
62
+
63
+ ==== Bugzilla::XMLRPC#cookie
64
+
65
+ =end
66
+
67
+ def cookie
68
+ @xmlrpc.cookie
69
+ end # def cookie
70
+
71
+ =begin rdoc
72
+
73
+ ==== Bugzilla::XMLRPC#cookie=(val)
74
+
75
+ =end
76
+
77
+ def cookie=(val)
78
+ @xmlrpc.cookie = val
79
+ end # def cookie=
80
+
81
+ =begin rdoc
82
+
83
+ ==== Bugzilla::XMLRPC#token
84
+
85
+ =end
86
+
87
+ def token
88
+ @token
89
+ end # def token
90
+
91
+ =begin rdoc
92
+
93
+ ==== Bugzilla::XMLRPC#token=(val)
94
+
95
+ =end
96
+
97
+ def token=(val)
98
+ @token = val
99
+ end # def token=
100
+
101
+ end # class XMLRPC
102
+
103
+ end # module Bugzilla
data/lib/bugzilla.rb ADDED
@@ -0,0 +1,24 @@
1
+ # bugzilla.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/bug'
21
+ require 'bugzilla/plugin'
22
+ require 'bugzilla/product'
23
+ require 'bugzilla/user'
24
+ require 'bugzilla/xmlrpc'
@@ -0,0 +1,55 @@
1
+ # nvbugzilla.rb
2
+ # Copyright (C) 2014 Novell, Inc.
3
+ #
4
+ # Authors:
5
+ # Victor Pereira <vpereira@suse.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 'rubygems'
21
+
22
+ #begin
23
+ # gem 'ruby-bugzilla'
24
+ #rescue Gem::LoadError
25
+ # require File.join(File.dirname(__FILE__), "..", "bugzilla.rb")
26
+ #end
27
+
28
+ module Bugzilla
29
+
30
+ module Plugin
31
+
32
+ class Novell < ::Bugzilla::Plugin::Template
33
+
34
+ def initialize
35
+ super
36
+ @hostname = "bugzilla.novell.com"
37
+ end # def initialize
38
+
39
+ def parserhook(*args)
40
+ super
41
+ end # def parserhook
42
+
43
+ def prehook(*args)
44
+ super
45
+ end # def prehook
46
+
47
+ def posthook(*args)
48
+ super
49
+ end # def posthook
50
+
51
+ end # class Novell
52
+
53
+ end # module Plugin
54
+
55
+ end # module Bugzilla