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.
@@ -0,0 +1,12 @@
1
+ == 0.1.1
2
+
3
+ * Support redirection in named query
4
+ * Add CHANGELOG
5
+
6
+ == 0.1.0
7
+
8
+ * First upload to rubygems.org
9
+
10
+ == 0.0.1
11
+
12
+ * Initial release
@@ -0,0 +1,11 @@
1
+ == 0.1.1
2
+
3
+ * Support redirection in named query
4
+
5
+ == 0.1.0
6
+
7
+ * First upload to rubygems.org
8
+
9
+ == 0.0.1
10
+
11
+ * Initial releas
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in dm-bugzilla-adapter.gemspec
4
+ gemspec
@@ -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.
@@ -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 }
@@ -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 = DataMapper::Adapters::BugzillaAdapter::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("bicho", ["~> 0.0.2"])
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"]
@@ -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
- bugs = @client.get_bugs(*ids)
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
- http = Net::HTTP.new(@uri.host, @uri.port)
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 : bug['internals', p.name]
151
- when :platform : bug['internals', 'rep_platform']
152
- when :creator : bug['internals', 'reporter_id']
153
- when :whiteboard : bug['internals', 'status_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: v = v.to_s
161
- when DataMapper::Property::Integer: v = v.to_i
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)
@@ -1,8 +1,3 @@
1
- require 'dm-core'
2
- require 'dm-core/adapters/abstract_adapter'
3
-
4
- module DataMapper::Adapters
5
- class BugzillaAdapter < AbstractAdapter
6
- VERSION = "0.0.1"
7
- end
1
+ class BugzillaAdapter
2
+ VERSION = "0.1.2"
8
3
  end
@@ -0,0 +1,9 @@
1
+ task :clean do
2
+ `rm -rf *~`
3
+ `rm -rf */*~`
4
+ `rm -rf */*/*~`
5
+ `rm -rf pkg`
6
+ `rm -rf doc`
7
+ `rm -rf .yardoc`
8
+ `rm -f Gemfile.lock`
9
+ end
@@ -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
@@ -0,0 +1,6 @@
1
+ Rake::TestTask.new do |t|
2
+ t.libs << File.expand_path('../test', __FILE__)
3
+ t.libs << File.expand_path('../', __FILE__)
4
+ t.test_files = FileList['test/test*.rb']
5
+ t.verbose = true
6
+ end
@@ -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
- named_query = NamedQuery.get("Manager")
15
- assert named_query
16
- bugs = named_query.bugs
17
- assert bugs
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: 29
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
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: 2011-09-27 00:00:00 +02:00
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: bicho
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: 27
29
+ hash: 31
30
30
  segments:
31
- - 0
32
- - 0
31
+ - 1
33
32
  - 2
34
- version: 0.0.2
33
+ - 0
34
+ version: 1.2.0
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: nokogiri
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: *id002
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
- - .gitignore
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.2
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)
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- *~