spire_io 1.2.2 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/spire/api/application.rb +13 -8
- data/lib/spire/api/requestable.rb +4 -0
- data/lib/spire/api/resource.rb +11 -3
- data/lib/spire/api/session.rb +5 -1
- data/lib/spire/api/subscription.rb +3 -0
- data/lib/spire/api.rb +7 -0
- data/lib/spire_io.rb +5 -1
- metadata +4 -4
@@ -132,13 +132,15 @@ class Spire
|
|
132
132
|
}
|
133
133
|
end
|
134
134
|
|
135
|
-
define_request(:members) do
|
135
|
+
define_request(:members) do |options|
|
136
|
+
options ||= {}
|
136
137
|
collection = @resources["members"]
|
137
138
|
capability = collection["capabilities"]["all"]
|
138
139
|
url = collection["url"]
|
139
140
|
{
|
140
141
|
:method => :get,
|
141
142
|
:url => url,
|
143
|
+
:query => options,
|
142
144
|
:headers => {
|
143
145
|
"Authorization" => "Capability #{capability}",
|
144
146
|
"Accept" => @api.mediaType("members"),
|
@@ -245,20 +247,23 @@ class Spire
|
|
245
247
|
true
|
246
248
|
end
|
247
249
|
|
248
|
-
def members
|
249
|
-
@members
|
250
|
+
def members(options = {})
|
251
|
+
@members ||= {}
|
252
|
+
@members[options.hash] || members!(options)
|
250
253
|
end
|
251
254
|
|
252
|
-
def members!
|
253
|
-
response = request(:members)
|
255
|
+
def members!(options = {})
|
256
|
+
response = request(:members, options)
|
254
257
|
unless response.status == 200
|
255
258
|
raise "Error getting members for application #{self.name}: (#{response.status}) #{response.body}"
|
256
259
|
end
|
257
|
-
@members
|
260
|
+
@members ||= {}
|
261
|
+
hsh_key = options.hash
|
262
|
+
@members[hsh_key] ||= {}
|
258
263
|
response.data.each do |login, properties|
|
259
|
-
@members[login] = API::Member.new(@api, properties)
|
264
|
+
@members[hsh_key][login] = API::Member.new(@api, properties)
|
260
265
|
end
|
261
|
-
@members
|
266
|
+
@members[hsh_key]
|
262
267
|
end
|
263
268
|
|
264
269
|
def get_member(member_login)
|
@@ -48,6 +48,8 @@ class Spire
|
|
48
48
|
end
|
49
49
|
|
50
50
|
class Request
|
51
|
+
# @!attribute [rw] url
|
52
|
+
# Url of the request
|
51
53
|
attr_accessor :url
|
52
54
|
def initialize(client, options)
|
53
55
|
@client = client
|
@@ -90,6 +92,8 @@ class Spire
|
|
90
92
|
end
|
91
93
|
|
92
94
|
class Response < SimpleDelegator
|
95
|
+
# @!attribute [rw] data
|
96
|
+
# Response data
|
93
97
|
attr_accessor :data
|
94
98
|
end
|
95
99
|
end
|
data/lib/spire/api/resource.rb
CHANGED
@@ -38,8 +38,12 @@ class Spire
|
|
38
38
|
}
|
39
39
|
}
|
40
40
|
end
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
# @!attribute [r] url
|
43
|
+
# Url of the resource
|
44
|
+
# @!attribute [r] capabilities
|
45
|
+
# Capabilities for the resource
|
46
|
+
attr_reader :url, :properties, :capabilities
|
43
47
|
|
44
48
|
def initialize(api, data)
|
45
49
|
@api = api
|
@@ -54,13 +58,17 @@ class Spire
|
|
54
58
|
end
|
55
59
|
|
56
60
|
def method_missing(name, *args)
|
57
|
-
if
|
61
|
+
if schema["properties"][name.to_s]
|
58
62
|
properties[name.to_s]
|
59
63
|
else
|
60
64
|
super
|
61
65
|
end
|
62
66
|
end
|
63
67
|
|
68
|
+
def respond_to?(name)
|
69
|
+
schema["properties"][name.to_s] || super
|
70
|
+
end
|
71
|
+
|
64
72
|
def [](name)
|
65
73
|
properties[name]
|
66
74
|
end
|
data/lib/spire/api/session.rb
CHANGED
@@ -186,7 +186,11 @@ class Spire
|
|
186
186
|
}
|
187
187
|
end
|
188
188
|
|
189
|
-
|
189
|
+
# @!attribute [r] url
|
190
|
+
# Url of the spire.io api.
|
191
|
+
# @!attribute [r] schema
|
192
|
+
# Spire API Schema
|
193
|
+
attr_reader :url, :resources, :schema, :capabilities
|
190
194
|
|
191
195
|
def initialize(api, data)
|
192
196
|
@api = api
|
@@ -15,7 +15,10 @@ class Spire
|
|
15
15
|
# * subscription = channel.subscribe("subscription name")
|
16
16
|
class Subscription < Resource
|
17
17
|
|
18
|
+
# @!attribute [rw]
|
19
|
+
# Timestamp (in microseconds) of the last event received
|
18
20
|
attr_accessor :last
|
21
|
+
|
19
22
|
def resource_name
|
20
23
|
"subscription"
|
21
24
|
end
|
data/lib/spire/api.rb
CHANGED
@@ -24,7 +24,14 @@ class Spire
|
|
24
24
|
JSON.parse(string, :symbolize_names => false)
|
25
25
|
end
|
26
26
|
|
27
|
+
# @!attribute [r] client
|
28
|
+
# HTTP client.
|
29
|
+
# @!attribute [r] description
|
30
|
+
# Description of the Spire.io API from discovery.
|
31
|
+
# @!attribute [r] schema
|
32
|
+
# The Spire.io API schema.
|
27
33
|
attr_reader :client, :description, :schema
|
34
|
+
|
28
35
|
def initialize(url="https://api.spire.io", spire=nil, options={})
|
29
36
|
@version = options[:version] || "1.0"
|
30
37
|
@client = Excon
|
data/lib/spire_io.rb
CHANGED
@@ -8,8 +8,12 @@ class Spire
|
|
8
8
|
# getting a 409 Conflict.
|
9
9
|
RETRY_CREATION_LIMIT = 3
|
10
10
|
|
11
|
+
# @!attribute [rw] api
|
12
|
+
# Spire API object. Has low-level methods for accessing the spire.io API.
|
13
|
+
# @!attribute [rw] session
|
14
|
+
# Spire session. Contains methods for creating channels, subscriptions, and applications.
|
11
15
|
attr_accessor :api, :session, :resources
|
12
|
-
|
16
|
+
|
13
17
|
def initialize(url="https://api.spire.io")
|
14
18
|
@api = Spire::API.new(url)
|
15
19
|
@url = url
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spire_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 4
|
10
|
+
version: 1.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dan Yoder
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-05-
|
20
|
+
date: 2012-05-30 00:00:00 -07:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|