ruby-bugzilla 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/bzconsole +82 -35
- data/lib/bugzilla.rb +5 -4
- metadata +4 -5
data/bin/bzconsole
CHANGED
@@ -26,6 +26,7 @@ require 'yaml'
|
|
26
26
|
require 'rubygems'
|
27
27
|
require 'pp'
|
28
28
|
require 'gruff'
|
29
|
+
require 'uri'
|
29
30
|
|
30
31
|
|
31
32
|
$KCODE = 'u'
|
@@ -101,7 +102,7 @@ module BzConsole
|
|
101
102
|
template = {
|
102
103
|
"rhbz"=>{
|
103
104
|
:Name=>"Red Hat Bugzilla",
|
104
|
-
:URL=>"https://bugzilla.redhat.com
|
105
|
+
:URL=>"https://bugzilla.redhat.com",
|
105
106
|
:User=>"account@example.com",
|
106
107
|
:Password=>"blahblahblah",
|
107
108
|
:ProductAliases=>{
|
@@ -114,19 +115,19 @@ module BzConsole
|
|
114
115
|
},
|
115
116
|
"gnbz"=>{
|
116
117
|
:Name=>"GNOME Bugzilla",
|
117
|
-
:URL=>"https://bugzilla.gnome.org
|
118
|
+
:URL=>"https://bugzilla.gnome.org",
|
118
119
|
:User=>"account@example.com",
|
119
120
|
:Password=>"blahblahblah",
|
120
121
|
},
|
121
122
|
"fdobz"=>{
|
122
123
|
:Name=>"FreeDesktop Bugzilla",
|
123
|
-
:URL=>"https://bugs.freedesktop.org
|
124
|
+
:URL=>"https://bugs.freedesktop.org",
|
124
125
|
:User=>"account@example.com",
|
125
126
|
:Password=>"blahblahblah",
|
126
127
|
},
|
127
128
|
"mzbz"=>{
|
128
129
|
:Name=>"Mozilla Bugzilla",
|
129
|
-
:URL=>"https://bugzilla.mozilla.org
|
130
|
+
:URL=>"https://bugzilla.mozilla.org",
|
130
131
|
:User=>"account@example.com",
|
131
132
|
:Password=>"blahblahblah",
|
132
133
|
}
|
@@ -225,14 +226,16 @@ module BzConsole
|
|
225
226
|
end
|
226
227
|
|
227
228
|
info = conf[prefix]
|
228
|
-
|
229
|
-
|
229
|
+
uri = URI.parse(info[:URL])
|
230
|
+
host = uri.host
|
231
|
+
port = uri.port
|
232
|
+
path = uri.path.empty? ? nil : uri.path
|
230
233
|
login = opts[:command][:anonymous] == true ? nil : info[:User]
|
231
234
|
pass = opts[:command][:anonymous] == true ? nil : info[:Password]
|
232
235
|
|
233
236
|
@plugin.run(:pre, host, :getbug, opts)
|
234
237
|
|
235
|
-
xmlrpc = Bugzilla::XMLRPC.new(host, port)
|
238
|
+
xmlrpc = Bugzilla::XMLRPC.new(host, port, path)
|
236
239
|
user = Bugzilla::User.new(xmlrpc)
|
237
240
|
user.session(login, pass) do
|
238
241
|
bug = Bugzilla::Bug.new(xmlrpc)
|
@@ -335,14 +338,16 @@ module BzConsole
|
|
335
338
|
end
|
336
339
|
|
337
340
|
info = conf[prefix]
|
338
|
-
|
339
|
-
|
341
|
+
uri = URI.parse(info[:URL])
|
342
|
+
host = uri.host
|
343
|
+
port = uri.port
|
344
|
+
path = uri.path.empty? ? nil : uri.path
|
340
345
|
login = opts[:command][:anonymous] == true ? nil : info[:User]
|
341
346
|
pass = opts[:command][:anonymous] == true ? nil : info[:Password]
|
342
347
|
|
343
348
|
@plugin.run(:pre, host, :search, opts[:command][:query])
|
344
349
|
|
345
|
-
xmlrpc = Bugzilla::XMLRPC.new(host, port)
|
350
|
+
xmlrpc = Bugzilla::XMLRPC.new(host, port, path)
|
346
351
|
user = Bugzilla::User.new(xmlrpc)
|
347
352
|
user.session(login, pass) do
|
348
353
|
bug = Bugzilla::Bug.new(xmlrpc)
|
@@ -378,6 +383,8 @@ module BzConsole
|
|
378
383
|
parser.banner = sprintf("Usage: %s [global options] show [command options] <prefix> ...", File.basename(__FILE__))
|
379
384
|
parser.separator ""
|
380
385
|
parser.separator "Command options:"
|
386
|
+
parser.on('-f', '--field', 'Displays available field informations') {|v| opts[:show][:mode] = :field}
|
387
|
+
parser.on('--field-name=NAME', 'Displays NAME field information') {|v| opts[:show][:field] = v}
|
381
388
|
parser.on('-p', '--product', 'Displays available product names') {|v| opts[:show][:mode] = :product}
|
382
389
|
parser.on('-c', '--component', 'Displays available component names (default)') {|v| opts[:show][:mode] = :component}
|
383
390
|
parser.on('--anonymous', 'Access to Bugzilla anonymously') {opts[:anonymous] = true}
|
@@ -407,28 +414,40 @@ module BzConsole
|
|
407
414
|
end
|
408
415
|
|
409
416
|
info = conf[prefix]
|
410
|
-
|
411
|
-
|
417
|
+
uri = URI.parse(info[:URL])
|
418
|
+
host = uri.host
|
419
|
+
port = uri.port
|
420
|
+
path = uri.path.empty? ? nil : uri.path
|
412
421
|
login = opts[:command][:anonymous] == true ? nil : info[:User]
|
413
422
|
pass = opts[:command][:anonymous] == true ? nil : info[:Password]
|
414
423
|
|
415
424
|
@plugin.run(:pre, host, :show, opts)
|
416
425
|
|
417
|
-
xmlrpc = Bugzilla::XMLRPC.new(host, port)
|
426
|
+
xmlrpc = Bugzilla::XMLRPC.new(host, port, path)
|
418
427
|
user = Bugzilla::User.new(xmlrpc)
|
419
428
|
user.session(login, pass) do
|
420
|
-
|
429
|
+
if opts[:command][:show][:mode] == :field then
|
430
|
+
bug = Bugzilla::Bug.new(xmlrpc)
|
421
431
|
|
422
|
-
|
432
|
+
result = bug.fields(opts[:command][:show][:field])
|
423
433
|
|
424
|
-
|
434
|
+
@plugin.run(:post, host, :show, result)
|
425
435
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
436
|
+
pp result
|
437
|
+
else
|
438
|
+
product = Bugzilla::Product.new(xmlrpc)
|
439
|
+
|
440
|
+
result = product.selectable_products
|
441
|
+
|
442
|
+
@plugin.run(:post, host, :show, result)
|
443
|
+
|
444
|
+
products = result.keys.sort
|
445
|
+
products.each do |p|
|
446
|
+
if opts[:command][:show][:mode] == :product then
|
447
|
+
yield p
|
448
|
+
elsif opts[:command][:show][:mode] == :component then
|
449
|
+
yield p, result[p][0].sort
|
450
|
+
end
|
432
451
|
end
|
433
452
|
end
|
434
453
|
end
|
@@ -449,6 +468,7 @@ module BzConsole
|
|
449
468
|
opts[:metrics] = {}
|
450
469
|
opts[:query] = {}
|
451
470
|
opts[:metrics][:output] = 'bz-metrics.png'
|
471
|
+
opts[:metrics][:x_coordinate] = :monthly
|
452
472
|
|
453
473
|
parser.banner = sprintf("Usage: %s [global options] metrics [command options] <prefix> ...", File.basename(__FILE__))
|
454
474
|
parser.separator ""
|
@@ -474,6 +494,8 @@ module BzConsole
|
|
474
494
|
parser.on('--end-date=DATE', 'generate the graph until the end of month of DATE.') {|v| x = Time.parse(v); opts[:metrics][:end_date] = Time.utc(x.year, x.month + 1, 1, 0, 0, 0) - 1}
|
475
495
|
parser.on('-o', '--output=FILE', 'generate the graph to FILE') {|v| opts[:metrics][:output] = v}
|
476
496
|
parser.on('--anonymous', 'access to Bugzilla anonymously') {|v| opts[:anonymous] = true}
|
497
|
+
parser.on('--weekly', 'genereate the graph with weekly X-coordinate') {|v| opts[:metrics][:x_coordinate] = :weekly}
|
498
|
+
parser.on('--monthly', 'genereate the graph with monthly X-coordinate (default)') {|v| opts[:metrics][:x_coordinate] = :monthly}
|
477
499
|
|
478
500
|
super
|
479
501
|
end # def parse
|
@@ -488,16 +510,23 @@ module BzConsole
|
|
488
510
|
'CLOSED'=>[],
|
489
511
|
'OPEN'=>[]
|
490
512
|
}
|
513
|
+
last_label = nil
|
491
514
|
real_do(argv, opts) do |t, new, assigned, modified, on_qa, closed, open|
|
492
515
|
printf("%s, new: %d, assigned: %d, modified %d, on_qa %d, closed %d / open %d\n",
|
493
|
-
t.strftime("%Y-%m"), new, assigned, modified, on_qa, closed, open)
|
516
|
+
opts[:command][:metrics][:x_coordinate] == :weekly ? sprintf("week %d", Date.new(t.year, t.month, t.day).cweek) : t.strftime("%Y-%m"), new, assigned, modified, on_qa, closed, open)
|
494
517
|
data['NEW'] << new
|
495
518
|
data['ASSIGNED'] << assigned
|
496
519
|
data['MODIFIED'] << modified
|
497
520
|
data['ON_QA'] << on_qa
|
498
521
|
data['CLOSED'] << closed
|
499
522
|
data['OPEN'] << open
|
500
|
-
|
523
|
+
label = t.strftime("%Y/%m")
|
524
|
+
if last_label != label then
|
525
|
+
data[:label] << label
|
526
|
+
last_label = label
|
527
|
+
else
|
528
|
+
data[:label] << nil
|
529
|
+
end
|
501
530
|
end
|
502
531
|
|
503
532
|
timeline = data[:label]
|
@@ -505,7 +534,7 @@ module BzConsole
|
|
505
534
|
def timeline.to_hash
|
506
535
|
ret = {}
|
507
536
|
(0..self.length-1).each do |i|
|
508
|
-
ret[i] = self[i]
|
537
|
+
ret[i] = self[i] unless self[i].nil?
|
509
538
|
end
|
510
539
|
ret
|
511
540
|
end # def timeline.to_hash
|
@@ -549,12 +578,14 @@ module BzConsole
|
|
549
578
|
end
|
550
579
|
|
551
580
|
info = conf[prefix]
|
552
|
-
|
553
|
-
|
581
|
+
uri = URI.parse(info[:URL])
|
582
|
+
host = uri.host
|
583
|
+
port = uri.port
|
584
|
+
path = uri.path.empty? ? nil : uri.path
|
554
585
|
login = opts[:command][:anonymous] == true ? nil : info[:User]
|
555
586
|
pass = opts[:command][:anonymous] == true ? nil : info[:Password]
|
556
587
|
|
557
|
-
xmlrpc = Bugzilla::XMLRPC.new(host, port)
|
588
|
+
xmlrpc = Bugzilla::XMLRPC.new(host, port, path)
|
558
589
|
user = Bugzilla::User.new(xmlrpc)
|
559
590
|
user.session(login, pass) do
|
560
591
|
bug = Bugzilla::Bug.new(xmlrpc)
|
@@ -563,13 +594,22 @@ module BzConsole
|
|
563
594
|
|
564
595
|
ts = opts[:command][:metrics][:begin_date] || Time.utc(Time.new.year, 1, 1)
|
565
596
|
te = opts[:command][:metrics][:end_date] || Time.utc(Time.new.year+1, 1, 1) - 1
|
597
|
+
if opts[:command][:metrics][:x_coordinate] == :weekly then
|
598
|
+
# align to the week
|
599
|
+
d = Date.new(ts.year, ts.month, ts.day)
|
600
|
+
ds = Date.commercial(d.year, d.cweek, 1)
|
601
|
+
d = Date.new(te.year, te.month, te.day)
|
602
|
+
de = Date.commercial(d.year, d.cweek, 7)
|
603
|
+
ts = Time.utc(ds.year, ds.month, ds.day)
|
604
|
+
te = Time.utc(de.year, de.month, de.day)
|
605
|
+
end
|
566
606
|
|
567
607
|
searchopts = opts[:command][:query].clone
|
568
608
|
|
569
609
|
@plugin.run(:pre, host, :metrics, searchopts, opts[:metrics])
|
570
610
|
|
571
611
|
if searchopts == opts[:command][:query] then
|
572
|
-
raise NoMethodError, "No method to deal with the query
|
612
|
+
raise NoMethodError, "No method to deal with the query"
|
573
613
|
end
|
574
614
|
|
575
615
|
while ts < te do
|
@@ -577,7 +617,14 @@ module BzConsole
|
|
577
617
|
|
578
618
|
# don't rely on the status to deal with NEW bugs.
|
579
619
|
# unable to estimate the case bugs closed quickly
|
580
|
-
|
620
|
+
if opts[:command][:metrics][:x_coordinate] == :weekly then
|
621
|
+
d = Date.new(ts.year, ts.month, ts.day)
|
622
|
+
de = Date.commercial(d.year, d.cweek, 7)
|
623
|
+
drange = [ts, Time.utc(de.year, de.month, de.day, 23, 59, 59)]
|
624
|
+
else
|
625
|
+
drange = [ts, Time.utc(ts.year, ts.month + 1, 1) - 1]
|
626
|
+
end
|
627
|
+
searchopts[:creation_time] = drange
|
581
628
|
|
582
629
|
@plugin.run(:pre, host, :metrics, searchopts)
|
583
630
|
|
@@ -590,7 +637,7 @@ module BzConsole
|
|
590
637
|
# for open bugs
|
591
638
|
# what we are interested in here would be how many bugs still keeps open.
|
592
639
|
searchopts = opts[:command][:query].clone
|
593
|
-
searchopts[:last_change_time] =
|
640
|
+
searchopts[:last_change_time] = drange
|
594
641
|
searchopts[:status] = '__open__'
|
595
642
|
|
596
643
|
@plugin.run(:pre, host, :metrics, searchopts)
|
@@ -608,7 +655,7 @@ module BzConsole
|
|
608
655
|
# what we are interested in here would be how much bugs are
|
609
656
|
# actually closed, but not how many closed bugs one worked on.
|
610
657
|
searchopts = opts[:command][:query].clone
|
611
|
-
searchopts[:last_change_time] =
|
658
|
+
searchopts[:last_change_time] = drange
|
612
659
|
searchopts[:status] = 'CLOSED'
|
613
660
|
|
614
661
|
@plugin.run(:pre, host, :metrics, searchopts)
|
@@ -622,7 +669,7 @@ module BzConsole
|
|
622
669
|
# obtain the information for open bugs that closed now
|
623
670
|
searchopts = opts[:command][:query].clone
|
624
671
|
searchopts[:status] = 'CLOSED'
|
625
|
-
searchopts[:metrics_closed_after] =
|
672
|
+
searchopts[:metrics_closed_after] = drange[1] + 1
|
626
673
|
|
627
674
|
@plugin.run(:pre, host, :metrics, searchopts)
|
628
675
|
|
@@ -634,7 +681,7 @@ module BzConsole
|
|
634
681
|
|
635
682
|
# obtain the information for open bugs
|
636
683
|
searchopts = opts[:command][:query].clone
|
637
|
-
searchopts[:metrics_not_closed] =
|
684
|
+
searchopts[:metrics_not_closed] = drange[1]
|
638
685
|
|
639
686
|
@plugin.run(:pre, host, :metrics, searchopts)
|
640
687
|
|
@@ -646,7 +693,7 @@ module BzConsole
|
|
646
693
|
|
647
694
|
yield ts, new, assigned, modified, on_qa, closed, open_bugs
|
648
695
|
|
649
|
-
ts =
|
696
|
+
ts = drange[1] + 1
|
650
697
|
end
|
651
698
|
end
|
652
699
|
end
|
data/lib/bugzilla.rb
CHANGED
@@ -30,7 +30,7 @@ require 'xmlrpc/client'
|
|
30
30
|
|
31
31
|
module Bugzilla
|
32
32
|
|
33
|
-
VERSION = "0.
|
33
|
+
VERSION = "0.2"
|
34
34
|
|
35
35
|
=begin rdoc
|
36
36
|
|
@@ -99,13 +99,14 @@ module Bugzilla
|
|
99
99
|
|
100
100
|
=begin rdoc
|
101
101
|
|
102
|
-
==== Bugzilla::XMLRPC#new(
|
102
|
+
==== Bugzilla::XMLRPC#new(host, port = 443, path = '/xmlrpc.cgi')
|
103
103
|
|
104
104
|
=end
|
105
105
|
|
106
|
-
def initialize(
|
106
|
+
def initialize(host, port = 443, path = '/xmlrpc.cgi')
|
107
|
+
path ||= '/xmlrpc.cgi'
|
107
108
|
use_ssl = port == 443 ? true : false
|
108
|
-
@xmlrpc = ::XMLRPC::Client.new(
|
109
|
+
@xmlrpc = ::XMLRPC::Client.new(host, path, port, nil, nil, nil, nil, use_ssl, 60)
|
109
110
|
end # def initialize
|
110
111
|
|
111
112
|
=begin rdoc
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-bugzilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.1.1
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Akira TAGOH
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-26 00:00:00 +09:00
|
19
18
|
default_executable: bzconsole
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|