ticketmaster-trac 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010 YOU
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
+ NONE
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # ticketmaster-trac
2
+
3
+ This is a provider for [ticketmaster](http://ticketrb.com). It provides interoperability with [Trac](http://trac.edgewall.org) and it's issue tracking system through the ticketmaster gem.
4
+
5
+ # Usage and Examples
6
+
7
+ First we have to instantiate a new ticketmaster instance, your trac installation should have api access enable:
8
+ trac = TicketMaster.new(:trac, {:username=> 'foo', :password => "bar", :url => "http://tracserver/project"})
9
+
10
+ If you do not pass in the url, username and password, you won't get any information.
11
+
12
+ == Finding Projects(Repositories)
13
+
14
+ Right now Trac doesn't support project handling, that's why you will use a project holder which consist of your username and url for the Trac instance.
15
+
16
+ == Finding Tickets(Issues)
17
+
18
+ tickets = project.tickets # All tickets
19
+ ticket = project.tickets(:status => '!closed') # All non closed tickets, you can specified any type of attributes field based on Trac scheme. ex. :component => 'Web'
20
+
21
+ == Open Tickets
22
+
23
+ ticket = project.ticket!({:summary => "New ticket", :description=> "Body for the very new ticket"}, attributes) # summary and description are mandatory fields the attributes hash will contain all the optional info that you need for your ticket, have to use the fields provided by Trac api.
24
+
25
+
26
+ ## Requirements
27
+
28
+ * rubygems (obviously)
29
+ * ticketmaster gem (latest version preferred)
30
+ * jeweler gem (only if you want to repackage and develop)
31
+ * trac4r
32
+
33
+ The ticketmaster gem should automatically be installed during the installation of this gem if it is not already installed.
34
+
35
+ ## Other Notes
36
+
37
+ Since this and the ticketmaster gem is still primarily a work-in-progress, minor changes may be incompatible with previous versions. Please be careful about using and updating this gem in production.
38
+
39
+ If you see or find any issues, feel free to open up an issue report.
40
+
41
+
42
+ ## Note on Patches/Pull Requests
43
+
44
+ * Fork the project.
45
+ * Make your feature addition or bug fix.
46
+ * Add tests for it. This is important so we don't break it in a
47
+ future version unintentionally.
48
+ * Commit, do not mess with rakefile, version, or history.
49
+ (if you want to have your own version, that is fine but bump version in a commit by itself so we can ignore when I pull)
50
+ * Send us a pull request. Bonus points for topic branches.
51
+
52
+ ## Copyright
53
+
54
+ Copyright (c) 2010 The Hybrid Group. See LICENSE for details.
55
+
56
+
data/Rakefile ADDED
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "ticketmaster-trac"
8
+ gem.summary = %Q{Ticketmaster Provider for Trac}
9
+ gem.description = %Q{Allows ticketmaster to interact with Your System.}
10
+ gem.email = "george.rafael@gmail.com"
11
+ gem.homepage = "http://bandw.tumblr.com"
12
+ gem.authors = ["Rafael George"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "ticketmaster", ">= 0.1.0"
15
+ gem.add_dependency "activesupport", ">= 2.3.2"
16
+ gem.add_dependency "activeresource", ">= 2.3.2"
17
+ gem.add_dependency "addressable", ">= 2.1.2"
18
+ gem.add_dependency "trac4r"
19
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
+ end
25
+
26
+ require 'spec/rake/spectask'
27
+ Spec::Rake::SpecTask.new(:spec) do |spec|
28
+ spec.libs << 'lib' << 'spec'
29
+ spec.spec_files = FileList['spec/**/*_spec.rb']
30
+ end
31
+
32
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
33
+ spec.libs << 'lib' << 'spec'
34
+ spec.pattern = 'spec/**/*_spec.rb'
35
+ spec.rcov = true
36
+ end
37
+
38
+ task :spec => :check_dependencies
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "ticketmaster-trac #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,13 @@
1
+ module TicketMaster::Provider
2
+ module Trac
3
+ # The comment class for ticketmaster-yoursystem
4
+ #
5
+ # Do any mapping between Ticketmaster and your system's comment model here
6
+ # versions of the ticket.
7
+ #
8
+ class Comment < TicketMaster::Provider::Base::Comment
9
+ # declare needed overloaded methods here
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,77 @@
1
+ module TicketMaster::Provider
2
+ module Trac
3
+ # Project class for ticketmaster-yoursystem
4
+ #
5
+ #
6
+ class Project < TicketMaster::Provider::Base::Project
7
+ # declare needed overloaded methods here
8
+ API = TracAPI
9
+
10
+ def initialize(*object)
11
+ if object.first
12
+ object = object.first
13
+ @system_data = {:client => object}
14
+ unless object.is_a? Hash
15
+ hash = {:repository => object.url,
16
+ :user => object.username}
17
+
18
+ else
19
+ hash = object
20
+ end
21
+ super hash
22
+ end
23
+ end
24
+
25
+ # copy from this.copy(that) copies that into this
26
+ def copy(project)
27
+ project.tickets.each do |ticket|
28
+ copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
29
+ ticket.comments.each do |comment|
30
+ copy_ticket.comment!(:body => comment.body)
31
+ sleep 1
32
+ end
33
+ end
34
+ end
35
+
36
+ def self.find(*options)
37
+ mode = options.first
38
+ if mode.is_a? String
39
+ self.new({:url => API.url, :username => "#{API.username}-project"})
40
+ end
41
+ end
42
+
43
+ def ticket(*options)
44
+ unless options.empty?
45
+ options = options.first
46
+ if options.is_a? Hash
47
+ TicketMaster::Provider::Trac::Ticket.find_by_id API.api.tickets.query(options).first
48
+ end
49
+ else
50
+ TicketMaster::Provider::Trac::Ticket
51
+ end
52
+ end
53
+
54
+ def ticket!(*options)
55
+ options = options.first
56
+ TicketMaster::Provider::Trac::Ticket.create options
57
+ end
58
+
59
+ def tickets(*options)
60
+ mode = options.first
61
+ if options.empty?
62
+ collect_tickets(API.api.tickets.list)
63
+ elsif mode.is_a? Array
64
+ collect_tickets(mode)
65
+ elsif mode.is_a? Hash
66
+ collect_tickets(API.api.tickets.query(mode))
67
+ end
68
+ end
69
+
70
+ private
71
+ def collect_tickets(tickets)
72
+ tickets.collect { |ticket_id| TicketMaster::Provider::Trac::Ticket.find_by_id ticket_id}
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,68 @@
1
+ module TicketMaster::Provider
2
+ module Trac
3
+ # Ticket class for ticketmaster-yoursystem
4
+ #
5
+
6
+ class Ticket < TicketMaster::Provider::Base::Ticket
7
+ # declare needed overloaded methods here
8
+
9
+ API = TracAPI
10
+ def initialize(*object)
11
+ if object.first
12
+ object = object.first
13
+ unless object.is_a? Hash
14
+ @system_data = {:client => object}
15
+ hash = {:id => object.id,
16
+ :severity => object.severity,
17
+ :milestone => object.milestone,
18
+ :status => object.status,
19
+ :type => object.type,
20
+ :priority => object.priority,
21
+ :version => object.version,
22
+ :reporter => object.reporter,
23
+ :owner => object.owner,
24
+ :cc => object.cc,
25
+ :summary => object.summary,
26
+ :description => object.description,
27
+ :keywords => object.keywords,
28
+ :created_at => object.created_at,
29
+ :updated_at => object.updated_at}
30
+ else
31
+ hash = object
32
+ end
33
+ super(hash)
34
+ end
35
+ end
36
+
37
+ def self.find_by_id(id)
38
+ self.new API.api.tickets.get id
39
+ end
40
+
41
+ def self.create(*options)
42
+ mandatory = options.shift
43
+ attributes = {}
44
+ attributes ||= options.shift
45
+ begin
46
+ self.find_by_id API.api.tickets.create(mandatory[:summary], mandatory[:description], attributes)
47
+ rescue
48
+ self
49
+ end
50
+ end
51
+
52
+ def comments
53
+ warn "Trac doesn't support comments"
54
+ []
55
+ end
56
+
57
+ def comment
58
+ warn "Trac doesn't support comments"
59
+ nil
60
+ end
61
+
62
+ def comment!
63
+ warn "Trac doesn't support comments"
64
+ []
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,32 @@
1
+ module TicketMaster::Provider
2
+ # This is the Yoursystem Provider for ticketmaster
3
+ module Trac
4
+ include TicketMaster::Provider::Base
5
+
6
+ # This is for cases when you want to instantiate using TicketMaster::Provider::Yoursystem.new(auth)
7
+ def self.new(auth = {})
8
+ TicketMaster.new(:trac, auth)
9
+ end
10
+
11
+ def authorize(auth = {})
12
+ @authentication ||= TicketMaster::Authenticator.new(auth)
13
+ auth = @authentication
14
+ @trac = ::Trac.new(auth.url, auth.username, auth.password)
15
+ TracAPI.new @trac, auth.url, auth.username
16
+ end
17
+
18
+ # declare needed overloaded methods here
19
+ def projects(*options)
20
+ [Project.new({:url => @authentication.url, :username => @authentication.username})]
21
+ end
22
+
23
+ def project(*options)
24
+ unless options.empty?
25
+ Project.new({:url => @authentication.url, :username => @authentication.username, :name => "#{@authentication.username}-project"})
26
+ else
27
+ TicketMaster::Provider::Trac::Project
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ require 'trac4r'
2
+
3
+ require 'lib/trac/trac'
4
+
5
+ %w{ trac ticket project comment }.each do |f|
6
+ require File.dirname(__FILE__) + '/provider/' + f + '.rb';
7
+ end
8
+
data/lib/trac/trac.rb ADDED
@@ -0,0 +1,23 @@
1
+ # code to communicate with your backend goes here...
2
+
3
+ class TracAPI
4
+ def initialize(trac, username, url)
5
+ @@api = trac
6
+ @@username = username
7
+ @@url = url
8
+ end
9
+
10
+ def self.api
11
+ @@api
12
+ end
13
+
14
+ def self.url
15
+ @@url
16
+ end
17
+
18
+ def self.username
19
+ @@username
20
+ end
21
+ end
22
+
23
+
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Trac::Comment" do
4
+ it "should have specs for comments"
5
+ end
File without changes
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Trac::Project" do
4
+
5
+ before(:all) do
6
+ @project_id = 'cored-project'
7
+ end
8
+
9
+ before(:each) do
10
+ @ticketmaster = TicketMaster.new(:trac, {:username => 'cored', :password => 'afdzk', :url => 'http://trac.edgewall.org/demo-0.11'})
11
+ @klass = TicketMaster::Provider::Trac::Project
12
+ end
13
+
14
+ it "should be able to load all projects" do
15
+ @ticketmaster.projects.should be_an_instance_of(Array)
16
+ @ticketmaster.projects.first.should be_an_instance_of(@klass)
17
+ end
18
+
19
+ it "should be able to load all projects from an array of id's" do
20
+ @projects = @ticketmaster.projects([@project_id])
21
+ @projects.should be_an_instance_of(Array)
22
+ @projects.first.should be_an_instance_of(@klass)
23
+ end
24
+
25
+ it "should be able to load all projects from attributes" do
26
+ @projects = @ticketmaster.projects(:url => 'http://trac.edgewall.org')
27
+ @projects.should be_an_instance_of(Array)
28
+ @projects.first.should be_an_instance_of(@klass)
29
+ end
30
+
31
+ it "should be able to load projects using the find method" do
32
+ @ticketmaster.project.should == @klass
33
+ @ticketmaster.project.find(@project_id).should be_an_instance_of(@klass)
34
+ end
35
+
36
+ it "should be able to find a project by name" do
37
+ @project = @ticketmaster.project(@project_id)
38
+ @project.should be_an_instance_of(@klass)
39
+ @project.name.should == @project_id
40
+ end
41
+
42
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rubygems'
4
+ require 'ticketmaster'
5
+ require 'ticketmaster-trac'
6
+ require 'spec'
7
+ require 'spec/autorun'
8
+
9
+ Spec::Runner.configure do |config|
10
+
11
+ end
12
+
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Trac" do
4
+
5
+ it "should be able to instantiate a new instance" do
6
+ @ticketmaster = TicketMaster.new(:trac, {:username => 'ticketmaster', :password => '000000', :url => 'here.com'})
7
+ @ticketmaster.should be_an_instance_of(TicketMaster)
8
+ @ticketmaster.should be_a_kind_of(TicketMaster::Provider::Trac)
9
+ end
10
+
11
+ end
@@ -0,0 +1,48 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ticketmaster::Provider::Trac::Ticket" do
4
+ before(:all) do
5
+ @project_id = 'demo-0.11'
6
+ end
7
+
8
+ before(:each) do
9
+ @ticketmaster = TicketMaster.new(:trac, {:url => 'http://pl3.projectlocker.com/cored/testrepo/trac', :username => 'george.rafael@gmail.com', :password => '123456'})
10
+ @project = @ticketmaster.project(@project_id)
11
+ @klass = TicketMaster::Provider::Trac::Ticket
12
+ end
13
+
14
+ it "should be able to load all tickets" do
15
+ @project.tickets.should be_an_instance_of(Array)
16
+ @project.tickets.first.should be_an_instance_of(@klass)
17
+ end
18
+
19
+ it "should be able to load all tickets based on array of id's" do
20
+ @tickets = @project.tickets([1])
21
+ @tickets.should be_an_instance_of(Array)
22
+ @tickets.first.should be_an_instance_of(@klass)
23
+ @tickets.first.summary.should == 'test'
24
+ end
25
+
26
+ it "should be able to load all tickets using attributes" do
27
+ @tickets = @project.tickets(:status => "!closed")
28
+ @tickets.should be_an_instance_of(Array)
29
+ @tickets.first.should be_an_instance_of(@klass)
30
+ @tickets.first.summary.should == 'test'
31
+ end
32
+
33
+ it "should return the ticket class" do
34
+ @project.ticket.should == @klass
35
+ end
36
+
37
+ it "should be able to load a single ticket based on attributes" do
38
+ @ticket = @project.ticket(:status => "!closed")
39
+ @ticket.should be_an_instance_of(@klass)
40
+ @ticket.summary.should == 'test'
41
+ end
42
+
43
+ it "should be able to create a new ticket" do
44
+ @ticket = @project.ticket!({:summary => 'Testing', :description => "Here we go"})
45
+ @ticket.should be_an_instance_of(@klass)
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ticketmaster-trac
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Rafael George
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-30 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: ticketmaster
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 27
46
+ segments:
47
+ - 0
48
+ - 1
49
+ - 0
50
+ version: 0.1.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: activesupport
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 7
62
+ segments:
63
+ - 2
64
+ - 3
65
+ - 2
66
+ version: 2.3.2
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: activeresource
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 7
78
+ segments:
79
+ - 2
80
+ - 3
81
+ - 2
82
+ version: 2.3.2
83
+ type: :runtime
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: addressable
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 15
94
+ segments:
95
+ - 2
96
+ - 1
97
+ - 2
98
+ version: 2.1.2
99
+ type: :runtime
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: trac4r
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ type: :runtime
114
+ version_requirements: *id006
115
+ description: Allows ticketmaster to interact with Your System.
116
+ email: george.rafael@gmail.com
117
+ executables: []
118
+
119
+ extensions: []
120
+
121
+ extra_rdoc_files:
122
+ - LICENSE
123
+ - README.md
124
+ files:
125
+ - LICENSE
126
+ - README.md
127
+ - Rakefile
128
+ - VERSION
129
+ - lib/provider/comment.rb
130
+ - lib/provider/project.rb
131
+ - lib/provider/ticket.rb
132
+ - lib/provider/trac.rb
133
+ - lib/ticketmaster-trac.rb
134
+ - lib/trac/trac.rb
135
+ - spec/comments_spec.rb
136
+ - spec/fixtures/tickets.xml
137
+ - spec/projects_spec.rb
138
+ - spec/spec.opts
139
+ - spec/spec_helper.rb
140
+ - spec/ticketmaster-trac_spec.rb
141
+ - spec/tickets_spec.rb
142
+ has_rdoc: true
143
+ homepage: http://bandw.tumblr.com
144
+ licenses: []
145
+
146
+ post_install_message:
147
+ rdoc_options: []
148
+
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ hash: 3
157
+ segments:
158
+ - 0
159
+ version: "0"
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ requirements: []
170
+
171
+ rubyforge_project:
172
+ rubygems_version: 1.3.7
173
+ signing_key:
174
+ specification_version: 3
175
+ summary: Ticketmaster Provider for Trac
176
+ test_files:
177
+ - spec/comments_spec.rb
178
+ - spec/projects_spec.rb
179
+ - spec/spec_helper.rb
180
+ - spec/ticketmaster-trac_spec.rb
181
+ - spec/tickets_spec.rb