spacebunny 1.2.2 → 1.3.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.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/lib/spacebunny/device/base.rb +16 -9
- data/lib/spacebunny/live_stream/base.rb +17 -11
- data/lib/spacebunny/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08d9ef7ec38cfdd4d17a454f00e39241c0b666f8'
|
4
|
+
data.tar.gz: 1b2a133fe1db7f8755129e2e71585041c5e9f260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a5e0f306b81bdba7c1a92ae1e61330d8b28a8d73c0b71d99a45f4fe5a61d220d7d5f4d9c856bf8e9a494c38bb3d786a340069d2d7b685b6af309c7234791ef7
|
7
|
+
data.tar.gz: f3ae1e2148684817bd84c73e9e60fd8b9d3893fffccd5c50d0087cfcef13610beb93072bdd1eb77fd34139da49efd8075d2d2df0a8cfde5d275ca42e88075377
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ monitor live streams and remotely control your devices. Easy to use, and ready t
|
|
12
12
|
This is the source code repository for Ruby SDK.
|
13
13
|
Please feel free to contribute!
|
14
14
|
|
15
|
-
|
15
|
+
## Installation
|
16
16
|
|
17
17
|
Add this line to your application's Gemfile:
|
18
18
|
|
@@ -34,7 +34,7 @@ and a super rapid setup.
|
|
34
34
|
|
35
35
|
This SDK provides Device and LiveStream clients and currently supports the AMQP protocol.
|
36
36
|
|
37
|
-
|
37
|
+
## Device - Basic usage
|
38
38
|
|
39
39
|
Pick a device, view its configurations and copy the Device Key. Instantiate a new `Spacebunny::Device` client,
|
40
40
|
providing the Device Key:
|
@@ -50,7 +50,7 @@ connection configurations and required parameters. Nothing remains but to connec
|
|
50
50
|
dev.connect
|
51
51
|
```
|
52
52
|
|
53
|
-
|
53
|
+
### Publish
|
54
54
|
|
55
55
|
Ok, all set up! Let's publish some message:
|
56
56
|
|
@@ -86,7 +86,7 @@ You'll see the graph of the `temp` parameter being rendered. If you want to plot
|
|
86
86
|
just use a comma as separator e.g: temp, pressure, voltage
|
87
87
|
On the **Messages** tab you'll see raw messages' payloads received on this channel.
|
88
88
|
|
89
|
-
|
89
|
+
### Inbox
|
90
90
|
|
91
91
|
Waiting for and reading messages from the device's Inbox is trivial:
|
92
92
|
|
@@ -102,7 +102,7 @@ end
|
|
102
102
|
for instance:
|
103
103
|
|
104
104
|
```ruby
|
105
|
-
dev.inbox(
|
105
|
+
dev.inbox(wait: true, ack: :manual) do |message|
|
106
106
|
puts "Received: #{message.payload}"
|
107
107
|
# Manually ack the message
|
108
108
|
message.ack
|
@@ -110,7 +110,7 @@ end
|
|
110
110
|
```
|
111
111
|
This permits to handle errors or other critical situations
|
112
112
|
|
113
|
-
|
113
|
+
## Live Stream - Basic usage
|
114
114
|
|
115
115
|
For accessing a Live Stream a Live Stream Key's is required. On SpaceBunny's Web UI, go to the Streams section,
|
116
116
|
click on "Live Stream Keys" and pick or create one.
|
@@ -126,7 +126,7 @@ endpoint, retrieving the connection configurations and required parameters. Noth
|
|
126
126
|
live.connect
|
127
127
|
```
|
128
128
|
|
129
|
-
|
129
|
+
### Reading live messages
|
130
130
|
|
131
131
|
Each LiveStream has its own cache that will keep always last 100 messages (FIFO, when there are more than 100 messages,
|
132
132
|
the oldest ones get discarded). If you want to consume messages in a parallel way, you shoul use the cache and connect
|
@@ -153,7 +153,7 @@ end
|
|
153
153
|
|
154
154
|
Every client subscribed to the LiveStream in this way will receive a copy of the message.
|
155
155
|
|
156
|
-
|
156
|
+
## TLS
|
157
157
|
|
158
158
|
Instantiating a TLS-secured connection is trivial:
|
159
159
|
|
@@ -40,12 +40,19 @@ module Spacebunny
|
|
40
40
|
@api_endpoint = options.deep_symbolize_keys
|
41
41
|
end
|
42
42
|
|
43
|
+
# Retrieve configs from APIs endpoint
|
44
|
+
def auto_configs(force_reload = false)
|
45
|
+
if force_reload || !@auto_configs
|
46
|
+
@auto_configs = EndpointConnection.new(@api_endpoint.merge(key: @key, logger: logger)).configs
|
47
|
+
end
|
48
|
+
@auto_configs
|
49
|
+
end
|
50
|
+
|
43
51
|
def connection_configs
|
44
52
|
return @connection_configs if @connection_configs
|
45
53
|
if auto_configure?
|
46
54
|
# If key is specified, retrieve configs from APIs endpoint
|
47
|
-
|
48
|
-
normalize_and_add_channels @auto_configs[:channels]
|
55
|
+
normalize_and_add_channels auto_configs[:channels]
|
49
56
|
@auto_connection_configs = normalize_auto_connection_configs
|
50
57
|
end
|
51
58
|
# Build final connection_configs
|
@@ -220,13 +227,13 @@ module Spacebunny
|
|
220
227
|
# Translate from auto configs given by APIs endpoint to a common format
|
221
228
|
def normalize_auto_connection_configs
|
222
229
|
{
|
223
|
-
host:
|
224
|
-
port:
|
225
|
-
tls_port:
|
226
|
-
vhost:
|
227
|
-
device_id:
|
228
|
-
device_name:
|
229
|
-
secret:
|
230
|
+
host: auto_configs[:connection][:host],
|
231
|
+
port: auto_configs[:connection][:protocols][@protocol][:port],
|
232
|
+
tls_port: auto_configs[:connection][:protocols][@protocol][:tls_port],
|
233
|
+
vhost: auto_configs[:connection][:vhost],
|
234
|
+
device_id: auto_configs[:connection][:device_id],
|
235
|
+
device_name: auto_configs[:connection][:device_name],
|
236
|
+
secret: auto_configs[:connection][:secret]
|
230
237
|
}
|
231
238
|
end
|
232
239
|
|
@@ -40,15 +40,21 @@ module Spacebunny
|
|
40
40
|
@api_endpoint = options.deep_symbolize_keys
|
41
41
|
end
|
42
42
|
|
43
|
+
# Retrieve configs from APIs endpoint
|
44
|
+
def auto_configs(force_reload = false)
|
45
|
+
if force_reload || !@auto_configs
|
46
|
+
@auto_configs = EndpointConnection.new(
|
47
|
+
@api_endpoint.merge(client: @client, secret: @secret, logger: logger)
|
48
|
+
).configs
|
49
|
+
end
|
50
|
+
@auto_configs
|
51
|
+
end
|
52
|
+
|
43
53
|
def connection_configs
|
44
54
|
return @connection_configs if @connection_configs
|
45
55
|
if auto_configure?
|
46
56
|
# If key is specified, retrieve configs from APIs endpoint
|
47
|
-
|
48
|
-
client: @client,
|
49
|
-
secret: @secret,
|
50
|
-
logger: logger)).configs
|
51
|
-
check_and_add_live_streams @auto_configs[:live_streams]
|
57
|
+
check_and_add_live_streams auto_configs[:live_streams]
|
52
58
|
@auto_connection_configs = normalize_auto_connection_configs
|
53
59
|
end
|
54
60
|
# Build final connection_configs
|
@@ -185,12 +191,12 @@ module Spacebunny
|
|
185
191
|
# Translate from auto configs given by APIs endpoint to a common format
|
186
192
|
def normalize_auto_connection_configs
|
187
193
|
{
|
188
|
-
host:
|
189
|
-
port:
|
190
|
-
tls_port:
|
191
|
-
vhost:
|
192
|
-
client:
|
193
|
-
secret:
|
194
|
+
host: auto_configs[:connection][:host],
|
195
|
+
port: auto_configs[:connection][:protocols][@protocol][:port],
|
196
|
+
tls_port: auto_configs[:connection][:protocols][@protocol][:tls_port],
|
197
|
+
vhost: auto_configs[:connection][:vhost],
|
198
|
+
client: auto_configs[:connection][:client],
|
199
|
+
secret: auto_configs[:connection][:secret]
|
194
200
|
}
|
195
201
|
end
|
196
202
|
|
data/lib/spacebunny/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spacebunny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Verlato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.6.
|
154
|
+
rubygems_version: 2.6.12
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Space Bunny platform SDK
|