ticketmaster-lighthouse 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/provider/comment.rb +5 -3
- data/lib/provider/lighthouse.rb +5 -5
- data/lib/provider/project.rb +1 -1
- data/lib/provider/ticket.rb +3 -2
- data/lib/ticketmaster-lighthouse.rb +27 -1
- data/spec/tickets_spec.rb +1 -5
- data/ticketmaster-lighthouse.gemspec +5 -5
- metadata +21 -9
- data/lib/lighthouse/LICENSE +0 -20
- data/lib/lighthouse/README.markdown +0 -5
- data/lib/lighthouse/lighthouse-api.rb +0 -359
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -14,6 +14,7 @@ begin
|
|
14
14
|
gem.add_dependency "ticketmaster", ">= 0.3.0"
|
15
15
|
gem.add_dependency "activesupport", ">= 2.3.2"
|
16
16
|
gem.add_dependency "activeresource", ">= 2.3.2"
|
17
|
+
gem.add_dependency "lighthouse-api", "~> 2.0"
|
17
18
|
gem.add_dependency "addressable", ">= 2.1.2"
|
18
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
20
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/provider/comment.rb
CHANGED
@@ -13,13 +13,13 @@ module TicketMaster::Provider
|
|
13
13
|
# * ticket_id => number (read-only)
|
14
14
|
# * project_id => (set by the initializer)
|
15
15
|
class Comment < TicketMaster::Provider::Base::Comment
|
16
|
-
API =
|
16
|
+
API = ::Lighthouse::Ticket
|
17
17
|
|
18
18
|
# A custom find_by_id
|
19
19
|
# The "comment" id is it's index in the versions array. An id of 0 therefore exists and
|
20
20
|
# should be the first ticket (original)
|
21
21
|
def self.find_by_id(project_id, ticket_id, id)
|
22
|
-
self.new
|
22
|
+
self.new API.find(ticket_id, :params => {:project_id => project_id}), id
|
23
23
|
end
|
24
24
|
|
25
25
|
# A custom find_by_attributes
|
@@ -49,7 +49,9 @@ module TicketMaster::Provider
|
|
49
49
|
attributes.each do |k, v|
|
50
50
|
ticket.send("#{k}=", v)
|
51
51
|
end
|
52
|
+
versions = ticket.attributes.delete('versions')
|
52
53
|
ticket.save
|
54
|
+
ticket.attributes['versions'] = versions
|
53
55
|
self.find_by_id project_id, ticket_id, ticket.versions.length
|
54
56
|
end
|
55
57
|
|
@@ -66,7 +68,7 @@ module TicketMaster::Provider
|
|
66
68
|
#
|
67
69
|
# It returns a custom result because we need the original ticket to make a comment.
|
68
70
|
def self.search(project_id, ticket_id, options = {}, limit = 1000)
|
69
|
-
ticket =
|
71
|
+
ticket = API.find(ticket_id, :params => {:project_id => project_id})
|
70
72
|
comments = ticket.versions
|
71
73
|
[search_by_attribute(comments, options, limit), ticket]
|
72
74
|
end
|
data/lib/provider/lighthouse.rb
CHANGED
@@ -2,8 +2,8 @@ module TicketMaster::Provider
|
|
2
2
|
# This is the Lighthouse Provider for ticketmaster
|
3
3
|
module Lighthouse
|
4
4
|
include TicketMaster::Provider::Base
|
5
|
-
PROJECT_API =
|
6
|
-
TICKET_API =
|
5
|
+
PROJECT_API = ::Lighthouse::Project
|
6
|
+
TICKET_API = ::Lighthouse::Ticket
|
7
7
|
|
8
8
|
# This is for cases when you want to instantiate using TicketMaster::Provider::Lighthouse.new(auth)
|
9
9
|
def self.new(auth = {})
|
@@ -17,11 +17,11 @@ module TicketMaster::Provider
|
|
17
17
|
if auth.account.nil? or (auth.token.nil? and (auth.username.nil? and auth.password.nil?))
|
18
18
|
raise "Please provide at least an account (subdomain) and token or username and password)"
|
19
19
|
end
|
20
|
-
|
20
|
+
::Lighthouse.account = auth.account || auth.subdomain
|
21
21
|
if auth.token
|
22
|
-
|
22
|
+
::Lighthouse.token = auth.token
|
23
23
|
elsif auth.username && auth.password
|
24
|
-
|
24
|
+
::Lighthouse.authenticate(auth.username, auth.password)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/provider/project.rb
CHANGED
data/lib/provider/ticket.rb
CHANGED
@@ -29,7 +29,7 @@ module TicketMaster::Provider
|
|
29
29
|
class Ticket < TicketMaster::Provider::Base::Ticket
|
30
30
|
@@allowed_states = ['new', 'open', 'resolved', 'hold', 'invalid']
|
31
31
|
attr_accessor :prefix_options
|
32
|
-
API =
|
32
|
+
API = ::Lighthouse::Ticket
|
33
33
|
|
34
34
|
# This is to get the ticket id
|
35
35
|
# We can't set ids, so there's no 'id=' method.
|
@@ -105,6 +105,7 @@ module TicketMaster::Provider
|
|
105
105
|
# t = "\"#{t}\"" if t.include?(' ')
|
106
106
|
# mem << t
|
107
107
|
# end.join(' ') if @tags
|
108
|
+
@system_data[:client].attributes.delete('versions')
|
108
109
|
result = super
|
109
110
|
body = nil
|
110
111
|
@system_data[:client].body = nil
|
@@ -114,7 +115,7 @@ module TicketMaster::Provider
|
|
114
115
|
# The closer
|
115
116
|
def close(resolution = 'resolved')
|
116
117
|
resolution = 'resolved' unless @@allowed_states.include?(resolution)
|
117
|
-
ticket =
|
118
|
+
ticket = ::Lighthouse::Ticket.find(self.id, :params => {:project_id => self.prefix_options[:project_id]})
|
118
119
|
ticket.state = resolution
|
119
120
|
ticket.save
|
120
121
|
end
|
@@ -1,4 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require 'lighthouse-api'
|
2
|
+
|
3
|
+
# Monkey Patch - remove when the lighthouse gem gets updated.
|
4
|
+
# texel's changes got merged, but looks like a new gem didn't get released. ugh!
|
5
|
+
module Lighthouse
|
6
|
+
class Ticket
|
7
|
+
protected
|
8
|
+
def cleanup_tags(tags)
|
9
|
+
tags.tap do |tag|
|
10
|
+
tag.collect! do |t|
|
11
|
+
unless tag.blank?
|
12
|
+
t = Tag.new(t,prefix_options[:project_id])
|
13
|
+
t.downcase!
|
14
|
+
t.gsub! /(^')|('$)/, ''
|
15
|
+
t.gsub! /[^a-z0-9 \-_@\!']/, ''
|
16
|
+
t.strip!
|
17
|
+
t.prefix_options = prefix_options
|
18
|
+
t
|
19
|
+
end
|
20
|
+
end
|
21
|
+
tag.compact!
|
22
|
+
tag.uniq!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
2
28
|
|
3
29
|
%w{ lighthouse ticket project comment }.each do |f|
|
4
30
|
require File.dirname(__FILE__) + '/provider/' + f + '.rb';
|
data/spec/tickets_spec.rb
CHANGED
@@ -59,11 +59,7 @@ describe "Ticketmaster::Provider::Lighthouse::Ticket" do
|
|
59
59
|
@ticket = @project.ticket(5)
|
60
60
|
@ticket.save.should == nil
|
61
61
|
@ticket.description = 'hello'
|
62
|
-
|
63
|
-
@ticket.save.should == true
|
64
|
-
rescue Exception => e
|
65
|
-
raise e.backtrace.join("\n")
|
66
|
-
end
|
62
|
+
@ticket.save.should be_true
|
67
63
|
end
|
68
64
|
|
69
65
|
it "should be able to create a ticket" do
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ticketmaster-lighthouse}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hong"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-22}
|
13
13
|
s.description = %q{Allows ticketmaster to interact with Lighthouse's issue tracking system.}
|
14
14
|
s.email = %q{hong.quach@abigfisch.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,9 +23,6 @@ Gem::Specification.new do |s|
|
|
23
23
|
"README.md",
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
|
-
"lib/lighthouse/LICENSE",
|
27
|
-
"lib/lighthouse/README.markdown",
|
28
|
-
"lib/lighthouse/lighthouse-api.rb",
|
29
26
|
"lib/provider/comment.rb",
|
30
27
|
"lib/provider/lighthouse.rb",
|
31
28
|
"lib/provider/project.rb",
|
@@ -68,12 +65,14 @@ Gem::Specification.new do |s|
|
|
68
65
|
s.add_runtime_dependency(%q<ticketmaster>, [">= 0.3.0"])
|
69
66
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
|
70
67
|
s.add_runtime_dependency(%q<activeresource>, [">= 2.3.2"])
|
68
|
+
s.add_runtime_dependency(%q<lighthouse-api>, ["~> 2.0"])
|
71
69
|
s.add_runtime_dependency(%q<addressable>, [">= 2.1.2"])
|
72
70
|
else
|
73
71
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
74
72
|
s.add_dependency(%q<ticketmaster>, [">= 0.3.0"])
|
75
73
|
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
76
74
|
s.add_dependency(%q<activeresource>, [">= 2.3.2"])
|
75
|
+
s.add_dependency(%q<lighthouse-api>, ["~> 2.0"])
|
77
76
|
s.add_dependency(%q<addressable>, [">= 2.1.2"])
|
78
77
|
end
|
79
78
|
else
|
@@ -81,6 +80,7 @@ Gem::Specification.new do |s|
|
|
81
80
|
s.add_dependency(%q<ticketmaster>, [">= 0.3.0"])
|
82
81
|
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
83
82
|
s.add_dependency(%q<activeresource>, [">= 2.3.2"])
|
83
|
+
s.add_dependency(%q<lighthouse-api>, ["~> 2.0"])
|
84
84
|
s.add_dependency(%q<addressable>, [">= 2.1.2"])
|
85
85
|
end
|
86
86
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ticketmaster-lighthouse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hong
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-22 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -83,9 +83,24 @@ dependencies:
|
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: *id004
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
86
|
+
name: lighthouse-api
|
87
87
|
prerelease: false
|
88
88
|
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
94
|
+
segments:
|
95
|
+
- 2
|
96
|
+
- 0
|
97
|
+
version: "2.0"
|
98
|
+
type: :runtime
|
99
|
+
version_requirements: *id005
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: addressable
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
89
104
|
none: false
|
90
105
|
requirements:
|
91
106
|
- - ">="
|
@@ -97,7 +112,7 @@ dependencies:
|
|
97
112
|
- 2
|
98
113
|
version: 2.1.2
|
99
114
|
type: :runtime
|
100
|
-
version_requirements: *
|
115
|
+
version_requirements: *id006
|
101
116
|
description: Allows ticketmaster to interact with Lighthouse's issue tracking system.
|
102
117
|
email: hong.quach@abigfisch.com
|
103
118
|
executables: []
|
@@ -114,9 +129,6 @@ files:
|
|
114
129
|
- README.md
|
115
130
|
- Rakefile
|
116
131
|
- VERSION
|
117
|
-
- lib/lighthouse/LICENSE
|
118
|
-
- lib/lighthouse/README.markdown
|
119
|
-
- lib/lighthouse/lighthouse-api.rb
|
120
132
|
- lib/provider/comment.rb
|
121
133
|
- lib/provider/lighthouse.rb
|
122
134
|
- lib/provider/project.rb
|
data/lib/lighthouse/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
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.
|
@@ -1,359 +0,0 @@
|
|
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 = 'https'
|
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
|