ruby-bugzilla 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +510 -0
- data/README.rdoc +18 -0
- data/Rakefile +53 -0
- data/bin/bzconsole +704 -0
- data/lib/bugzilla.rb +787 -0
- data/lib/ruby-bugzilla/rhbugzilla.rb +223 -0
- data/spec/ruby-bugzilla_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +89 -0
@@ -0,0 +1,223 @@
|
|
1
|
+
# rhbugzilla.rb
|
2
|
+
# Copyright (C) 2010 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 2 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 GNU
|
15
|
+
# Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public
|
18
|
+
# License along with this library; if not, write to the
|
19
|
+
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
20
|
+
# Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
|
24
|
+
#begin
|
25
|
+
# gem 'ruby-bugzilla'
|
26
|
+
#rescue Gem::LoadError
|
27
|
+
# require File.join(File.dirname(__FILE__), "..", "bugzilla.rb")
|
28
|
+
#end
|
29
|
+
|
30
|
+
module Bugzilla
|
31
|
+
|
32
|
+
module Plugin
|
33
|
+
|
34
|
+
class RedHat < ::Bugzilla::Plugin::Template
|
35
|
+
|
36
|
+
def initialize
|
37
|
+
super
|
38
|
+
|
39
|
+
@hostname = "bugzilla.redhat.com"
|
40
|
+
end # def initialize
|
41
|
+
|
42
|
+
def parserhook(*args)
|
43
|
+
parser, argv, opts, *etc = args
|
44
|
+
parser.separator ""
|
45
|
+
parser.separator "RH Bugzilla specific options:"
|
46
|
+
parser.on('--cc=EMAILS', 'filter out the result by Cc in bugs') {|v| opts[:query][:cc] ||= []; opts[:query][:cc].push(*v.split(','))}
|
47
|
+
parser.on('--version=VERSION', 'filter out the result by the version in bugs') {|v| opts[:query][:version] ||= []; opts[:query][:version].push(*v.split(','))}
|
48
|
+
end # def parserhook
|
49
|
+
|
50
|
+
def prehook(*args)
|
51
|
+
cmd, opts, *etc = args
|
52
|
+
case cmd
|
53
|
+
when :search
|
54
|
+
extra_field = 0
|
55
|
+
|
56
|
+
if opts.include?(:status) then
|
57
|
+
opts[:bug_status] = opts[:status]
|
58
|
+
opts.delete(:status)
|
59
|
+
end
|
60
|
+
if opts.include?(:id) then
|
61
|
+
opts[:bug_id] = opts[:id]
|
62
|
+
opts.delete(:id)
|
63
|
+
end
|
64
|
+
if opts.include?(:severity)
|
65
|
+
opts[:bug_severity] = opts[:severity]
|
66
|
+
end
|
67
|
+
if opts.include?(:summary) then
|
68
|
+
opts[:short_desc] = opts[:summary]
|
69
|
+
opts.delete(:summary)
|
70
|
+
end
|
71
|
+
if opts.include?(:cc) then
|
72
|
+
i = 1
|
73
|
+
opts[:cc].each do |e|
|
74
|
+
opts[eval(":emailcc#{i}")] = 1
|
75
|
+
opts[eval(":emailtype#{i}")] = :substring
|
76
|
+
opts[eval(":email#{i}")] = e
|
77
|
+
end
|
78
|
+
opts.delete(:cc)
|
79
|
+
end
|
80
|
+
if opts.include?(:creation_time) then
|
81
|
+
opts[sprintf("field0-%d-0", extra_field)] = :creation_ts
|
82
|
+
opts[sprintf("type0-%d-0", extra_field)] = :greaterthan
|
83
|
+
opts[sprintf("value0-%d-0", extra_field)] = opts[:creation_time]
|
84
|
+
opts.delete(:creation_time)
|
85
|
+
end
|
86
|
+
when :metrics
|
87
|
+
metricsopts = etc[0]
|
88
|
+
extra_field = 0
|
89
|
+
|
90
|
+
if opts.include?(:status) then
|
91
|
+
opts[:bug_status] = opts[:status]
|
92
|
+
opts.delete(:status)
|
93
|
+
end
|
94
|
+
if opts.include?(:id) then
|
95
|
+
opts[:bug_id] = opts[:id]
|
96
|
+
opts.delete(:id)
|
97
|
+
end
|
98
|
+
if opts.include?(:severity)
|
99
|
+
opts[:bug_severity] = opts[:severity]
|
100
|
+
end
|
101
|
+
if opts.include?(:summary) then
|
102
|
+
opts[:short_desc] = opts[:summary]
|
103
|
+
opts.delete(:summary)
|
104
|
+
end
|
105
|
+
if opts.include?(:cc) then
|
106
|
+
i = 1
|
107
|
+
opts[:cc].each do |e|
|
108
|
+
opts[eval(":emailcc#{i}")] = 1
|
109
|
+
opts[eval(":emailtype#{i}")] = :substring
|
110
|
+
opts[eval(":email#{i}")] = e
|
111
|
+
end
|
112
|
+
opts.delete(:cc)
|
113
|
+
end
|
114
|
+
|
115
|
+
if opts.include?(:creation_time) then
|
116
|
+
if opts[:creation_time].kind_of?(Array) then
|
117
|
+
opts[sprintf("field0-%d-0", extra_field)] = :creation_ts
|
118
|
+
opts[sprintf("type0-%d-0", extra_field)] = :greaterthan
|
119
|
+
opts[sprintf("value0-%d-0", extra_field)] = opts[:creation_time][0]
|
120
|
+
extra_field += 1
|
121
|
+
opts[sprintf("field0-%d-0", extra_field)] = :creation_ts
|
122
|
+
opts[sprintf("type0-%d-0", extra_field)] = :lessthan
|
123
|
+
opts[sprintf("value0-%d-0", extra_field)] = opts[:creation_time][1]
|
124
|
+
extra_field += 1
|
125
|
+
else
|
126
|
+
opts[sprintf("field0-%d-0", extra_field)] = :creation_ts
|
127
|
+
opts[sprintf("type0-%d-0", extra_field)] = :greaterthan
|
128
|
+
opts[sprintf("value0-%d-0", extra_field)] = opts[:creation_time]
|
129
|
+
extra_field += 1
|
130
|
+
end
|
131
|
+
opts.delete(:creation_time)
|
132
|
+
end
|
133
|
+
if opts.include?(:last_change_time) then
|
134
|
+
if opts[:last_change_time].kind_of?(Array) then
|
135
|
+
opts[:chfieldfrom] = opts[:last_change_time][0]
|
136
|
+
opts[:chfieldto] = opts[:last_change_time][1]
|
137
|
+
if opts[:bug_status] == 'CLOSED' then
|
138
|
+
opts[sprintf("field0-%d-0", extra_field)] = :bug_status
|
139
|
+
opts[sprintf("type0-%d-0", extra_field)] = :changedto
|
140
|
+
opts[sprintf("value0-%d-0", extra_field)] = opts[:bug_status]
|
141
|
+
extra_field += 1
|
142
|
+
end
|
143
|
+
end
|
144
|
+
opts.delete(:last_change_time)
|
145
|
+
end
|
146
|
+
if opts.include?(:metrics_closed_after) then
|
147
|
+
opts[sprintf("field0-%d-0", extra_field)] = :bug_status
|
148
|
+
opts[sprintf("type0-%d-0", extra_field)] = :changedafter
|
149
|
+
opts[sprintf("value0-%d-0", extra_field)] = opts[:metrics_closed_after]
|
150
|
+
extra_field += 1
|
151
|
+
opts.delete(:metrics_closed_after)
|
152
|
+
end
|
153
|
+
if opts.include?(:metrics_not_closed) then
|
154
|
+
opts[sprintf("field0-%d-0", extra_field)] = :bug_status
|
155
|
+
opts[sprintf("type0-%d-0", extra_field)] = :notequals
|
156
|
+
opts[sprintf("value0-%d-0", extra_field)] = 'CLOSED'
|
157
|
+
extra_field += 1
|
158
|
+
opts[sprintf("field0-%d-0", extra_field)] = :creation_ts
|
159
|
+
opts[sprintf("type0-%d-0", extra_field)] = :lessthan
|
160
|
+
opts[sprintf("value0-%d-0", extra_field)] = opts[:metrics_not_closed]
|
161
|
+
extra_field += 1
|
162
|
+
opts.delete(:metrics_not_closed)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
end
|
166
|
+
end # def prehook
|
167
|
+
|
168
|
+
def posthook(*args)
|
169
|
+
cmd, opts, *etc = args
|
170
|
+
case cmd
|
171
|
+
when :search
|
172
|
+
if opts.include?('bugs') then
|
173
|
+
opts['bugs'].each do |bug|
|
174
|
+
if bug.include?('bug_status') then
|
175
|
+
bug['status'] = bug['bug_status']
|
176
|
+
bug.delete('bug_status')
|
177
|
+
end
|
178
|
+
if bug.include?('bug_id') then
|
179
|
+
bug['id'] = bug['bug_id']
|
180
|
+
bug.delete('bug_id')
|
181
|
+
end
|
182
|
+
if bug.include?('bug_severity') then
|
183
|
+
bug['severity'] = bug['bug_severity']
|
184
|
+
bug.delete('bug_severity')
|
185
|
+
end
|
186
|
+
if bug.include?('short_desc') then
|
187
|
+
bug['summary'] = bug['short_desc']
|
188
|
+
bug.delete('short_desc')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
when :metrics
|
193
|
+
metricsopts = etc[0]
|
194
|
+
|
195
|
+
if opts.include?('bugs') then
|
196
|
+
opts['bugs'].each do |bug|
|
197
|
+
if bug.include?('bug_status') then
|
198
|
+
bug['status'] = bug['bug_status']
|
199
|
+
bug.delete('bug_status')
|
200
|
+
end
|
201
|
+
if bug.include?('bug_id') then
|
202
|
+
bug['id'] = bug['bug_id']
|
203
|
+
bug.delete('bug_id')
|
204
|
+
end
|
205
|
+
if bug.include?('bug_severity') then
|
206
|
+
bug['severity'] = bug['bug_severity']
|
207
|
+
bug.delete('bug_severity')
|
208
|
+
end
|
209
|
+
if bug.include?('short_desc') then
|
210
|
+
bug['summary'] = bug['short_desc']
|
211
|
+
bug.delete('short_desc')
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
else
|
216
|
+
end
|
217
|
+
end # def posthook
|
218
|
+
|
219
|
+
end # class RedHat
|
220
|
+
|
221
|
+
end # module Plugin
|
222
|
+
|
223
|
+
end # module Bugzilla
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-bugzilla
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Akira TAGOH
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-19 00:00:00 +09:00
|
18
|
+
default_executable: bzconsole
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 13
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 2
|
32
|
+
- 9
|
33
|
+
version: 1.2.9
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
description: This aims to provide similar features to access to Bugzilla through WebService APIs in Ruby.
|
37
|
+
email: akira@tagoh.org
|
38
|
+
executables:
|
39
|
+
- bzconsole
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- COPYING
|
46
|
+
- README.rdoc
|
47
|
+
- Rakefile
|
48
|
+
- bin/bzconsole
|
49
|
+
- lib/bugzilla.rb
|
50
|
+
- lib/ruby-bugzilla/rhbugzilla.rb
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
- spec/ruby-bugzilla_spec.rb
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/tagoh/ruby-bugzilla
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- --charset=UTF-8
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.7
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Ruby binding for Bugzilla WebService APIs
|
87
|
+
test_files:
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/ruby-bugzilla_spec.rb
|