rubyzilla 0.1.1
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/lib/rubyzilla.rb +48 -0
- data/lib/rubyzilla/bug.rb +85 -0
- data/lib/rubyzilla/product.rb +47 -0
- data/rubyzilla.gemspec +13 -0
- metadata +70 -0
data/lib/rubyzilla.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'xmlrpc/client'
|
2
|
+
|
3
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'rubyzilla/*.rb')).each {|f| require f}
|
4
|
+
|
5
|
+
|
6
|
+
module Rubyzilla
|
7
|
+
class Bugzilla
|
8
|
+
|
9
|
+
def initialize server
|
10
|
+
@@server = XMLRPC::Client.new2(server)
|
11
|
+
@@logged_in = false
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.server
|
15
|
+
@@server
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.logged_in?
|
19
|
+
@@logged_in
|
20
|
+
end
|
21
|
+
|
22
|
+
def login login, password
|
23
|
+
result = @@server.call("User.login", {
|
24
|
+
:login => login.chomp, :password => password.chomp,
|
25
|
+
:remember => 1
|
26
|
+
})
|
27
|
+
|
28
|
+
@id = result['id']
|
29
|
+
|
30
|
+
# Workaround for Bugzilla's broken cookies.
|
31
|
+
if @@server.cookie =~ /Bugzilla_logincookie=([^;]+)/
|
32
|
+
@@server.cookie =
|
33
|
+
"Bugzilla_login=#{@id}; Bugzilla_logincookie=#{$1}"
|
34
|
+
@@logged_in = true
|
35
|
+
end
|
36
|
+
|
37
|
+
return @@logged_in
|
38
|
+
end
|
39
|
+
|
40
|
+
def bug id=nil
|
41
|
+
return Bug.new(id)
|
42
|
+
end
|
43
|
+
|
44
|
+
def product id=nil
|
45
|
+
return Product.new(id)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Rubyzilla
|
2
|
+
class Bug
|
3
|
+
attr_accessor :id
|
4
|
+
|
5
|
+
# Required create parameters
|
6
|
+
attr_accessor :product_id, :component_id, :summary, :version
|
7
|
+
attr_accessor :component # String value component for creation
|
8
|
+
@product # String value component for creation
|
9
|
+
|
10
|
+
# Defaulted create parameters
|
11
|
+
attr_accessor :op_sys, :platform, :priority, :severity
|
12
|
+
attr_accessor :description
|
13
|
+
|
14
|
+
# Optional create parameters
|
15
|
+
attr_accessor :alias, :assigned_to, :cc, :qa_contact, :status
|
16
|
+
attr_accessor :target_milestone
|
17
|
+
|
18
|
+
def initialize id=nil
|
19
|
+
unless id.nil?
|
20
|
+
result = Bugzilla.server.call("Bug.get_bugs", {:ids => [id]})
|
21
|
+
|
22
|
+
@product_id = result["bugs"][0]["internals"]["product_id"]
|
23
|
+
@product = product
|
24
|
+
@id = result["bugs"][0]["id"]
|
25
|
+
@component_id = result["bugs"][0]["internals"]["component_id"]
|
26
|
+
@summary = result["bugs"][0]["summary"]
|
27
|
+
@version = result["bugs"][0]["internals"]["version"]
|
28
|
+
@op_sys = result["bugs"][0]["internals"]["op_sys"]
|
29
|
+
@platform = result["bugs"][0]["internals"]["rep_platform"]
|
30
|
+
@priority = result["bugs"][0]["internals"]["priority"]
|
31
|
+
@description = result["bugs"][0]["internals"]["short_desc"]
|
32
|
+
@alias = result["bugs"][0]["alias"]
|
33
|
+
@qa_contact = result["bugs"][0]["internals"]["qa_contact"]
|
34
|
+
@status = result["bugs"][0]["internals"]["status_whiteboard"]
|
35
|
+
@target_milestone = result["bugs"][0]["internals"]["target_milestone"]
|
36
|
+
@severity = result["bugs"][0]["internals"]["bug_severity"]
|
37
|
+
end
|
38
|
+
return self
|
39
|
+
end
|
40
|
+
|
41
|
+
def product
|
42
|
+
Product.new(@product_id)
|
43
|
+
end
|
44
|
+
|
45
|
+
def product= _product
|
46
|
+
@product_id = _product.id
|
47
|
+
@product = _product.name
|
48
|
+
end
|
49
|
+
|
50
|
+
def create
|
51
|
+
if Bugzilla.logged_in?
|
52
|
+
parameters = {
|
53
|
+
:product => @product,
|
54
|
+
:component => @component,
|
55
|
+
:summary => @summary || "",
|
56
|
+
:version => @version || "unspecified",
|
57
|
+
:op_sys => @op_sys || "Windows",
|
58
|
+
:platform => @platform || "PC",
|
59
|
+
:priority => @priority || "P5",
|
60
|
+
}
|
61
|
+
|
62
|
+
parameters.merge!({:severity => @severity}) if @severity
|
63
|
+
parameters.merge!({:description => @description}) if @description
|
64
|
+
parameters.merge!({:alias => @alias}) if @alias && @alias != ""
|
65
|
+
parameters.merge!({:assigned_to => @assigned_to}) if @assigned_to
|
66
|
+
parameters.merge!({:cc => @cc}) if @cc
|
67
|
+
parameters.merge!({:qa_contact => @qa_contact}) if @qa_contact
|
68
|
+
parameters.merge!({:status => @status}) if @status
|
69
|
+
parameters.merge!({:target_milestone => @target_milestone}) if
|
70
|
+
@target_milestone
|
71
|
+
|
72
|
+
result = Bugzilla.server.call("Bug.create", parameters)
|
73
|
+
|
74
|
+
@id = result["id"].to_i
|
75
|
+
end
|
76
|
+
return self
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_comment(comment)
|
80
|
+
if Bugzilla.logged_in?
|
81
|
+
Bugzilla.server.call("Bug.add_comment", {:id => id, :comment => comment})
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Rubyzilla
|
2
|
+
class Product
|
3
|
+
attr_accessor :id, :name
|
4
|
+
|
5
|
+
def initialize id
|
6
|
+
product = Bugzilla.server.call("Product.get_products", {:ids => [id]})
|
7
|
+
@id = id
|
8
|
+
@name = product["products"][0]["name"]
|
9
|
+
end
|
10
|
+
|
11
|
+
# accessible, enterable, selectable
|
12
|
+
def self.list s="accessible"
|
13
|
+
product_list = Array.new
|
14
|
+
|
15
|
+
product_ids =
|
16
|
+
Bugzilla.server.call("Product.get_#{s}_products")["ids"]
|
17
|
+
|
18
|
+
product_ids.map {|id| product_list << Product.new(id)}
|
19
|
+
return product_list
|
20
|
+
end
|
21
|
+
|
22
|
+
def components
|
23
|
+
result = Bugzilla.server.call("Bug.legal_values", {
|
24
|
+
:field => 'component', :product_id => @id
|
25
|
+
})
|
26
|
+
return result["values"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def milestones
|
30
|
+
result = Bugzilla.server.call("Bug.legal_values", {
|
31
|
+
:field => 'target_milestone', :product_id => @id
|
32
|
+
})
|
33
|
+
result["values"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def versions
|
37
|
+
result = Bugzilla.server.call("Bug.legal_values", {
|
38
|
+
:field => 'version', :product_id => @id
|
39
|
+
})
|
40
|
+
result["values"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
@name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/rubyzilla.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "rubyzilla"
|
3
|
+
s.version = "0.1.1"
|
4
|
+
s.date = "2008-07-02"
|
5
|
+
s.summary = "Ruby API for bugzilla"
|
6
|
+
s.email = "guitsaru@gmail.com"
|
7
|
+
s.homepage = "http://github.com/guitsaru/rubyzilla"
|
8
|
+
s.description = "Rubyzilla is a Ruby API for interfacing with bugzilla."
|
9
|
+
s.has_rdoc = false
|
10
|
+
s.authors = ["Matt Pruitt"]
|
11
|
+
s.files = ["lib/rubyzilla.rb", "lib/rubyzilla/bug.rb",
|
12
|
+
"lib/rubyzilla/product.rb", "rubyzilla.gemspec"]
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyzilla
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Matt Pruitt
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2008-07-02 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Rubyzilla is a Ruby API for interfacing with bugzilla.
|
23
|
+
email: guitsaru@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/rubyzilla.rb
|
32
|
+
- lib/rubyzilla/bug.rb
|
33
|
+
- lib/rubyzilla/product.rb
|
34
|
+
- rubyzilla.gemspec
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/guitsaru/rubyzilla
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 3
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.3.7
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Ruby API for bugzilla
|
69
|
+
test_files: []
|
70
|
+
|