mind_meld 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mind_meld.rb +21 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fe211ad4268bb53b8a771ed82114bc972271c98
|
4
|
+
data.tar.gz: b7327391f6e01965d041c19640f4ff684c9170d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eba3450bd2aa1df39a956750af398fd9f495390ec6599dbfa368935ea6f5c7e698368f475197601fbc3a879d3fa323dcc4274eebd29c1318047c08243be3735
|
7
|
+
data.tar.gz: 77921f3f2c0613233de2e2c5b2e45d937bf1e5922e7fa1ae7981e37beb49e16453ec145983986fa647880b7f5e4a68e78dd01ab808e435d6efe85eb929a08b1d
|
data/lib/mind_meld.rb
CHANGED
@@ -7,19 +7,36 @@ class MindMeld
|
|
7
7
|
if options[:url]
|
8
8
|
uri = URI.parse(options[:url])
|
9
9
|
@http = Net::HTTP.new(uri.host, uri.port)
|
10
|
+
|
11
|
+
@device = options[:device]
|
12
|
+
|
13
|
+
# To initialize @id (is this needed?)
|
14
|
+
self.id
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
18
|
+
def id
|
19
|
+
@id ||= register(@device)['id']
|
20
|
+
end
|
21
|
+
|
13
22
|
def register options
|
14
|
-
post 'devices/register', { device: options }
|
23
|
+
request :post, 'devices/register', { device: options }
|
24
|
+
end
|
25
|
+
|
26
|
+
def poll *dev_ids
|
27
|
+
args = {
|
28
|
+
poll: dev_ids.length > 0 ? { id: self.id, devices: dev_ids } : { id: self.id }
|
29
|
+
}
|
30
|
+
puts args
|
31
|
+
request :put, 'devices/poll', args
|
15
32
|
end
|
16
33
|
|
17
34
|
private
|
18
|
-
def
|
35
|
+
def request type, call, params = {}
|
19
36
|
if @http
|
20
37
|
begin
|
21
|
-
JSON.parse(@http.
|
22
|
-
rescue
|
38
|
+
JSON.parse(@http.send("request_#{type}", "/api/#{call}.json", params.to_query).body)
|
39
|
+
rescue => e
|
23
40
|
puts e.message
|
24
41
|
{ error: e.message }
|
25
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mind_meld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Haig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|