ticketmaster-trac 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -5
- data/VERSION +1 -1
- data/lib/provider/comment.rb +16 -0
- data/lib/provider/project.rb +7 -4
- data/lib/provider/ticket.rb +47 -4
- data/lib/provider/trac.rb +1 -1
- data/lib/trac/trac.rb +1 -0
- data/spec/comments_spec.rb +9 -2
- data/spec/tickets_spec.rb +6 -0
- data/ticketmaster-trac.gemspec +2 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -5,24 +5,24 @@ This is a provider for [ticketmaster](http://ticketrb.com). It provides interope
|
|
5
5
|
# Usage and Examples
|
6
6
|
|
7
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"})
|
8
|
+
trac = TicketMaster.new(:trac, {:username=> 'foo', :password => "bar", :url => "http://tracserver/username/project/trac"})
|
9
9
|
|
10
10
|
If you do not pass in the url, username and password, you won't get any information.
|
11
11
|
|
12
|
-
|
12
|
+
## Finding Projects(Repositories)
|
13
13
|
|
14
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
15
|
|
16
|
-
|
16
|
+
## Finding Tickets(Issues)
|
17
17
|
|
18
18
|
tickets = project.tickets # All tickets
|
19
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
20
|
|
21
|
-
|
21
|
+
## Open Tickets
|
22
22
|
|
23
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
24
|
|
25
|
-
|
25
|
+
## Finding comments
|
26
26
|
|
27
27
|
comments = project.tickets.first.comments # All the tickets facility for searchs are available for comments as well
|
28
28
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/provider/comment.rb
CHANGED
@@ -25,6 +25,22 @@ module TicketMaster::Provider
|
|
25
25
|
super(hash)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
def created_at
|
30
|
+
begin
|
31
|
+
Time.parse(self[:created_at])
|
32
|
+
rescue
|
33
|
+
self[:created_at]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def updated_at
|
38
|
+
begin
|
39
|
+
Time.parse(self[:updated_at])
|
40
|
+
rescue
|
41
|
+
self[:updated_at]
|
42
|
+
end
|
43
|
+
end
|
28
44
|
end
|
29
45
|
end
|
30
46
|
end
|
data/lib/provider/project.rb
CHANGED
@@ -13,7 +13,8 @@ module TicketMaster::Provider
|
|
13
13
|
@system_data = {:client => object}
|
14
14
|
unless object.is_a? Hash
|
15
15
|
hash = {:repository => object.url,
|
16
|
-
:user => object.username
|
16
|
+
:user => object.username,
|
17
|
+
:name => object.name}
|
17
18
|
|
18
19
|
else
|
19
20
|
hash = object
|
@@ -36,7 +37,7 @@ module TicketMaster::Provider
|
|
36
37
|
def self.find(*options)
|
37
38
|
mode = options.first
|
38
39
|
if mode.is_a? String
|
39
|
-
self.new({:url => API.url, :username => "#{API.username}-project"})
|
40
|
+
self.new({:url => API.url, :username => API.username, :name=> "#{API.username}-project"})
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -44,7 +45,7 @@ module TicketMaster::Provider
|
|
44
45
|
unless options.empty?
|
45
46
|
options = options.first
|
46
47
|
if options.is_a? Hash
|
47
|
-
TicketMaster::Provider::Trac::Ticket.find_by_id
|
48
|
+
TicketMaster::Provider::Trac::Ticket.find_by_id(API.api.tickets.query(options).first, self[:name])
|
48
49
|
end
|
49
50
|
else
|
50
51
|
TicketMaster::Provider::Trac::Ticket
|
@@ -69,7 +70,9 @@ module TicketMaster::Provider
|
|
69
70
|
|
70
71
|
private
|
71
72
|
def collect_tickets(tickets)
|
72
|
-
tickets.collect
|
73
|
+
tickets.collect do |ticket_id|
|
74
|
+
TicketMaster::Provider::Trac::Ticket.find_by_id(ticket_id, self[:name])
|
75
|
+
end
|
73
76
|
end
|
74
77
|
|
75
78
|
end
|
data/lib/provider/ticket.rb
CHANGED
@@ -9,7 +9,9 @@ module TicketMaster::Provider
|
|
9
9
|
API = TracAPI
|
10
10
|
def initialize(*object)
|
11
11
|
if object.first
|
12
|
-
|
12
|
+
args = object
|
13
|
+
object = args.shift
|
14
|
+
project_id = args.shift
|
13
15
|
unless object.is_a? Hash
|
14
16
|
@system_data = {:client => object}
|
15
17
|
hash = {:id => object.id,
|
@@ -23,6 +25,10 @@ module TicketMaster::Provider
|
|
23
25
|
:owner => object.owner,
|
24
26
|
:cc => object.cc,
|
25
27
|
:summary => object.summary,
|
28
|
+
:assignee => object.owner,
|
29
|
+
:requestor => object.reporter,
|
30
|
+
:title => object.summary,
|
31
|
+
:project_id => project_id,
|
26
32
|
:description => object.description,
|
27
33
|
:keywords => object.keywords,
|
28
34
|
:created_at => object.created_at,
|
@@ -34,8 +40,26 @@ module TicketMaster::Provider
|
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
37
|
-
def
|
38
|
-
|
43
|
+
def created_at
|
44
|
+
begin
|
45
|
+
normalize_datetime(self[:created_at])
|
46
|
+
rescue
|
47
|
+
self[:created_at]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def updated_at
|
52
|
+
begin
|
53
|
+
normalize_datetime(self[:updated_at])
|
54
|
+
rescue
|
55
|
+
self[:updated_at]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.find_by_id(id, project_id)
|
60
|
+
retryable(:tries => 5) do
|
61
|
+
self.new API.api.tickets.get(id), project_id
|
62
|
+
end
|
39
63
|
end
|
40
64
|
|
41
65
|
def self.create(*options)
|
@@ -79,9 +103,28 @@ module TicketMaster::Provider
|
|
79
103
|
end
|
80
104
|
|
81
105
|
def comment!
|
82
|
-
warn "Trac doesn't support comments"
|
106
|
+
warn "Trac doesn't support creation of comments"
|
83
107
|
[]
|
84
108
|
end
|
109
|
+
|
110
|
+
private
|
111
|
+
def normalize_datetime(datetime)
|
112
|
+
Time.mktime(datetime.year, datetime.month, datetime.day, datetime.hour, datetime.min, datetime.sec)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Extracted this code from facet http://api.mackframework.com/mack-facets/classes/Kernel.html
|
116
|
+
def self.retryable(options = {}, &block)
|
117
|
+
opts = { :tries => 1, :on => Exception }.merge(options)
|
118
|
+
|
119
|
+
retry_exception, retries = opts[:on], opts[:tries]
|
120
|
+
|
121
|
+
begin
|
122
|
+
return yield
|
123
|
+
rescue retry_exception
|
124
|
+
retry if (retries -= 1) > 0
|
125
|
+
end
|
126
|
+
yield
|
127
|
+
end
|
85
128
|
end
|
86
129
|
end
|
87
130
|
end
|
data/lib/provider/trac.rb
CHANGED
@@ -17,7 +17,7 @@ module TicketMaster::Provider
|
|
17
17
|
|
18
18
|
# declare needed overloaded methods here
|
19
19
|
def projects(*options)
|
20
|
-
[Project.new({:url => @authentication.url, :username => @authentication.username})]
|
20
|
+
[Project.new({:url => @authentication.url, :username => @authentication.username, :name => "#{@authentication.username}-project"})]
|
21
21
|
end
|
22
22
|
|
23
23
|
def project(*options)
|
data/lib/trac/trac.rb
CHANGED
data/spec/comments_spec.rb
CHANGED
@@ -4,11 +4,18 @@ describe "Ticketmaster::Provider::Trac::Comment" do
|
|
4
4
|
before(:each) do
|
5
5
|
@ticketmaster = TicketMaster.new(:trac, {:username => 'george.rafael@gmail.com', :password => '123456', :url => 'http://pl3.projectlocker.com/cored/testrepo/trac'})
|
6
6
|
@project = @ticketmaster.projects.first
|
7
|
+
@project.stub!(:tickets).and_return([TicketMaster::Provider::Trac::Ticket.new])
|
7
8
|
@ticket = @project.tickets.first
|
8
9
|
@klass = TicketMaster::Provider::Trac::Comment
|
10
|
+
@comment_1 = @klass.new(:id => 1)
|
11
|
+
@comment_2 = @klass.new(:id => 2)
|
12
|
+
@comments = [@comment_1, @comment_2]
|
13
|
+
@ticket.stub!(:comments).and_return(@comments)
|
14
|
+
@ticket.stub!(:comment).and_return(@comment_2)
|
9
15
|
end
|
10
16
|
|
11
17
|
it "should load all comments from a ticket" do
|
18
|
+
|
12
19
|
@ticket.comments.should be_an_instance_of(Array)
|
13
20
|
@ticket.comments.first.should be_an_instance_of(@klass)
|
14
21
|
end
|
@@ -40,9 +47,9 @@ describe "Ticketmaster::Provider::Trac::Comment" do
|
|
40
47
|
end
|
41
48
|
|
42
49
|
it "should be able to load a comment using attributes" do
|
43
|
-
@comment = @ticket.comment(:ticket_id =>
|
50
|
+
@comment = @ticket.comment(:ticket_id => 2)
|
44
51
|
@comment.should be_an_instance_of(@klass)
|
45
|
-
@comment.id.should ==
|
52
|
+
@comment.id.should == 2
|
46
53
|
end
|
47
54
|
|
48
55
|
end
|
data/spec/tickets_spec.rb
CHANGED
@@ -9,6 +9,11 @@ describe "Ticketmaster::Provider::Trac::Ticket" do
|
|
9
9
|
@ticketmaster = TicketMaster.new(:trac, {:url => 'http://pl3.projectlocker.com/cored/testrepo/trac', :username => 'george.rafael@gmail.com', :password => '123456'})
|
10
10
|
@project = @ticketmaster.project(@project_id)
|
11
11
|
@klass = TicketMaster::Provider::Trac::Ticket
|
12
|
+
@ticket_1 = @klass.new(:summary => 'test', :status => 'open')
|
13
|
+
@tickets = [@ticket_1]
|
14
|
+
@project.stub!(:tickets).and_return(@tickets)
|
15
|
+
@project.stub!(:ticket).and_return(@ticket_1)
|
16
|
+
@project.stub!(:ticket!).and_return(@klass.new)
|
12
17
|
end
|
13
18
|
|
14
19
|
it "should be able to load all tickets" do
|
@@ -31,6 +36,7 @@ describe "Ticketmaster::Provider::Trac::Ticket" do
|
|
31
36
|
end
|
32
37
|
|
33
38
|
it "should return the ticket class" do
|
39
|
+
@project.stub!(:ticket).and_return(@klass)
|
34
40
|
@project.ticket.should == @klass
|
35
41
|
end
|
36
42
|
|
data/ticketmaster-trac.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ticketmaster-trac}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rafael George"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-07}
|
13
13
|
s.description = %q{Allows ticketmaster to interact with Your System.}
|
14
14
|
s.email = %q{george.rafael@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ticketmaster-trac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rafael George
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-07 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|