ticketmaster-pivotal 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/provider/comment.rb +75 -0
- data/lib/provider/pivotal.rb +2 -63
- data/lib/provider/project.rb +1 -75
- data/lib/provider/ticket.rb +5 -67
- data/lib/ticketmaster-pivotal.rb +1 -1
- data/ticketmaster-pivotal.gemspec +66 -0
- metadata +6 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.2.0
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module TicketMaster::Provider
|
2
|
+
module Pivotal
|
3
|
+
# The comment class for ticketmaster-pivotal
|
4
|
+
# * author
|
5
|
+
# * body => text
|
6
|
+
# * id => position in the versions array (set by the initializer)
|
7
|
+
# * created_at => noted_at
|
8
|
+
# * updated_at => noted_at
|
9
|
+
# * ticket_id (actually the story id)
|
10
|
+
# * project_id
|
11
|
+
class Comment < TicketMaster::Provider::Base::Comment
|
12
|
+
API = PivotalAPI::Note
|
13
|
+
|
14
|
+
# A custom find_by_id
|
15
|
+
# The "comment" id is it's index in the versions array. An id of 0 therefore exists and
|
16
|
+
# should be the first ticket (original)
|
17
|
+
def self.find_by_id(project_id, ticket_id, id)
|
18
|
+
self.new PivotalAPI::Note.find(id, :params => {:project_id => project_id, :story_id => ticket_id})
|
19
|
+
end
|
20
|
+
|
21
|
+
# A custom find_by_attributes
|
22
|
+
#
|
23
|
+
def self.find_by_attributes(project_id, ticket_id, attributes = {})
|
24
|
+
self.search(project_id, ticket_id, attributes).collect { |comment| self.new comment }
|
25
|
+
end
|
26
|
+
|
27
|
+
# A custom searcher
|
28
|
+
#
|
29
|
+
# It returns a custom result because we need the original story to make a comment.
|
30
|
+
def self.search(project_id, ticket_id, options = {}, limit = 1000)
|
31
|
+
comments = PivotalAPI::Note.find(:all, :params => {:project_id => project_id, :story_id => ticket_id})
|
32
|
+
search_by_attribute(comments, options, limit)
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(note, ticket = nil)
|
36
|
+
@system_data ||= {}
|
37
|
+
@system_data[:ticket] = @system_data[:client] = ticket if ticket
|
38
|
+
if note.is_a?(PivotalAPI::Note)
|
39
|
+
@system_data[:note] = note
|
40
|
+
self.project_id = note.prefix_options[:project_id]
|
41
|
+
self.project_id ||= ticket.prefix_options[:project_id] if ticket
|
42
|
+
self.ticket_id = note.prefix_options[:story_id]
|
43
|
+
self.ticket_id ||= ticket.id if ticket
|
44
|
+
self.id = note.id
|
45
|
+
self.prefix_options = note.prefix_options
|
46
|
+
end
|
47
|
+
super(@system_data[:note])
|
48
|
+
end
|
49
|
+
|
50
|
+
def body
|
51
|
+
self.text
|
52
|
+
end
|
53
|
+
|
54
|
+
def body=(bod)
|
55
|
+
self.text = bod
|
56
|
+
end
|
57
|
+
|
58
|
+
def created_at
|
59
|
+
self.noted_at
|
60
|
+
end
|
61
|
+
|
62
|
+
def updated_at
|
63
|
+
self.noted_at
|
64
|
+
end
|
65
|
+
|
66
|
+
def project_id
|
67
|
+
self.project_id || @system_data[:client].prefix_options[:project_id]
|
68
|
+
end
|
69
|
+
|
70
|
+
def ticket_id
|
71
|
+
self.ticket_id || @system_data[:client].prefix_options[:story_id]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/provider/pivotal.rb
CHANGED
@@ -2,6 +2,8 @@ module TicketMaster::Provider
|
|
2
2
|
# This is the Pivotal Tracker Provider for ticketmaster
|
3
3
|
module Pivotal
|
4
4
|
include TicketMaster::Provider::Base
|
5
|
+
TICKET_API = PivotalAPI::Story
|
6
|
+
PROJECT_API = PivotalAPI::Project
|
5
7
|
|
6
8
|
# This is for cases when you want to instantiate using TicketMaster::Provider::Lighthouse.new(auth)
|
7
9
|
def self.new(auth = {})
|
@@ -19,68 +21,5 @@ module TicketMaster::Provider
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
# The projects
|
23
|
-
#
|
24
|
-
# We have to merge in the auth information because, due to the class-based authentication
|
25
|
-
# mechanism, if we don't reset the authorize information for every request, it would
|
26
|
-
# end up using whatever the previous instantiated object's account info is.
|
27
|
-
def projects(*options)
|
28
|
-
authorize
|
29
|
-
projects = if options.length > 0
|
30
|
-
Project.find(*options)
|
31
|
-
else
|
32
|
-
Project.find(:all)
|
33
|
-
end
|
34
|
-
set_master_data(projects)
|
35
|
-
end
|
36
|
-
|
37
|
-
# The project
|
38
|
-
def project(*options)
|
39
|
-
authorize
|
40
|
-
return set_master_data(Project.find(:first, *options)) if options.length > 0
|
41
|
-
Project
|
42
|
-
end
|
43
|
-
|
44
|
-
# The tickets
|
45
|
-
#
|
46
|
-
# Due to the nature of pivotal, we must have the project_id to pull tickets. You can
|
47
|
-
# pass in the id through this format:
|
48
|
-
#
|
49
|
-
# .tickets(22)
|
50
|
-
# .tickets(:project_id => 22)
|
51
|
-
#
|
52
|
-
# To conform to ticketmaster's standard of returning all tickets on a call to this method
|
53
|
-
# without any parameters, if no parameters are passed, it will return all tickets for whatever
|
54
|
-
# the first project is.
|
55
|
-
def tickets(*options)
|
56
|
-
authorize
|
57
|
-
arg = options.shift
|
58
|
-
tickets = if arg.nil?
|
59
|
-
Ticket.find
|
60
|
-
elsif arg.is_a?(Fixnum)
|
61
|
-
Ticket.find(:all, :params => {:project_id => arg})
|
62
|
-
elsif arg.is_a?(Hash)
|
63
|
-
Ticket.find(:all, :params => arg) if arg.is_a?(Hash)
|
64
|
-
else
|
65
|
-
[]
|
66
|
-
end
|
67
|
-
set_master_data(tickets)
|
68
|
-
end
|
69
|
-
|
70
|
-
# the ticket
|
71
|
-
def ticket(*options)
|
72
|
-
authorize
|
73
|
-
return set_master_data(Ticket.find(*options)) if options.length > 0
|
74
|
-
Ticket
|
75
|
-
end
|
76
|
-
|
77
|
-
def set_master_data(data)
|
78
|
-
if data.is_a?(Array)
|
79
|
-
data.collect! { |p| p.system_data.merge!(:master => self); p }
|
80
|
-
else
|
81
|
-
data.system_data.merge!(:master => self)
|
82
|
-
end
|
83
|
-
data
|
84
|
-
end
|
85
24
|
end
|
86
25
|
end
|
data/lib/provider/project.rb
CHANGED
@@ -4,6 +4,7 @@ module TicketMaster::Provider
|
|
4
4
|
#
|
5
5
|
#
|
6
6
|
class Project < TicketMaster::Provider::Base::Project
|
7
|
+
API = PivotalAPI::Project
|
7
8
|
# The finder method
|
8
9
|
#
|
9
10
|
# It accepts all the find functionalities defined by ticketmaster
|
@@ -16,81 +17,6 @@ module TicketMaster::Provider
|
|
16
17
|
alias_method :stories, :tickets
|
17
18
|
alias_method :story, :ticket
|
18
19
|
|
19
|
-
def self.find(*options)
|
20
|
-
first = options.shift
|
21
|
-
if first.nil? or first == :all
|
22
|
-
PivotalAPI::Project.find(:all).collect do |p|
|
23
|
-
self.new p
|
24
|
-
end
|
25
|
-
elsif first.is_a?(Fixnum)
|
26
|
-
self.new PivotalAPI::Project.find(first)
|
27
|
-
elsif first == :first
|
28
|
-
self.new self.search(options.shift || {}, 1).first
|
29
|
-
elsif first.is_a?(Hash)
|
30
|
-
self.search(first).collect { |p| self.new p }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# This is a helper method to find
|
35
|
-
def self.search(options = {}, limit = 1000)
|
36
|
-
projects = PivotalAPI::Project.find(:all)
|
37
|
-
projects.find_all do |p|
|
38
|
-
options.keys.reduce(true) do |memo, key|
|
39
|
-
p.send(key) == options[key] and (limit-=1) >= 0
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Create a project
|
45
|
-
def self.create(*options)
|
46
|
-
project = PivotalAPI::Project.new(options.shift)
|
47
|
-
project.save
|
48
|
-
self.new project
|
49
|
-
end
|
50
|
-
|
51
|
-
# The initializer
|
52
|
-
#
|
53
|
-
# A side effect of Hashie causes prefix_options to become an instance of TicketMaster::Provider::Pivotal::Project
|
54
|
-
def initialize(*options)
|
55
|
-
@system = :pivotal
|
56
|
-
@system_data = {}
|
57
|
-
first = options.shift
|
58
|
-
if first.is_a?(PivotalAPI::Project)
|
59
|
-
@system_data[:client] = first
|
60
|
-
@prefix_options = first.prefix_options
|
61
|
-
super(first.attributes)
|
62
|
-
else
|
63
|
-
super(first)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# All tickets for this project
|
68
|
-
def tickets(*options)
|
69
|
-
if options.length == 0
|
70
|
-
Ticket.find(:project_id => self.id)
|
71
|
-
else
|
72
|
-
first = options.first
|
73
|
-
if first.is_a?(Fixnum)
|
74
|
-
[Ticket.find(first, {:project_id => self.id})]
|
75
|
-
else
|
76
|
-
Ticket.find({:project_id => self.id}.merge(:q => options.first))
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# The ticket finder
|
82
|
-
# returns only one ticket
|
83
|
-
def ticket(*options)
|
84
|
-
first = options.shift
|
85
|
-
if first.nil?
|
86
|
-
return Ticket
|
87
|
-
elsif first.is_a?(Fixnum)
|
88
|
-
return Ticket.find(first, :project_id => self.id)
|
89
|
-
else
|
90
|
-
Ticket.find(:first, {:project_id => self.id}.merge(:q => first))
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
20
|
# Save this project
|
95
21
|
def save
|
96
22
|
warn 'Warning: Pivotal does not allow editing of project attributes. This method does nothing.'
|
data/lib/provider/ticket.rb
CHANGED
@@ -4,73 +4,7 @@ module TicketMaster::Provider
|
|
4
4
|
class Ticket < TicketMaster::Provider::Base::Ticket
|
5
5
|
@@allowed_states = ['new', 'open', 'resolved', 'hold', 'invalid']
|
6
6
|
attr_accessor :prefix_options
|
7
|
-
|
8
|
-
# The finder
|
9
|
-
#
|
10
|
-
# It tries to implement all the ticketmaster calls, but since the project id is required as the
|
11
|
-
# parent key, it doesnt really make sense to call find(:all) or find(##)
|
12
|
-
#
|
13
|
-
# * find(:all) - Returns an array of all tickets
|
14
|
-
# * find(##, ##) - Returns a ticket based on that id or some other primary (unique) attribute
|
15
|
-
# * find(:first, :summary => 'Ticket title') - Returns a ticket based on the ticket's attributes
|
16
|
-
# * find(:summary => 'Test Ticket') - Returns all tickets based on the given attributes
|
17
|
-
def self.find(*options)
|
18
|
-
first = options.shift
|
19
|
-
if first.nil? or first == :all
|
20
|
-
tickets = []
|
21
|
-
PivotalAPI::Project.find(:all).each do |p|
|
22
|
-
tickets |= p.stories
|
23
|
-
end
|
24
|
-
tickets.collect { |t| self.new t }
|
25
|
-
elsif first.is_a?(Fixnum)
|
26
|
-
second = options.shift
|
27
|
-
if second.is_a?(Fixnum)
|
28
|
-
self.new PivotalAPI::Story.find(first, :params => { :project_id => second })
|
29
|
-
elsif second.is_a?(Hash)
|
30
|
-
self.new PivotalAPI::Story.find(first, :params => qize(second))
|
31
|
-
end
|
32
|
-
elsif first == :first
|
33
|
-
self.new self.search(options.shift, 1).first
|
34
|
-
elsif first.is_a?(Hash)
|
35
|
-
self.search(first).collect do |t| self.new t end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.qize(params)
|
40
|
-
return params unless params[:filter] and params[:filter].is_a?(Hash)
|
41
|
-
q = ''
|
42
|
-
params[:filter].keys.each do |key|
|
43
|
-
value = params[:q][key]
|
44
|
-
value = "\"#{value}\"" if value.to_s.include?(' ')
|
45
|
-
q += "#{key}:#{value} "
|
46
|
-
end
|
47
|
-
params[:filter] = q
|
48
|
-
params
|
49
|
-
end
|
50
|
-
|
51
|
-
# The find helper
|
52
|
-
def self.search(options, limit = 1000)
|
53
|
-
tickets = PivotalAPI::Story.find(:all, :params => ({:project_id => (options.delete(:project_id) || options.delete('project_id')).to_i}.merge(qize(:filter => options))))
|
54
|
-
tickets.find_all do |t|
|
55
|
-
options.keys.reduce(true) do |memo, key|
|
56
|
-
t.send(key) == options[key] and (limit-=1) > 0
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# The initializer
|
62
|
-
def initialize(*options)
|
63
|
-
@system = :pivotal
|
64
|
-
@system_data = {}
|
65
|
-
first = options.shift
|
66
|
-
if first.is_a?(PivotalAPI::Story)
|
67
|
-
@system_data[:client] = first
|
68
|
-
@prefix_options = first.prefix_options
|
69
|
-
super(first.attributes)
|
70
|
-
else
|
71
|
-
super(first)
|
72
|
-
end
|
73
|
-
end
|
7
|
+
API = PivotalAPI::Story
|
74
8
|
|
75
9
|
# The creator
|
76
10
|
def self.create(*options)
|
@@ -95,6 +29,10 @@ module TicketMaster::Provider
|
|
95
29
|
@system_data[:client].destroy.is_a?(Net::HTTPOK)
|
96
30
|
end
|
97
31
|
|
32
|
+
def project_id
|
33
|
+
self.prefix_options[:project_id]
|
34
|
+
end
|
35
|
+
|
98
36
|
# The closer
|
99
37
|
def close(resolution = 'resolved')
|
100
38
|
resolution = 'resolved' unless @@allowed_states.include?(resolution)
|
data/lib/ticketmaster-pivotal.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ticketmaster-pivotal}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["HybridGroup"]
|
12
|
+
s.date = %q{2010-07-03}
|
13
|
+
s.description = %q{This is a ticketmaster provider for interacting with Pivotal Tracker .}
|
14
|
+
s.email = %q{hong.quach@abigfisch.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/pivotal/pivotal-api.rb",
|
27
|
+
"lib/provider/comment.rb",
|
28
|
+
"lib/provider/pivotal.rb",
|
29
|
+
"lib/provider/project.rb",
|
30
|
+
"lib/provider/ticket.rb",
|
31
|
+
"lib/ticketmaster-pivotal.rb",
|
32
|
+
"spec/spec.opts",
|
33
|
+
"spec/spec_helper.rb",
|
34
|
+
"spec/ticketmaster-pivotal_spec.rb",
|
35
|
+
"ticketmaster-pivotal.gemspec"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://ticket.rb}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
41
|
+
s.summary = %q{This is a ticketmaster provider for interacting with Pivotal Tracker}
|
42
|
+
s.test_files = [
|
43
|
+
"spec/spec_helper.rb",
|
44
|
+
"spec/ticketmaster-pivotal_spec.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
|
54
|
+
s.add_runtime_dependency(%q<activeresource>, [">= 2.3.2"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
58
|
+
s.add_dependency(%q<activeresource>, [">= 2.3.2"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
63
|
+
s.add_dependency(%q<activeresource>, [">= 2.3.2"])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ticketmaster-pivotal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 2
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.1
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- HybridGroup
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-07-03 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- Rakefile
|
84
84
|
- VERSION
|
85
85
|
- lib/pivotal/pivotal-api.rb
|
86
|
+
- lib/provider/comment.rb
|
86
87
|
- lib/provider/pivotal.rb
|
87
88
|
- lib/provider/project.rb
|
88
89
|
- lib/provider/ticket.rb
|
@@ -90,6 +91,7 @@ files:
|
|
90
91
|
- spec/spec.opts
|
91
92
|
- spec/spec_helper.rb
|
92
93
|
- spec/ticketmaster-pivotal_spec.rb
|
94
|
+
- ticketmaster-pivotal.gemspec
|
93
95
|
has_rdoc: true
|
94
96
|
homepage: http://ticket.rb
|
95
97
|
licenses: []
|