dm-bugzilla-adapter 0.0.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +12 -0
- data/CHANGELOG.rdoc~ +11 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +51 -0
- data/Rakefile +1 -25
- data/dm-bugzilla-adapter.gemspec +6 -3
- data/lib/dm-bugzilla-adapter.rb +29 -20
- data/lib/dm-bugzilla-adapter/read.rb +6 -6
- data/lib/dm-bugzilla-adapter/version.rb +2 -7
- data/tasks/clean.rake +9 -0
- data/tasks/doc.rake +14 -0
- data/tasks/test.rake +6 -0
- data/test/test_run_named_query.rb +10 -5
- metadata +41 -16
- data/.gitignore +0 -5
data/CHANGELOG.rdoc
ADDED
data/CHANGELOG.rdoc~
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 SUSE LINUX Products GmbH
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= dm-bugzilla-adapter
|
2
|
+
|
3
|
+
A DataMapper adapter for Bugzilla
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
This DataMapper adapter allows easy access to the Bugzilla bugtracking
|
8
|
+
system via its XMLRPC interface.
|
9
|
+
|
10
|
+
It supports access to bugs and named queries.
|
11
|
+
|
12
|
+
== Install
|
13
|
+
|
14
|
+
Install it with
|
15
|
+
|
16
|
+
gem install dm-bugzilla-adapter
|
17
|
+
|
18
|
+
== Code
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require 'dm-core'
|
22
|
+
require 'dm-bugzilla-adapter'
|
23
|
+
|
24
|
+
DataMapper::Logger.new($stdout, :debug)
|
25
|
+
# For bugzilla.novell.com, it retrieves credentials from ~/.oscrc if exists
|
26
|
+
# Otherwise add user:pass@ to the url
|
27
|
+
keeper = DataMapper.setup(:default, :adapter => 'bugzilla', :url => 'https://bugzilla.novell.com')
|
28
|
+
require 'bugzilla/bug'
|
29
|
+
require 'bugzilla/named_query'
|
30
|
+
DataMapper.finalize
|
31
|
+
|
32
|
+
# Get a single bug entry
|
33
|
+
f = Bug.get(424242)
|
34
|
+
|
35
|
+
# Access to bugs via a named query
|
36
|
+
named_query = NamedQuery.get("Manager")
|
37
|
+
named_query.bugs.each do |bug|
|
38
|
+
...
|
39
|
+
end
|
40
|
+
|
41
|
+
== TODO
|
42
|
+
|
43
|
+
Map DataMapper queries to Bugzilla queries
|
44
|
+
|
45
|
+
== License
|
46
|
+
|
47
|
+
MIT
|
48
|
+
|
49
|
+
== Author
|
50
|
+
|
51
|
+
Klaus Kämpf <kkaempf@suse.com>
|
data/Rakefile
CHANGED
@@ -1,29 +1,5 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
|
-
extra_docs = ['README*', 'TODO*', 'CHANGELOG*']
|
5
|
-
|
6
4
|
task :default => [:test]
|
7
|
-
|
8
|
-
Rake::TestTask.new do |t|
|
9
|
-
t.libs << File.expand_path('../test', __FILE__)
|
10
|
-
t.libs << File.expand_path('../', __FILE__)
|
11
|
-
t.test_files = FileList['test/test*.rb']
|
12
|
-
t.verbose = true
|
13
|
-
end
|
14
|
-
|
15
|
-
begin
|
16
|
-
require 'yard'
|
17
|
-
YARD::Rake::YardocTask.new(:doc) do |t|
|
18
|
-
t.files = ['lib/**/*.rb', *extra_docs]
|
19
|
-
t.options = ['--no-private']
|
20
|
-
end
|
21
|
-
rescue LoadError
|
22
|
-
STDERR.puts "Install yard if you want prettier docs"
|
23
|
-
require 'rdoc/task'
|
24
|
-
Rake::RDocTask.new(:doc) do |rdoc|
|
25
|
-
rdoc.rdoc_dir = "doc"
|
26
|
-
rdoc.title = "dm-bugzilla-adapter #{DataMapper::Adapters::BugzillaAdapter::VERSION}"
|
27
|
-
extra_docs.each { |ex| rdoc.rdoc_files.include ex }
|
28
|
-
end
|
29
|
-
end
|
5
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
data/dm-bugzilla-adapter.gemspec
CHANGED
@@ -4,21 +4,24 @@ require "dm-bugzilla-adapter/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "dm-bugzilla-adapter"
|
7
|
-
s.version =
|
7
|
+
s.version = BugzillaAdapter::VERSION
|
8
8
|
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ["Klaus Kämpf"]
|
11
11
|
s.email = ["kkaempf@suse.de"]
|
12
|
-
s.homepage = ""
|
12
|
+
s.homepage = "https://github.com/openSUSE/dm-bugzilla-adapter"
|
13
13
|
s.summary = %q{A datamapper adapter for Bugzilla (aka bugzilla.novell.com)}
|
14
14
|
s.description = %q{Use it in Ruby applications to access Bugzilla}
|
15
15
|
|
16
|
-
s.add_dependency("
|
16
|
+
s.add_dependency("dm-core", ["~> 1.2.0"])
|
17
|
+
s.add_dependency("bicho", ["~> 0.0.5"])
|
17
18
|
s.add_dependency("nokogiri", ["~> 1.4"])
|
18
19
|
|
19
20
|
s.rubyforge_project = "dm-bugzilla-adapter"
|
20
21
|
|
21
22
|
s.files = `git ls-files`.split("\n")
|
23
|
+
s.files.reject! { |fn| fn == '.gitignore' }
|
24
|
+
s.extra_rdoc_files = Dir['README*', 'TODO*', 'CHANGELOG*']
|
22
25
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
26
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
27
|
s.require_paths = ["lib"]
|
data/lib/dm-bugzilla-adapter.rb
CHANGED
@@ -1,6 +1,33 @@
|
|
1
1
|
#
|
2
2
|
# dm-bugzilla-adapter.rb
|
3
3
|
#
|
4
|
+
# A DataMapper adapter for Bugzilla
|
5
|
+
#
|
6
|
+
#--
|
7
|
+
# Copyright (c) 2011 SUSE LINUX Products GmbH
|
8
|
+
#
|
9
|
+
# Author: Klaus Kämpf <kkaempf@suse.com>
|
10
|
+
#
|
11
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
12
|
+
# a copy of this software and associated documentation files (the
|
13
|
+
# "Software"), to deal in the Software without restriction, including
|
14
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
15
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
16
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
17
|
+
# the following conditions:
|
18
|
+
#
|
19
|
+
# The above copyright notice and this permission notice shall be
|
20
|
+
# included in all copies or substantial portions of the Software.
|
21
|
+
#
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
23
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
25
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
26
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
27
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
28
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
|
+
#++
|
30
|
+
|
4
31
|
require 'rubygems'
|
5
32
|
|
6
33
|
# DataMapper
|
@@ -42,30 +69,12 @@ module DataMapper::Adapters
|
|
42
69
|
|
43
70
|
# get Bugs by ids
|
44
71
|
def get_bugs(ids)
|
45
|
-
|
72
|
+
@client.get_bugs(*ids)
|
46
73
|
end
|
47
74
|
|
48
75
|
# run named query, return Array of bug ids
|
49
76
|
def named_query(name)
|
50
|
-
|
51
|
-
http.use_ssl = true
|
52
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
53
|
-
request = Net::HTTP::Get.new("/buglist.cgi?cmdtype=runnamed&namedcmd=#{name}&ctype=atom", { "Cookie" => @client.cookie } )
|
54
|
-
response = http.request(request)
|
55
|
-
case response
|
56
|
-
when Net::HTTPSuccess
|
57
|
-
bugs = []
|
58
|
-
xml = Nokogiri::XML.parse(response.body)
|
59
|
-
xml.root.xpath("//xmlns:entry/xmlns:link/@href", xml.root.namespace).each do |attr|
|
60
|
-
uri = URI.parse attr.value
|
61
|
-
bugs << uri.query.split("=")[1]
|
62
|
-
end
|
63
|
-
get_bugs(bugs)
|
64
|
-
when Net::HTTPRedirect
|
65
|
-
raise "HTTP redirect not supported in named_query"
|
66
|
-
else
|
67
|
-
response.error!
|
68
|
-
end
|
77
|
+
@client.get_bugs(name)
|
69
78
|
end
|
70
79
|
end
|
71
80
|
end
|
@@ -147,18 +147,18 @@ module DataMapper::Adapters
|
|
147
147
|
record = { }
|
148
148
|
model.properties.each do |p|
|
149
149
|
v = case p.name
|
150
|
-
when :version, :target_milestone, :op_sys, :qa_contact
|
151
|
-
when :platform
|
152
|
-
when :creator
|
153
|
-
when :whiteboard
|
150
|
+
when :version, :target_milestone, :op_sys, :qa_contact then bug['internals', p.name]
|
151
|
+
when :platform then bug['internals', 'rep_platform']
|
152
|
+
when :creator then bug['internals', 'reporter_id']
|
153
|
+
when :whiteboard then bug['internals', 'status_whiteboard']
|
154
154
|
else
|
155
155
|
bug[p.name]
|
156
156
|
end
|
157
157
|
# STDERR.puts "#{v.inspect} -> #{p.inspect}"
|
158
158
|
if v
|
159
159
|
case p
|
160
|
-
when DataMapper::Property::String
|
161
|
-
when DataMapper::Property::Integer
|
160
|
+
when DataMapper::Property::String then v = v.to_s
|
161
|
+
when DataMapper::Property::Integer then v = v.to_i
|
162
162
|
when DataMapper::Property::DateTime
|
163
163
|
# STDERR.puts "DateTime #{v.to_a.inspect}"
|
164
164
|
v = DateTime.civil(*v.to_a)
|
data/tasks/clean.rake
ADDED
data/tasks/doc.rake
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
begin
|
2
|
+
require 'yard'
|
3
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
4
|
+
t.files = ['lib/**/*.rb']
|
5
|
+
t.options = ['--no-private']
|
6
|
+
end
|
7
|
+
rescue LoadError
|
8
|
+
STDERR.puts "Install yard if you want prettier docs"
|
9
|
+
require 'rdoc/task'
|
10
|
+
Rake::RDocTask.new(:doc) do |rdoc|
|
11
|
+
rdoc.rdoc_dir = "doc"
|
12
|
+
rdoc.title = "dm-bugzilla-adapter #{DataMapper::Adapters::BugzillaAdapter::VERSION}"
|
13
|
+
end
|
14
|
+
end
|
data/tasks/test.rake
ADDED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'helper')
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
2
|
|
3
3
|
class Run_named_query_test < Test::Unit::TestCase
|
4
4
|
|
@@ -11,10 +11,15 @@ class Run_named_query_test < Test::Unit::TestCase
|
|
11
11
|
require 'bugzilla/named_query'
|
12
12
|
DataMapper.finalize
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
# assert_raise do
|
15
|
+
named_query = NamedQuery.get("Manager")
|
16
|
+
assert named_query
|
17
|
+
bugs = named_query.bugs
|
18
|
+
# end
|
19
|
+
# named_query = NamedQuery.get("Manager")
|
20
|
+
# assert named_query
|
21
|
+
# bugs = named_query.bugs
|
22
|
+
# assert bugs
|
18
23
|
puts "Query '#{named_query.name}' results in #{bugs.size} bugs"
|
19
24
|
end
|
20
25
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-bugzilla-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Klaus K\xC3\xA4mpf"
|
@@ -15,29 +15,45 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-17 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: dm-core
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 31
|
30
30
|
segments:
|
31
|
-
-
|
32
|
-
- 0
|
31
|
+
- 1
|
33
32
|
- 2
|
34
|
-
|
33
|
+
- 0
|
34
|
+
version: 1.2.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: bicho
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 21
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
- 5
|
50
|
+
version: 0.0.5
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: nokogiri
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
58
|
requirements:
|
43
59
|
- - ~>
|
@@ -48,7 +64,7 @@ dependencies:
|
|
48
64
|
- 4
|
49
65
|
version: "1.4"
|
50
66
|
type: :runtime
|
51
|
-
version_requirements: *
|
67
|
+
version_requirements: *id003
|
52
68
|
description: Use it in Ruby applications to access Bugzilla
|
53
69
|
email:
|
54
70
|
- kkaempf@suse.de
|
@@ -56,10 +72,15 @@ executables: []
|
|
56
72
|
|
57
73
|
extensions: []
|
58
74
|
|
59
|
-
extra_rdoc_files:
|
60
|
-
|
75
|
+
extra_rdoc_files:
|
76
|
+
- README.rdoc
|
77
|
+
- CHANGELOG.rdoc~
|
78
|
+
- CHANGELOG.rdoc
|
61
79
|
files:
|
62
|
-
- .
|
80
|
+
- CHANGELOG.rdoc
|
81
|
+
- Gemfile
|
82
|
+
- MIT-LICENSE
|
83
|
+
- README.rdoc
|
63
84
|
- Rakefile
|
64
85
|
- dm-bugzilla-adapter.gemspec
|
65
86
|
- lib/bugzilla/bug.rb
|
@@ -71,11 +92,15 @@ files:
|
|
71
92
|
- lib/dm-bugzilla-adapter/read.rb
|
72
93
|
- lib/dm-bugzilla-adapter/update.rb
|
73
94
|
- lib/dm-bugzilla-adapter/version.rb
|
95
|
+
- tasks/clean.rake
|
96
|
+
- tasks/doc.rake
|
97
|
+
- tasks/test.rake
|
74
98
|
- test/helper.rb
|
75
99
|
- test/test_get_bug.rb
|
76
100
|
- test/test_run_named_query.rb
|
101
|
+
- CHANGELOG.rdoc~
|
77
102
|
has_rdoc: true
|
78
|
-
homepage:
|
103
|
+
homepage: https://github.com/openSUSE/dm-bugzilla-adapter
|
79
104
|
licenses: []
|
80
105
|
|
81
106
|
post_install_message:
|
@@ -104,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
129
|
requirements: []
|
105
130
|
|
106
131
|
rubyforge_project: dm-bugzilla-adapter
|
107
|
-
rubygems_version: 1.5.
|
132
|
+
rubygems_version: 1.5.0
|
108
133
|
signing_key:
|
109
134
|
specification_version: 3
|
110
135
|
summary: A datamapper adapter for Bugzilla (aka bugzilla.novell.com)
|