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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98304ccf43a93ccec0f2a37ba00925ed1f1a22aa
4
- data.tar.gz: f985b12c74283d50d69ff42299a4e60403b3044f
3
+ metadata.gz: d547c4fbd95026d423d1ce9ce8d505ebe6be8d6b
4
+ data.tar.gz: 42916d8bf773990d66248abf56db32d3a7137cc7
5
5
  SHA512:
6
- metadata.gz: 59758121ab0dde38ec6646d59755aaebc7d3b7e85bbf15fdc89e9895418f935542f005b70fe3f4537d54450a013fc9f6b6edad419b18cf549f97deb0fc801e58
7
- data.tar.gz: 416b62f2423657c4db436f5c72e7143f8095de18f31084139a2c5c9e5f0f17f77ef64adf24cb9b2484bb649a73b2338bc89e98cfdf3d4bc14473c381f7b63e6d
6
+ metadata.gz: 969977a668f503c224ab34d1a34e2da2538e7df9f552a0470e06daa6aa0b056260f51085c091b817a89d48f9249585d9f923c6904450865b141635d404295277
7
+ data.tar.gz: 3c6327a5105976150aac4550a02d62b08c1db4cf025361233deb21016aadd99dcfb97f0285006a893760074880298ed7708648d8441f7dc2f79ad9f945279bb4
@@ -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
- puts args
35
- request :put, 'devices/poll', args
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.5
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 00:00:00.000000000 Z
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.4.8
86
+ rubygems_version: 2.5.0
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: API for Hive Mind