beebotte 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a342811e6b3041aacf419ffa54d37bc9ff1904e
4
- data.tar.gz: ca0f73eda5f8a58aa780dcb913ef52769b413e4c
3
+ metadata.gz: fd37c393fe2779c46d062e6d63e5857aef14b607
4
+ data.tar.gz: 5042564e8a7228df947b303bfe34665d884c4b20
5
5
  SHA512:
6
- metadata.gz: bbea1488fbed398f5640f684ef9942a5a84f40bbac798685cd53de98ae24e62cebae1f24b45d4f03e53fef040eac57e393a824fa4f89500506bbefd308c5bcf2
7
- data.tar.gz: fa588fa2d9acac1a8a5acfc220c69bb741afb5c726134a2f823363998933c5a08b59851e765072f1ab2e035de60e51bdadd6b37730ce80ed69d0a692aef1145d
6
+ metadata.gz: ee1382b295f31a6440f925e2b2153c17212e29c76d03cba9d594f92c3cdadb7553c6dc5dd831c77e7d77612e3cbe44b414050ad73b70a1f65000cd405ff0e912
7
+ data.tar.gz: 6c0de50a52d1ba9764f91267366b07c1c98861edebdb177055134faef10317f95578ea2dde89173abc276ec288d5becba00329b71507ab76c35464f16149d312
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2009-2013 Michael S. Kazmier
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -2,10 +2,34 @@ Beebotte ruby gem
2
2
  =================
3
3
 
4
4
 
5
- THIS IS ALPHA SOFTWARE - USE AT YOUR OWN PERIL
5
+ **THIS IS ALPHA SOFTWARE - USE AT YOUR OWN PERIL**
6
6
 
7
- Example usage:
8
- --------------
7
+
8
+ Basic Usage
9
+ -----------
10
+
11
+ Install the gem: `gem install beebotte`
12
+
13
+ In your ruby code:
14
+ ```
15
+ require 'beebotte'
16
+ ```
17
+
18
+
19
+ There are two main classes: `Connector` and `Stream`. The Connector class
20
+ implements the REST API and the Stream class implements the MQTT connection
21
+ to Beebotte.
22
+
23
+ Please see the Beebotte document here: https://beebotte.com/overview for
24
+ more details on their implmentation.
25
+
26
+ **Currently the Connector class only works with API and Secret key, Token
27
+ authentication is not yet supported.**
28
+
29
+
30
+
31
+ Full api examples:
32
+ ------------------------
9
33
  ```
10
34
  b = Beebotte::Connector.new("<yourApiKey>", "<yourSecretKey>", 'api.beebotte.com', 443)
11
35
 
@@ -50,6 +74,21 @@ b.get_resources(resource_name) {|r, code| puts "(#{code}) #{r.inspect}"}
50
74
  puts "\n\n---------\ndel_channel:"
51
75
  b.del_channel(channel_name) {|r, code| puts "(#{code}) #{r.inspect}"}
52
76
 
77
+
78
+
79
+
80
+ s = Beebotte::Stream.new({token: "yourChannelToken"})
81
+ s.connect()
82
+
83
+ s.subscribe("#{channel_name}/#{resource_name}")
84
+
85
+ s.publish(channel_name, resource_name, {status: 456})
86
+
87
+ s.write(channel_name, resource_name, {status: 789})
88
+
89
+ s.get { |topic, message| puts "\n\nTopic: #{topic}\nMessage: #{message}" }
90
+
91
+
53
92
  ```
54
93
 
55
94
  TODO:
@@ -58,4 +97,8 @@ TODO:
58
97
  1. Testing
59
98
  1. Token authentication for REST API
60
99
  1. Bulk API
61
- 1. Stream API
100
+
101
+ License
102
+ -------
103
+
104
+ The Beebotte ruby gem is licensed under the terms of the MIT license. See the file LICENSE for details.
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency 'openssl'
24
24
  spec.add_runtime_dependency 'json'
25
- spec.add_runtime_dependency 'rest-client', '>= 2.0.0'
25
+ spec.add_runtime_dependency 'rest-client', '>= 1.8.0'
26
26
  spec.add_runtime_dependency 'classy_hash'
27
27
  spec.add_runtime_dependency 'mqtt'
28
28
  spec.add_development_dependency "rspec"
@@ -264,20 +264,19 @@ module Beebotte
264
264
 
265
265
  class Stream
266
266
  attr_accessor :token, :host, :port, :ssl
267
- attr_reader :subsciptions
267
+ attr_reader :subscriptions
268
268
 
269
269
  class NotConnected < StandardError; end
270
270
  class NoSubscriptions < StandardError; end
271
271
 
272
272
  def initialize(opts = {})
273
273
  @token = opts[:token]
274
- @apiKey = opts[:api_key]
275
274
  @secretKey = opts[:secret_key]
276
- raise ArguementError, 'Must set token OR api_key and secret key' if (@token.nil? && (@apiKey.nil? || @secretKey.nil?))
275
+ raise ArguementError, 'Must set token OR secret_key in opts' if (@token.nil? && @secretKey.nil?)
277
276
  @host = opts[:host] || "mqtt.beebotte.com"
278
277
  @port = opts[:port] || 1883
279
278
  @ssl = opts[:ssl] || false
280
- @subscrptions = []
279
+ @subscriptions = []
281
280
  @client = MQTT::Client.new
282
281
  end
283
282
 
@@ -290,6 +289,8 @@ module Beebotte
290
289
  @subscriptions = []
291
290
  if @token
292
291
  @client.username = "token:#{@token}"
292
+ else
293
+ @client.username = @secretKey
293
294
  end
294
295
  @client.connect()
295
296
  @client.connected?
@@ -298,6 +299,7 @@ module Beebotte
298
299
  def disconnect
299
300
  @subscriptions = []
300
301
  @client.disconnect()
302
+ true
301
303
  end
302
304
 
303
305
  def connected?
@@ -1,3 +1,3 @@
1
1
  module Beebotte
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beebotte
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kazmier
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.0
47
+ version: 1.8.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.0.0
54
+ version: 1.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: classy_hash
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -202,6 +202,7 @@ files:
202
202
  - ".gitignore"
203
203
  - Gemfile
204
204
  - Guardfile
205
+ - LICENSE.md
205
206
  - README.md
206
207
  - Rakefile
207
208
  - beebotte.gemspec