cyberfox-lighthouse-api 1.0.0 → 1.0.1
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/lib/lighthouse-api.rb +2 -1
- data/lib/lighthouse.rb +43 -1
- data/lib/multi_lighthouse.rb +17 -0
- metadata +2 -1
data/lib/lighthouse-api.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/lighthouse"
|
1
|
+
require File.dirname(__FILE__) + "/lighthouse"
|
2
|
+
require File.dirname(__FILE__) + "/multi_lighthouse"
|
data/lib/lighthouse.rb
CHANGED
@@ -159,10 +159,18 @@ module Lighthouse
|
|
159
159
|
def changesets(options = {})
|
160
160
|
Changeset.find(:all, :params => options.update(:project_id => id))
|
161
161
|
end
|
162
|
+
|
163
|
+
def memberships(options = {})
|
164
|
+
ProjectMembership.find(:all, :params => options.update(:project_id => id))
|
165
|
+
end
|
166
|
+
|
167
|
+
def tags(options = {})
|
168
|
+
TagResource.find(:all, :params => options.update(:project_id => id))
|
169
|
+
end
|
162
170
|
end
|
163
171
|
|
164
172
|
class User < Base
|
165
|
-
def memberships
|
173
|
+
def memberships(options = {})
|
166
174
|
Membership.find(:all, :params => {:user_id => id})
|
167
175
|
end
|
168
176
|
end
|
@@ -174,6 +182,19 @@ module Lighthouse
|
|
174
182
|
end
|
175
183
|
end
|
176
184
|
|
185
|
+
class ProjectMembership < Base
|
186
|
+
self.element_name = 'membership'
|
187
|
+
site_format << '/projects/:project_id'
|
188
|
+
|
189
|
+
def url
|
190
|
+
respond_to?(:account) ? account : project
|
191
|
+
end
|
192
|
+
|
193
|
+
def save
|
194
|
+
raise Error, "Cannot modify memberships from the API"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
177
198
|
class Token < Base
|
178
199
|
def save
|
179
200
|
raise Error, "Cannot modify Tokens from the API"
|
@@ -306,13 +327,34 @@ module Lighthouse
|
|
306
327
|
|
307
328
|
class Change < Array; end
|
308
329
|
|
330
|
+
class TagResource < Base
|
331
|
+
self.element_name = 'tag'
|
332
|
+
site_format << '/projects/:project_id'
|
333
|
+
|
334
|
+
def name
|
335
|
+
@name ||= Tag.new(attributes['name'], prefix_options[:project_id])
|
336
|
+
end
|
337
|
+
|
338
|
+
def tickets(options = {})
|
339
|
+
name.tickets(options)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
309
343
|
class Tag < String
|
310
344
|
attr_writer :prefix_options
|
345
|
+
attr_accessor :project_id
|
346
|
+
|
347
|
+
def initialize(s, project_id)
|
348
|
+
@project_id = project_id
|
349
|
+
super(s)
|
350
|
+
end
|
351
|
+
|
311
352
|
def prefix_options
|
312
353
|
@prefix_options || {}
|
313
354
|
end
|
314
355
|
|
315
356
|
def tickets(options = {})
|
357
|
+
options[:project_id] ||= @project_id
|
316
358
|
Ticket.find(:all, :params => options.merge(prefix_options).update(:q => %{tagged:"#{self}"}))
|
317
359
|
end
|
318
360
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class MultiLighthouse
|
2
|
+
def method_missing(meth, *args, &block)
|
3
|
+
begin
|
4
|
+
const = Lighthouse.const_get(meth)
|
5
|
+
Lighthouse.account = @account
|
6
|
+
Lighthouse.token = @token
|
7
|
+
return const
|
8
|
+
rescue NameError => ne
|
9
|
+
Lighthouse.send(meth, args, block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(account, token)
|
14
|
+
@account = account
|
15
|
+
@token = token
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyberfox-lighthouse-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Olsen
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- LICENSE
|
45
45
|
- README.markdown
|
46
46
|
- lib/lighthouse-api.rb
|
47
|
+
- lib/multi_lighthouse.rb
|
47
48
|
- lib/lighthouse.rb
|
48
49
|
- lib/lighthouse/console.rb
|
49
50
|
has_rdoc: true
|