guh 0.0.8 → 0.0.9

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: d4d9c7442043ff911a635dce551e050563e6dada
4
- data.tar.gz: a93a5f0f1b94fe8e1376651595d504ca88185ce2
3
+ metadata.gz: 4986b5e27fcbb44059de42f06fe85270470e06c3
4
+ data.tar.gz: 1e67ea596ae67942ce0b138f23a53900afbb4da8
5
5
  SHA512:
6
- metadata.gz: 818cf818e6ce9bac1d326f713d32c0a287a8901e6edc6eee6856e0e65014c1014fd5197a6e90faa3c2de28c8ba22c79dddc3dfefc4b769d50257e02a510520ab
7
- data.tar.gz: 10a5f8c681aecee9f25fdbf9f7f72ff8522bf47330660c8c9de0e3069bd3aba5c7a66e9cb6b9ca5ae3d1b202b7e4f2286488687949a3f9064eb453bb478b071f
6
+ metadata.gz: 293816e7eb5266eab8d3a9d8c3065f08ed65aa21c08d5eab35e47dbb1537ef7295567023eaceea315df65c0267c51992fb7b171e8626a7d58fd17579fa597567
7
+ data.tar.gz: 72f9065e827d245ad456b3d0bbc33def90bde42d98682f03368b309b50eb6af673cc163ded2a6bd563d6491cd656c8438504a73ff2d6acd259b79bd41ca75696
@@ -71,7 +71,7 @@ module Guh
71
71
  #
72
72
  # Example for the "Elro Power Switch":
73
73
  #
74
- # Guh::Device.add("{308ae6e6-38b3-4b3a-a513-3199da2764f8}", {
74
+ # Guh::Device.add("{308ae6e6-38b3-4b3a-a513-3199da2764f8}", nil, {
75
75
  # channel1: true,
76
76
  # channel2: false,
77
77
  # channel3: false,
@@ -86,15 +86,15 @@ module Guh
86
86
  #
87
87
  # To create a discovered device you have to provide a descriptor ID in the params:
88
88
  #
89
- # Guh::Device.add("{985195aa-17ad-4530-88a4-cdd753d747d7}", {deviceDescriptorId: "{727a4a9a-c187-446f-aadf-f1b2220607d1}"})
89
+ # Guh::Device.add("{985195aa-17ad-4530-88a4-cdd753d747d7}", "{727a4a9a-c187-446f-aadf-f1b2220607d1}")
90
90
  #
91
- def self.add(device_class_id, params)
91
+ def self.add(device_class_id, device_descriptor_id = nil, params = [])
92
92
  device_class = Guh::DeviceClass.find(device_class_id)
93
93
 
94
94
  if device_class['createMethods'].include? 'CreateMethodUser'
95
95
  add_configured_device(device_class_id, params)
96
96
  elsif device_class['createMethods'].include? 'CreateMethodDiscovery'
97
- add_discovered_device(device_class_id, params.delete('deviceDescriptorId'), params)
97
+ add_discovered_device(device_class_id, device_descriptor_id, params)
98
98
  elsif device_class['createMethods'].include? 'CreateMethodAuto'
99
99
  # Nothing to do here
100
100
  # TODO should we raise an exception?
@@ -129,7 +129,7 @@ module Guh
129
129
  #
130
130
  # Example:
131
131
  #
132
- # device_id = Guh::Device.add("{ab73ad2f-6594-45a3-9063-8f72d365c5e5}", {familyCode: 'A'})
132
+ # device_id = Guh::Device.add("{ab73ad2f-6594-45a3-9063-8f72d365c5e5}", nil, [{name: 'familyCode', value: 'A'}])
133
133
  #
134
134
  # Guh::Device.remove(device_id)
135
135
  #
@@ -1,3 +1,3 @@
1
1
  module Guh
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -58,7 +58,7 @@ end
58
58
 
59
59
  def create_configured_device(device_class_id, params)
60
60
  # Create a device
61
- device_id = Guh::Device.add(device_class_id, params)
61
+ device_id = Guh::Device.add(device_class_id, nil, params)
62
62
 
63
63
  # Get the newly configured device
64
64
  return Guh::Device.all.detect{|d| d['id'] == device_id}
@@ -18,7 +18,7 @@ describe Guh::Device do
18
18
  configured_count = Guh::Device.count
19
19
 
20
20
  -> {
21
- response = Guh::Device.add("{308ae6e6-38b3-4b3a-a513-3199da2764f8}", [
21
+ response = Guh::Device.add("{308ae6e6-38b3-4b3a-a513-3199da2764f8}", nil, [
22
22
  {name: 'channel 1', value: true},
23
23
  {name: 'channel 2', value: false},
24
24
  {name: 'channel 3', value: false},
@@ -39,14 +39,14 @@ describe Guh::Device do
39
39
  configured_count = Guh::Device.count
40
40
 
41
41
  -> {
42
- response = Guh::Device.add("{308ae6e6-38b3-4b3a-a513-3199da2764f8}", [])
42
+ response = Guh::Device.add("{308ae6e6-38b3-4b3a-a513-3199da2764f8}")
43
43
  }.should raise_error
44
44
 
45
45
  Guh::Device.count.should eq(configured_count)
46
46
  end
47
47
 
48
48
  it "should create a new device, return its ID and remove it successfully" do
49
- device_id = Guh::Device.add("{ab73ad2f-6594-45a3-9063-8f72d365c5e5}", [{name: 'familyCode', value: 'A'}])
49
+ device_id = Guh::Device.add("{ab73ad2f-6594-45a3-9063-8f72d365c5e5}", nil, [{name: 'familyCode', value: 'A'}])
50
50
 
51
51
  device_id.should match(/^\{[a-z0-9\-]+\}$/i)
52
52
 
@@ -66,7 +66,7 @@ describe Guh::Device do
66
66
 
67
67
  device_descriptors = Guh::Device.discover(device_class_id, [{name: 'location', value: 'Salzburg'}])
68
68
 
69
- response = Guh::Device.add(device_class_id, {'deviceDescriptorId' => device_descriptors.first['id']})
69
+ response = Guh::Device.add(device_class_id, device_descriptors.first['id'])
70
70
 
71
71
  response.should match /\A\{.*\}\z/
72
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Edthofer