fancybox2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -180
- data/lib/fancybox2/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45c38b5bf5cf22c421a61cd6ebcf5e09802d92047fb02f74a53ea97a5cd2a0d1
|
4
|
+
data.tar.gz: fda98ad8a2a41d27e6d84a278e74d5d29aab5e97934d1e4794aaddc8ca24947b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b363b07e701e3d143d0055cab28acbfc39e00121d41a26d56f3d2fd84fbb5be895f973b53987a5830ed2e242148f8a5cfdd8eca8f1217768af5fde108c9b5c
|
7
|
+
data.tar.gz: cfa1d5b4a6501bbddf1923937e1d6c1a9e804bbc6244052ebc045099f2538c72fd2e0d631413516e76420b05b0a7845f7fab830c157b0f14f51c74aaa5e4d373
|
data/README.md
CHANGED
@@ -2,188 +2,12 @@
|
|
2
2
|
<img width="480" src="assets/logo.png"/>
|
3
3
|
</p>
|
4
4
|
|
5
|
-
[![Build Status](https://travis-ci.org/
|
6
|
-
[![Gem Version](https://badge.fury.io/rb/
|
5
|
+
[![Build Status](https://travis-ci.org/FancyPixel/fancybox2-ruby-sdk.svg)](https://travis-ci.org/FancyPixel/fancybox2-ruby-sdk)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/fancybox2.svg)](https://badge.fury.io/rb/fancybox2)
|
7
7
|
|
8
|
-
|
9
|
-
exchange messages with a server or even with each other. You can store the data, receive timely event notifications,
|
10
|
-
monitor live streams and remotely control your devices. Easy to use, and ready to scale at any time.
|
8
|
+
FancyPixel's FancyBox2 Ruby SDK for developing modules
|
11
9
|
|
12
|
-
|
13
|
-
Please feel free to contribute!
|
14
|
-
|
15
|
-
## Installation
|
16
|
-
|
17
|
-
Add this line to your application's Gemfile:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
gem 'spacebunny'
|
21
|
-
```
|
22
|
-
|
23
|
-
And then execute:
|
24
|
-
|
25
|
-
$ bundle
|
26
|
-
|
27
|
-
Or install it yourself as:
|
28
|
-
|
29
|
-
$ gem install spacebunny
|
30
|
-
|
31
|
-
After you have signed up for a [SpaceBunny](http://spacebunny.io)'s account, follow the
|
32
|
-
[Getting Started](http://getting_started_link) guide for a one minute introduction to the platform concepts
|
33
|
-
and a super rapid setup.
|
34
|
-
|
35
|
-
This SDK provides Device and LiveStream clients and currently supports the AMQP protocol.
|
36
|
-
|
37
|
-
## Device - Basic usage
|
38
|
-
|
39
|
-
Pick a device, view its configurations and copy the Device Key. Instantiate a new `Spacebunny::Device` client,
|
40
|
-
providing the Device Key:
|
41
|
-
|
42
|
-
```ruby
|
43
|
-
dev = Spacebunny::Device.new 'device_key'
|
44
|
-
```
|
45
|
-
|
46
|
-
the SDK will auto-configure, contacting [SpaceBunny APIs](http://doc.spacebunny.io/api) endpoint, retrieving the
|
47
|
-
connection configurations and required parameters. Nothing remains but to connect:
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
dev.connect
|
51
|
-
```
|
52
|
-
|
53
|
-
### Publish
|
54
|
-
|
55
|
-
Ok, all set up! Let's publish some message:
|
56
|
-
|
57
|
-
```ruby
|
58
|
-
# We're assuming you have created a 'data' channel and you have enabled it for your device
|
59
|
-
|
60
|
-
# Let's publish, for instance, some JSON. Payload can be everything you want,
|
61
|
-
# SpaceBunny does not impose any constraint on format or content.
|
62
|
-
|
63
|
-
require 'json' # to convert our payload to JSON
|
64
|
-
|
65
|
-
# Publish one message every second for a minute.
|
66
|
-
60.times do
|
67
|
-
# Generate some random data
|
68
|
-
payload = { greetings: 'Hello, World!', temp: rand(20.0..25.0), foo: rand(100..200) }.to_json
|
69
|
-
|
70
|
-
# Publish
|
71
|
-
dev.publish :data, payload
|
72
|
-
|
73
|
-
# Give feedback on what has been published
|
74
|
-
puts "Published: #{payload}"
|
75
|
-
|
76
|
-
# Take a nap...
|
77
|
-
sleep 1
|
78
|
-
end
|
79
|
-
```
|
80
|
-
|
81
|
-
Let's check out that our data is really being sent by going to our web dashboard: navigate to devices, select the
|
82
|
-
device and click on 'LIVE DATA'. Select the 'data' channel from the dropdown and click **Start**.
|
83
|
-
Having published data as JSON allows SpaceBunny's web UI to parse them and visualize a nice
|
84
|
-
realtime graph: On the **Chart** tab write `temp` in the input field and press enter.
|
85
|
-
You'll see the graph of the `temp` parameter being rendered. If you want to plot more parameters,
|
86
|
-
just use a comma as separator e.g: temp, pressure, voltage
|
87
|
-
On the **Messages** tab you'll see raw messages' payloads received on this channel.
|
88
|
-
|
89
|
-
### Inbox
|
90
|
-
|
91
|
-
Waiting for and reading messages from the device's Inbox is trivial:
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
dev.inbox(wait: true, ack: :auto) do |message|
|
95
|
-
puts "Received: #{message.payload}"
|
96
|
-
end
|
97
|
-
```
|
98
|
-
|
99
|
-
`wait` option (default false) causes the script to wait forever on the receive block
|
100
|
-
|
101
|
-
`ack` option can have two values: `:manual` (default) or `:auto`. When `:manual` you are responsible to ack the messages,
|
102
|
-
for instance:
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
dev.inbox(wait: true, ack: :manual) do |message|
|
106
|
-
puts "Received: #{message.payload}"
|
107
|
-
# Manually ack the message
|
108
|
-
message.ack
|
109
|
-
end
|
110
|
-
```
|
111
|
-
This permits to handle errors or other critical situations
|
112
|
-
|
113
|
-
## Live Stream - Basic usage
|
114
|
-
|
115
|
-
For accessing a Live Stream a Live Stream Key's is required. On SpaceBunny's Web UI, go to the Streams section,
|
116
|
-
click on "Live Stream Keys" and pick or create one.
|
117
|
-
|
118
|
-
```ruby
|
119
|
-
live = Spacebunny::LiveStream.new client: 'live_stream_key_client', secret: 'live_stream_key_secret'
|
120
|
-
```
|
121
|
-
|
122
|
-
Similarly to the Device client, the SDK will auto-configure itself, contacting [SpaceBunny APIs](http://doc.spacebunny.io/api)
|
123
|
-
endpoint, retrieving the connection configurations and required parameters. Nothing remains but to connect:
|
124
|
-
|
125
|
-
```ruby
|
126
|
-
live.connect
|
127
|
-
```
|
128
|
-
|
129
|
-
### Reading live messages
|
130
|
-
|
131
|
-
Each LiveStream has its own cache that will keep always last 100 messages (FIFO, when there are more than 100 messages,
|
132
|
-
the oldest ones get discarded). If you want to consume messages in a parallel way, you shoul use the cache and connect
|
133
|
-
as many LiveStream clients as you need: this way messages will be equally distributed to clients.
|
134
|
-
|
135
|
-
```ruby
|
136
|
-
live.message_from_cache :some_live_stream, wait: true, ack: :auto do |message|
|
137
|
-
puts "Received from cache: #{message.payload}"
|
138
|
-
end
|
139
|
-
|
140
|
-
# An equivalent method is:
|
141
|
-
# live.message_from :some_live_stream, from_cache: true, wait: true, ack: :auto do |message|
|
142
|
-
# puts "Received from cache: #{message.payload}"
|
143
|
-
# end
|
144
|
-
```
|
145
|
-
|
146
|
-
Conversely, if you want that each client will receive a copy of each message, don't use the cache:
|
147
|
-
|
148
|
-
```ruby
|
149
|
-
live.message_from :some_live_stream, wait: true, ack: :auto do |message|
|
150
|
-
puts "Received a copy of: #{message.payload}"
|
151
|
-
end
|
152
|
-
```
|
153
|
-
|
154
|
-
Every client subscribed to the LiveStream in this way will receive a copy of the message.
|
155
|
-
|
156
|
-
## TLS
|
157
|
-
|
158
|
-
Instantiating a TLS-secured connection is trivial:
|
159
|
-
|
160
|
-
```ruby
|
161
|
-
# For a Device
|
162
|
-
|
163
|
-
dev = Spacebunny::Device.new key, tls: true
|
164
|
-
|
165
|
-
# Similarly, for a Live Stream
|
166
|
-
|
167
|
-
live = Spacebunny::LiveStream.new client, secret, tls: true
|
168
|
-
```
|
169
|
-
|
170
|
-
## More examples and options
|
171
|
-
|
172
|
-
Take a look at the ```examples``` directory for more code samples and further details about available options.
|
173
|
-
|
174
|
-
|
175
|
-
### Contributing
|
176
|
-
|
177
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/FancyPixel/spacebunny_ruby.
|
178
|
-
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere
|
179
|
-
to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
180
|
-
|
181
|
-
### Development
|
182
|
-
|
183
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests.
|
184
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
185
|
-
|
186
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
10
|
+
[FancyBox](https://www.fancypixel.it/fancybox-standard/)
|
187
11
|
|
188
12
|
### License
|
189
13
|
|
data/lib/fancybox2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancybox2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Verlato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: paho-mqtt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.12
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.12
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: concurrent-ruby
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|