mind_meld 0.0.5 → 0.0.6
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/hive.rb +22 -0
- data/lib/mind_meld.rb +15 -8
- 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: d547c4fbd95026d423d1ce9ce8d505ebe6be8d6b
|
4
|
+
data.tar.gz: 42916d8bf773990d66248abf56db32d3a7137cc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 969977a668f503c224ab34d1a34e2da2538e7df9f552a0470e06daa6aa0b056260f51085c091b817a89d48f9249585d9f923c6904450865b141635d404295277
|
7
|
+
data.tar.gz: 3c6327a5105976150aac4550a02d62b08c1db4cf025361233deb21016aadd99dcfb97f0285006a893760074880298ed7708648d8441f7dc2f79ad9f945279bb4
|
data/lib/mind_meld/hive.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'mind_meld'
|
2
|
+
|
3
|
+
class MindMeld::Hive < MindMeld
|
4
|
+
def initialize options
|
5
|
+
options[:device][:device_type] = 'Hive'
|
6
|
+
super options
|
7
|
+
end
|
8
|
+
|
9
|
+
def connect device_id
|
10
|
+
request :put, 'plugin/hive/connect', { connection: { hive_id: self.id, device_id: device_id } }
|
11
|
+
end
|
12
|
+
|
13
|
+
def disconnect device_id
|
14
|
+
request :put, 'plugin/hive/disconnect', { connection: { hive_id: self.id, device_id: device_id } }
|
15
|
+
end
|
16
|
+
|
17
|
+
def device_details(refresh = false)
|
18
|
+
super(refresh)
|
19
|
+
@device_details['connected_devices'] = [] if not @device_details.has_key? 'connected_devices'
|
20
|
+
@device_details
|
21
|
+
end
|
22
|
+
end
|
data/lib/mind_meld.rb
CHANGED
@@ -31,12 +31,24 @@ class MindMeld
|
|
31
31
|
args = {
|
32
32
|
poll: dev_ids.length > 0 ? { id: self.id, devices: dev_ids } : { id: self.id }
|
33
33
|
}
|
34
|
-
|
35
|
-
|
34
|
+
response = request :put, 'devices/poll', args
|
35
|
+
if dev_ids.length == 0
|
36
|
+
@device_details = response
|
37
|
+
end
|
38
|
+
response
|
36
39
|
end
|
37
40
|
|
38
41
|
def create_action options
|
39
|
-
request :put, 'devices/action', { device_action: options }
|
42
|
+
response = request :put, 'devices/action', { device_action: { device_id: self.id }.merge(options) }
|
43
|
+
response
|
44
|
+
end
|
45
|
+
|
46
|
+
def device_details(refresh = false)
|
47
|
+
if refresh or not @device_details or @device_details.has_key? :error
|
48
|
+
@device_details = register(@device)
|
49
|
+
else
|
50
|
+
@device_details
|
51
|
+
end
|
40
52
|
end
|
41
53
|
|
42
54
|
private
|
@@ -45,15 +57,10 @@ puts args
|
|
45
57
|
begin
|
46
58
|
JSON.parse(@http.send("request_#{type}", "/api/#{call}.json", params.to_query).body)
|
47
59
|
rescue => e
|
48
|
-
puts e.message
|
49
60
|
{ error: e.message }
|
50
61
|
end
|
51
62
|
else
|
52
63
|
{ error: 'Mind Meld not configured' }
|
53
64
|
end
|
54
65
|
end
|
55
|
-
|
56
|
-
def device_details
|
57
|
-
device_details ||= register(@device)
|
58
|
-
end
|
59
66
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Haig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.5.0
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: API for Hive Mind
|