ticketmaster-lighthouse 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.md +47 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/lib/lighthouse/LICENSE +20 -0
- data/lib/lighthouse/README.markdown +5 -0
- data/lib/lighthouse/lighthouse-api.rb +359 -0
- data/lib/provider/authenticator.rb +4 -0
- data/lib/provider/project.rb +48 -0
- data/lib/provider/ticket.rb +34 -0
- data/lib/ticketmaster-lighthouse.rb +6 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/ticketmaster-lighthouse_spec.rb +7 -0
- data/ticketmaster-lighthouse.gemspec +70 -0
- metadata +148 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 HybridGroup
|
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.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# ticketmaster-lighthouse
|
2
|
+
|
3
|
+
This is a provider for [ticketmaster](http://ticketrb.com). It provides interoperability with (Lighthouse)[http://www.lighthouseapp.com/] through the ticketmaster gem.
|
4
|
+
|
5
|
+
# Usage and Examples
|
6
|
+
|
7
|
+
First we have to instantiate a new ticketmaster instance:
|
8
|
+
lighthouse = TicketMaster.new(:lighthouse, {:subdomain => "rails"})
|
9
|
+
lighthouse = TicketMaster.new(:lighthouse, {:username => "code", :password => "m4st3r!", :account => "ticketmaster"})
|
10
|
+
lighthouse = TicketMaster.new(:lighthouse, {:token => "5ff546af3df4a3c02d3a719b0ff1c3fcc5351c97", :account => "lhdemo"})
|
11
|
+
|
12
|
+
The :account is the name of the account which should be the same as the subdomain used to access the account's projects. For you convenience, you can also pass in :subdomain in place of :account. If you pass in both, it'll use the :account value. If you do not pass in the token or both the username and password, it will only access public information for the account.
|
13
|
+
|
14
|
+
Tokens allow access to a specific project or account without having to give out your login credentials. It can be nullified if necessary. I highly suggest you use tokens. For more information, please see Lighthouse's FAQ (How do I get an API token?)[http://help.lighthouseapp.com/faqs/api/how-do-i-get-an-api-token]
|
15
|
+
|
16
|
+
== Finding Projects
|
17
|
+
|
18
|
+
project = lighthouse.project
|
19
|
+
|
20
|
+
## Requirements
|
21
|
+
|
22
|
+
* rubygems (obviously)
|
23
|
+
* ticketmaster gem (latest version preferred)
|
24
|
+
* jeweler gem (only if you want to repackage and develop)
|
25
|
+
|
26
|
+
The ticketmaster gem should automatically be installed during the installation of this gem if it is not already installed.
|
27
|
+
|
28
|
+
## Other Notes
|
29
|
+
|
30
|
+
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.
|
31
|
+
|
32
|
+
If you see or find any issues, feel free to open up an issue report.
|
33
|
+
|
34
|
+
|
35
|
+
## Note on Patches/Pull Requests
|
36
|
+
|
37
|
+
* Fork the project.
|
38
|
+
* Make your feature addition or bug fix.
|
39
|
+
* Add tests for it. This is important so I don't break it in a
|
40
|
+
future version unintentionally.
|
41
|
+
* Commit, do not mess with rakefile, version, or history.
|
42
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
43
|
+
* Send me a pull request. Bonus points for topic branches.
|
44
|
+
|
45
|
+
## Copyright
|
46
|
+
|
47
|
+
Copyright (c) 2010 HybridGroup. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ticketmaster-lighthouse"
|
8
|
+
gem.summary = %Q{Ticketmaster Provider for Lighthouse}
|
9
|
+
gem.description = %Q{Allows ticketmaster to interact with Lighthouse's issue tracking system.}
|
10
|
+
gem.email = "hong.quach@abigfisch.com"
|
11
|
+
gem.homepage = "http://github.com/kiafaldorius/ticketmaster-lighthouse"
|
12
|
+
gem.authors = ["Hong"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_dependency "activesupport", ">= 2.3.2"
|
15
|
+
gem.add_dependency "activeresource", ">= 2.3.2"
|
16
|
+
gem.add_dependency "addressable", ">= 2.1.2"
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'spec/rake/spectask'
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
+
end
|
29
|
+
|
30
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
spec.rcov = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :spec => :check_dependencies
|
37
|
+
|
38
|
+
task :default => :spec
|
39
|
+
|
40
|
+
require 'rake/rdoctask'
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "ticketmaster-lighthouse #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 HybridGroup
|
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,359 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'uri'
|
5
|
+
require 'addressable/uri'
|
6
|
+
|
7
|
+
module URI
|
8
|
+
def decode(*args)
|
9
|
+
Addressable::URI.decode(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def escape(*args)
|
13
|
+
Addressable::URI.escape(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse(*args)
|
17
|
+
Addressable::URI.parse(*args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
rescue LoadError => e
|
21
|
+
puts "Install the Addressable gem (with dependencies) to support accounts with subdomains."
|
22
|
+
puts "# sudo gem install addressable --development"
|
23
|
+
puts e.message
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'active_support'
|
27
|
+
require 'active_resource'
|
28
|
+
|
29
|
+
# Ruby lib for working with the Lighthouse API's XML interface.
|
30
|
+
# The first thing you need to set is the account name. This is the same
|
31
|
+
# as the web address for your account.
|
32
|
+
#
|
33
|
+
# LighthouseAPI.account = 'activereload'
|
34
|
+
#
|
35
|
+
# Then, you should set the authentication. You can either use your login
|
36
|
+
# credentials with HTTP Basic Authentication or with an API Tokens. You can
|
37
|
+
# find more info on tokens at http://lighthouseapp.com/help/using-beacons.
|
38
|
+
#
|
39
|
+
# # with basic authentication
|
40
|
+
# LighthouseAPI.authenticate('rick@techno-weenie.net', 'spacemonkey')
|
41
|
+
#
|
42
|
+
# # or, use a token
|
43
|
+
# LighthouseAPI.token = 'abcdefg'
|
44
|
+
#
|
45
|
+
# If no token or authentication info is given, you'll only be granted public access.
|
46
|
+
#
|
47
|
+
# This library is a small wrapper around the REST interface. You should read the docs at
|
48
|
+
# http://lighthouseapp.com/api.
|
49
|
+
#
|
50
|
+
module LighthouseAPI
|
51
|
+
class Error < StandardError; end
|
52
|
+
class << self
|
53
|
+
attr_accessor :email, :password, :host_format, :domain_format, :protocol, :port
|
54
|
+
attr_reader :account, :token
|
55
|
+
|
56
|
+
# Sets the account name, and updates all the resources with the new domain.
|
57
|
+
def account=(name)
|
58
|
+
resources.each do |klass|
|
59
|
+
klass.site = klass.site_format % (host_format % [protocol, domain_format % name, ":#{port}"])
|
60
|
+
end
|
61
|
+
@account = name
|
62
|
+
end
|
63
|
+
|
64
|
+
# Sets up basic authentication credentials for all the resources.
|
65
|
+
def authenticate(email, password)
|
66
|
+
@email = email
|
67
|
+
@password = password
|
68
|
+
self::Base.user = email
|
69
|
+
self::Base.password = password
|
70
|
+
end
|
71
|
+
|
72
|
+
# Sets the API token for all the resources.
|
73
|
+
def token=(value)
|
74
|
+
resources.each do |klass|
|
75
|
+
klass.headers['X-LighthouseToken'] = value
|
76
|
+
end
|
77
|
+
@token = value
|
78
|
+
end
|
79
|
+
|
80
|
+
def resources
|
81
|
+
@resources ||= []
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
self.host_format = '%s://%s%s'
|
86
|
+
self.domain_format = '%s.lighthouseapp.com'
|
87
|
+
self.protocol = 'http'
|
88
|
+
self.port = ''
|
89
|
+
|
90
|
+
class Base < ActiveResource::Base
|
91
|
+
def self.inherited(base)
|
92
|
+
LighthouseAPI.resources << base
|
93
|
+
class << base
|
94
|
+
attr_accessor :site_format
|
95
|
+
end
|
96
|
+
base.site_format = '%s'
|
97
|
+
super
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Find projects
|
102
|
+
#
|
103
|
+
# LighthouseAPI::Project.find(:all) # find all projects for the current account.
|
104
|
+
# LighthouseAPI::Project.find(44) # find individual project by ID
|
105
|
+
#
|
106
|
+
# Creating a Project
|
107
|
+
#
|
108
|
+
# project = LighthouseAPI::Project.new(:name => 'Ninja Whammy Jammy')
|
109
|
+
# project.save
|
110
|
+
# # => true
|
111
|
+
#
|
112
|
+
# Creating an OSS project
|
113
|
+
#
|
114
|
+
# project = LighthouseAPI::Project.new(:name => 'OSS Project')
|
115
|
+
# project.access = 'oss'
|
116
|
+
# project.license = 'mit'
|
117
|
+
# project.save
|
118
|
+
#
|
119
|
+
# OSS License Mappings
|
120
|
+
#
|
121
|
+
# 'mit' => "MIT License",
|
122
|
+
# 'apache-2-0' => "Apache License 2.0",
|
123
|
+
# 'artistic-gpl-2' => "Artistic License/GPLv2",
|
124
|
+
# 'gpl-2' => "GNU General Public License v2",
|
125
|
+
# 'gpl-3' => "GNU General Public License v3",
|
126
|
+
# 'lgpl' => "GNU Lesser General Public License"
|
127
|
+
# 'mozilla-1-1' => "Mozilla Public License 1.1"
|
128
|
+
# 'new-bsd' => "New BSD License",
|
129
|
+
# 'afl-3' => "Academic Free License v. 3.0"
|
130
|
+
|
131
|
+
#
|
132
|
+
# Updating a Project
|
133
|
+
#
|
134
|
+
# project = LighthouseAPI::Project.find(44)
|
135
|
+
# project.name = "Lighthouse Issues"
|
136
|
+
# project.public = false
|
137
|
+
# project.save
|
138
|
+
#
|
139
|
+
# Finding tickets
|
140
|
+
#
|
141
|
+
# project = LighthouseAPI::Project.find(44)
|
142
|
+
# project.tickets
|
143
|
+
#
|
144
|
+
class Project < Base
|
145
|
+
def tickets(options = {})
|
146
|
+
Ticket.find(:all, :params => options.update(:project_id => id))
|
147
|
+
end
|
148
|
+
|
149
|
+
def messages(options = {})
|
150
|
+
Message.find(:all, :params => options.update(:project_id => id))
|
151
|
+
end
|
152
|
+
|
153
|
+
def milestones(options = {})
|
154
|
+
Milestone.find(:all, :params => options.update(:project_id => id))
|
155
|
+
end
|
156
|
+
|
157
|
+
def bins(options = {})
|
158
|
+
Bin.find(:all, :params => options.update(:project_id => id))
|
159
|
+
end
|
160
|
+
|
161
|
+
def changesets(options = {})
|
162
|
+
Changeset.find(:all, :params => options.update(:project_id => id))
|
163
|
+
end
|
164
|
+
|
165
|
+
def memberships(options = {})
|
166
|
+
ProjectMembership.find(:all, :params => options.update(:project_id => id))
|
167
|
+
end
|
168
|
+
|
169
|
+
def tags(options = {})
|
170
|
+
TagResource.find(:all, :params => options.update(:project_id => id))
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class User < Base
|
175
|
+
def memberships(options = {})
|
176
|
+
Membership.find(:all, :params => {:user_id => id})
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
class Membership < Base
|
181
|
+
site_format << '/users/:user_id'
|
182
|
+
def save
|
183
|
+
raise Error, "Cannot modify memberships from the API"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
class ProjectMembership < Base
|
188
|
+
self.element_name = 'membership'
|
189
|
+
site_format << '/projects/:project_id'
|
190
|
+
|
191
|
+
def url
|
192
|
+
respond_to?(:account) ? account : project
|
193
|
+
end
|
194
|
+
|
195
|
+
def save
|
196
|
+
raise Error, "Cannot modify memberships from the API"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class Token < Base
|
201
|
+
def save
|
202
|
+
raise Error, "Cannot modify Tokens from the API"
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# Find tickets
|
207
|
+
#
|
208
|
+
# LighthouseAPI::Ticket.find(:all, :params => { :project_id => 44 })
|
209
|
+
# LighthouseAPI::Ticket.find(:all, :params => { :project_id => 44, :q => "state:closed tagged:committed" })
|
210
|
+
#
|
211
|
+
# project = LighthouseAPI::Project.find(44)
|
212
|
+
# project.tickets
|
213
|
+
# project.tickets(:q => "state:closed tagged:committed")
|
214
|
+
#
|
215
|
+
# Creating a Ticket
|
216
|
+
#
|
217
|
+
# ticket = LighthouseAPI::Ticket.new(:project_id => 44)
|
218
|
+
# ticket.title = 'asdf'
|
219
|
+
# ...
|
220
|
+
# ticket.tags << 'ruby' << 'rails' << '@high'
|
221
|
+
# ticket.save
|
222
|
+
#
|
223
|
+
# Updating a Ticket
|
224
|
+
#
|
225
|
+
# ticket = LighthouseAPI::Ticket.find(20, :params => { :project_id => 44 })
|
226
|
+
# ticket.state = 'resolved'
|
227
|
+
# ticket.tags.delete '@high'
|
228
|
+
# ticket.save
|
229
|
+
#
|
230
|
+
class Ticket < Base
|
231
|
+
attr_writer :tags
|
232
|
+
site_format << '/projects/:project_id'
|
233
|
+
|
234
|
+
def id
|
235
|
+
attributes['number'] ||= nil
|
236
|
+
number
|
237
|
+
end
|
238
|
+
|
239
|
+
def tags
|
240
|
+
attributes['tag'] ||= nil
|
241
|
+
@tags ||= tag.blank? ? [] : parse_with_spaces(tag)
|
242
|
+
end
|
243
|
+
|
244
|
+
def body
|
245
|
+
attributes['body'] ||= ''
|
246
|
+
end
|
247
|
+
|
248
|
+
def body=(value)
|
249
|
+
attributes['body'] = value
|
250
|
+
end
|
251
|
+
|
252
|
+
def body_html
|
253
|
+
attributes['body_html'] ||= ''
|
254
|
+
end
|
255
|
+
|
256
|
+
def body_html=(value)
|
257
|
+
attributes['body_html'] = value
|
258
|
+
end
|
259
|
+
|
260
|
+
def save_with_tags
|
261
|
+
self.tag = @tags.collect do |tag|
|
262
|
+
tag.include?(' ') ? tag.inspect : tag
|
263
|
+
end.join(" ") if @tags.is_a?(Array)
|
264
|
+
@tags = nil ; save_without_tags
|
265
|
+
end
|
266
|
+
|
267
|
+
alias_method_chain :save, :tags
|
268
|
+
|
269
|
+
private
|
270
|
+
# taken from Lighthouse Tag code
|
271
|
+
def parse_with_spaces(list)
|
272
|
+
tags = []
|
273
|
+
|
274
|
+
# first, pull out the quoted tags
|
275
|
+
list.gsub!(/\"(.*?)\"\s*/ ) { tags << $1; "" }
|
276
|
+
|
277
|
+
# then, get whatever's left
|
278
|
+
tags.concat list.split(/\s/)
|
279
|
+
|
280
|
+
cleanup_tags(tags)
|
281
|
+
end
|
282
|
+
|
283
|
+
def cleanup_tags(tags)
|
284
|
+
returning tags do |tag|
|
285
|
+
tag.collect! do |t|
|
286
|
+
unless tag.blank?
|
287
|
+
t = Tag.new(t,prefix_options[:project_id])
|
288
|
+
t.downcase!
|
289
|
+
t.gsub! /(^')|('$)/, ''
|
290
|
+
t.gsub! /[^a-z0-9 \-_@\!']/, ''
|
291
|
+
t.strip!
|
292
|
+
t.prefix_options = prefix_options
|
293
|
+
t
|
294
|
+
end
|
295
|
+
end
|
296
|
+
tag.compact!
|
297
|
+
tag.uniq!
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
class Message < Base
|
303
|
+
site_format << '/projects/:project_id'
|
304
|
+
end
|
305
|
+
|
306
|
+
class Milestone < Base
|
307
|
+
site_format << '/projects/:project_id'
|
308
|
+
|
309
|
+
def tickets(options = {})
|
310
|
+
Ticket.find(:all, :params => options.merge(prefix_options).update(:q => %{milestone:"#{title}"}))
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
class Bin < Base
|
315
|
+
site_format << '/projects/:project_id'
|
316
|
+
|
317
|
+
def tickets(options = {})
|
318
|
+
Ticket.find(:all, :params => options.merge(prefix_options).update(:q => query))
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
class Changeset < Base
|
323
|
+
site_format << '/projects/:project_id'
|
324
|
+
end
|
325
|
+
|
326
|
+
class Change < Array; end
|
327
|
+
|
328
|
+
class TagResource < Base
|
329
|
+
self.element_name = 'tag'
|
330
|
+
site_format << '/projects/:project_id'
|
331
|
+
|
332
|
+
def name
|
333
|
+
@name ||= Tag.new(attributes['name'], prefix_options[:project_id])
|
334
|
+
end
|
335
|
+
|
336
|
+
def tickets(options = {})
|
337
|
+
name.tickets(options)
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
class Tag < String
|
342
|
+
attr_writer :prefix_options
|
343
|
+
attr_accessor :project_id
|
344
|
+
|
345
|
+
def initialize(s, project_id)
|
346
|
+
@project_id = project_id
|
347
|
+
super(s)
|
348
|
+
end
|
349
|
+
|
350
|
+
def prefix_options
|
351
|
+
@prefix_options || {}
|
352
|
+
end
|
353
|
+
|
354
|
+
def tickets(options = {})
|
355
|
+
options[:project_id] ||= @project_id
|
356
|
+
Ticket.find(:all, :params => options.merge(prefix_options).update(:q => %{tagged:"#{self}"}))
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module TicketMasterMod
|
2
|
+
module Lighthouse
|
3
|
+
class Project
|
4
|
+
def self.find(query, options = {})
|
5
|
+
self.authenticate(options[:authentication]) if options[:authentication]
|
6
|
+
projects = LighthouseAPI::Project.find :all # Kernel::Lighthouse::Project.find query
|
7
|
+
formatted_projects = []
|
8
|
+
|
9
|
+
unless projects.empty?
|
10
|
+
projects.each do |project|
|
11
|
+
attributes = {:system => "lighthouse", :authentication => options[:authentication],
|
12
|
+
:system_data => {:project => project}}
|
13
|
+
attributes.merge!(project.attributes)
|
14
|
+
formatted_projects << TicketMasterMod::Project.new(attributes)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
formatted_projects
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.authenticate(auth)
|
22
|
+
LighthouseAPI.account = auth.account || auth.subdomain
|
23
|
+
if auth.token
|
24
|
+
LighthouseAPI.token = auth.token
|
25
|
+
elsif auth.username && auth.password
|
26
|
+
LighthouseAPI.authenticate(auth.username, auth.password)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.tickets(project_instance)
|
31
|
+
self.authenticate(project_instance.authentication)
|
32
|
+
tickets = project_instance.system_data[:project].tickets
|
33
|
+
formatted_tickets = []
|
34
|
+
|
35
|
+
unless tickets.empty?
|
36
|
+
tickets.each do |ticket|
|
37
|
+
attributes = {:system => 'lighthouse', :project => project_instance,
|
38
|
+
:system_data => {:project => project_instance.system_data[:project], :ticket => ticket}}
|
39
|
+
attributes.merge!(ticket.attributes)
|
40
|
+
formatted_tickets << TicketMasterMod::Ticket.new(attributes)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
formatted_tickets
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module TicketMasterMod
|
2
|
+
module Lighthouse
|
3
|
+
class Ticket
|
4
|
+
# This is an exhaustive list, but should contain the most common ones, add as necessary
|
5
|
+
@@allowed_attributes = ["number", "permalink", "milestone_id", "created_at", "title", "closed", "updated_at", "raw_data", "priority", "tag", "url", "attachments_count", "creator_id", "milestone_due_on", "original_body_html", "user_id", "user_name", "original_body", "latest_body", "assigned_user_id", "creator_name", "state"]
|
6
|
+
def self.create(ticket)
|
7
|
+
ticket_attr = ticket.to_hash.delete_if { |k, v| !@@allowed_attributes.include?(k) }
|
8
|
+
project = ticket.project.system_data[:project]
|
9
|
+
new_ticket = LighthouseAPI::Ticket.new(:project_id => ticket.project.id)
|
10
|
+
ticket_attr.each do |k, v|
|
11
|
+
new_ticket.send(k + '=', v)
|
12
|
+
end
|
13
|
+
new_ticket.save
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.save(ticket)
|
17
|
+
ticket_attr = ticket.to_hash.delete_if { |k, v| !@@allowed_attributes.include?(k) || ticket.system_data[:ticket].send(k) == v }
|
18
|
+
project = ticket.project.system_data[:project]
|
19
|
+
lh_ticket = ticket.system_data[:ticket]
|
20
|
+
ticket_attr.each do |k, v|
|
21
|
+
lh_ticket.send(k + '=', v)
|
22
|
+
end
|
23
|
+
lh_ticket.save
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.close(ticket, resolution)
|
27
|
+
project = ticket.project.system_data[:project]
|
28
|
+
ticket = LighthouseAPI::Ticket.find(ticket.id, :params => {:project_id => ticket.project.id})
|
29
|
+
ticket.state = resolution
|
30
|
+
ticket.save
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,70 @@
|
|
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-lighthouse}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Hong"]
|
12
|
+
s.date = %q{2010-06-14}
|
13
|
+
s.description = %q{Allows ticketmaster to interact with Lighthouse's issue tracking system.}
|
14
|
+
s.email = %q{hong.quach@abigfisch.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/lighthouse/LICENSE",
|
27
|
+
"lib/lighthouse/README.markdown",
|
28
|
+
"lib/lighthouse/lighthouse-api.rb",
|
29
|
+
"lib/provider/authenticator.rb",
|
30
|
+
"lib/provider/project.rb",
|
31
|
+
"lib/provider/ticket.rb",
|
32
|
+
"lib/ticketmaster-lighthouse.rb",
|
33
|
+
"spec/spec.opts",
|
34
|
+
"spec/spec_helper.rb",
|
35
|
+
"spec/ticketmaster-lighthouse_spec.rb",
|
36
|
+
"ticketmaster-lighthouse.gemspec"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/kiafaldorius/ticketmaster-lighthouse}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.7}
|
42
|
+
s.summary = %q{Ticketmaster Provider for Lighthouse}
|
43
|
+
s.test_files = [
|
44
|
+
"spec/spec_helper.rb",
|
45
|
+
"spec/ticketmaster-lighthouse_spec.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
54
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
|
55
|
+
s.add_runtime_dependency(%q<activeresource>, [">= 2.3.2"])
|
56
|
+
s.add_runtime_dependency(%q<addressable>, [">= 2.1.2"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
59
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
60
|
+
s.add_dependency(%q<activeresource>, [">= 2.3.2"])
|
61
|
+
s.add_dependency(%q<addressable>, [">= 2.1.2"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
65
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
66
|
+
s.add_dependency(%q<activeresource>, [">= 2.3.2"])
|
67
|
+
s.add_dependency(%q<addressable>, [">= 2.1.2"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ticketmaster-lighthouse
|
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
|
+
- Hong
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-14 00:00:00 -07: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: activesupport
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 7
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 3
|
49
|
+
- 2
|
50
|
+
version: 2.3.2
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: activeresource
|
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: addressable
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 15
|
78
|
+
segments:
|
79
|
+
- 2
|
80
|
+
- 1
|
81
|
+
- 2
|
82
|
+
version: 2.1.2
|
83
|
+
type: :runtime
|
84
|
+
version_requirements: *id004
|
85
|
+
description: Allows ticketmaster to interact with Lighthouse's issue tracking system.
|
86
|
+
email: hong.quach@abigfisch.com
|
87
|
+
executables: []
|
88
|
+
|
89
|
+
extensions: []
|
90
|
+
|
91
|
+
extra_rdoc_files:
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
files:
|
95
|
+
- .document
|
96
|
+
- .gitignore
|
97
|
+
- LICENSE
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- lib/lighthouse/LICENSE
|
102
|
+
- lib/lighthouse/README.markdown
|
103
|
+
- lib/lighthouse/lighthouse-api.rb
|
104
|
+
- lib/provider/authenticator.rb
|
105
|
+
- lib/provider/project.rb
|
106
|
+
- lib/provider/ticket.rb
|
107
|
+
- lib/ticketmaster-lighthouse.rb
|
108
|
+
- spec/spec.opts
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
- spec/ticketmaster-lighthouse_spec.rb
|
111
|
+
- ticketmaster-lighthouse.gemspec
|
112
|
+
has_rdoc: true
|
113
|
+
homepage: http://github.com/kiafaldorius/ticketmaster-lighthouse
|
114
|
+
licenses: []
|
115
|
+
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options:
|
118
|
+
- --charset=UTF-8
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
139
|
+
requirements: []
|
140
|
+
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 1.3.7
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: Ticketmaster Provider for Lighthouse
|
146
|
+
test_files:
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
- spec/ticketmaster-lighthouse_spec.rb
|