ruby_home 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_home/factories/characteristic_factory.rb +4 -8
- data/lib/ruby_home/hap/characteristic.rb +6 -5
- data/lib/ruby_home/hap/server.rb +2 -3
- data/lib/ruby_home/hap/values/base_value.rb +1 -1
- data/lib/ruby_home/hap/values/identify_value.rb +9 -0
- data/lib/ruby_home/http/serializers/characteristic_serializer.rb +15 -11
- data/lib/ruby_home/version.rb +1 -1
- data/rubyhome.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78d53eedc8551fe938a91a59629393108dbab03836f237ee9c535769c97bc09e
|
4
|
+
data.tar.gz: '0388c9fee54bc40b072eefb0d330701c5460d9e99156c7b0df305caf2294a671'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f60165e3c45540053e7074e94dfb190d4290363189c6e730079d669b1d85e9b1ab4f2c0297ec5359acd6c680d30200c646b0d5c4e8be680d765d9f3097dda06a
|
7
|
+
data.tar.gz: 3da982336642c9a69d64b32a3c769bdc60f55c30cfaf6be51c3b3a6eb56fd629e65186ccd705b8bfaac54a87fe34dc28baa3a7b0fc3e3ac28a73a8924bd40748
|
@@ -1,9 +1,5 @@
|
|
1
1
|
module RubyHome
|
2
2
|
class CharacteristicFactory
|
3
|
-
DEFAULT_VALUES = {
|
4
|
-
identify: nil,
|
5
|
-
}.freeze
|
6
|
-
|
7
3
|
def self.create(characteristic_name, service: , subtype: 'default' , value: nil)
|
8
4
|
new(
|
9
5
|
characteristic_name: characteristic_name,
|
@@ -22,7 +18,7 @@ module RubyHome
|
|
22
18
|
service: service,
|
23
19
|
unit: template.unit,
|
24
20
|
uuid: template.uuid,
|
25
|
-
|
21
|
+
value_object: value_object
|
26
22
|
)
|
27
23
|
|
28
24
|
if persisted_characteristic
|
@@ -54,11 +50,11 @@ module RubyHome
|
|
54
50
|
@template ||= CharacteristicTemplate.find_by(name: characteristic_name)
|
55
51
|
end
|
56
52
|
|
57
|
-
def
|
58
|
-
|
53
|
+
def value_object
|
54
|
+
value_object_class.new(template, @requested_value)
|
59
55
|
end
|
60
56
|
|
61
|
-
def
|
57
|
+
def value_object_class
|
62
58
|
BaseValue.value_for_template(template)
|
63
59
|
end
|
64
60
|
|
@@ -23,7 +23,7 @@ module RubyHome
|
|
23
23
|
'write' => 'pw',
|
24
24
|
}.freeze
|
25
25
|
|
26
|
-
def initialize(uuid:, name:, description:, format:, unit:, properties:, service: ,
|
26
|
+
def initialize(uuid:, name:, description:, format:, unit:, properties:, service: , value_object: )
|
27
27
|
@uuid = uuid
|
28
28
|
@name = name
|
29
29
|
@description = description
|
@@ -31,7 +31,7 @@ module RubyHome
|
|
31
31
|
@unit = unit
|
32
32
|
@properties = properties
|
33
33
|
@service = service
|
34
|
-
@
|
34
|
+
@value_object = value_object
|
35
35
|
end
|
36
36
|
|
37
37
|
attr_reader(
|
@@ -42,7 +42,8 @@ module RubyHome
|
|
42
42
|
:format,
|
43
43
|
:unit,
|
44
44
|
:properties,
|
45
|
-
:instance_id
|
45
|
+
:instance_id,
|
46
|
+
:value_object,
|
46
47
|
)
|
47
48
|
|
48
49
|
def instance_id=(new_id)
|
@@ -59,11 +60,11 @@ module RubyHome
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def value
|
62
|
-
|
63
|
+
value_object.value
|
63
64
|
end
|
64
65
|
|
65
66
|
def value=(new_value)
|
66
|
-
|
67
|
+
value_object.value = new_value
|
67
68
|
broadcast(:after_update, self)
|
68
69
|
end
|
69
70
|
end
|
data/lib/ruby_home/hap/server.rb
CHANGED
@@ -65,8 +65,8 @@ module RubyHome
|
|
65
65
|
|
66
66
|
return close(socket) unless request.keep_alive?
|
67
67
|
return close(socket) unless response.keep_alive?
|
68
|
-
rescue Errno::ECONNRESET, Errno::
|
69
|
-
Errno::
|
68
|
+
rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EHOSTUNREACH,
|
69
|
+
Errno::EINVAL, Errno::EPROTO, Errno::ETIMEDOUT
|
70
70
|
close(socket)
|
71
71
|
rescue EOFError
|
72
72
|
close(socket)
|
@@ -79,4 +79,3 @@ module RubyHome
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
@@ -14,22 +14,26 @@ module RubyHome
|
|
14
14
|
'perms' => perms(characteristic),
|
15
15
|
'format' => characteristic.format,
|
16
16
|
'description' => characteristic.description,
|
17
|
-
}.merge(
|
17
|
+
}.merge(value_hash(characteristic))
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end.compact
|
24
|
-
end
|
20
|
+
private
|
21
|
+
|
22
|
+
HIDDEN_VALUE_OBJECTS = [ IdentifyValue ].freeze
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
def perms(characteristic)
|
25
|
+
characteristic.properties.map do |property|
|
26
|
+
RubyHome::Characteristic::PROPERTIES[property]
|
27
|
+
end.compact
|
28
|
+
end
|
29
|
+
|
30
|
+
def value_hash(characteristic)
|
31
|
+
if HIDDEN_VALUE_OBJECTS.include?(characteristic.value_object.class)
|
32
|
+
{}
|
33
|
+
else
|
34
|
+
{ 'value' => characteristic.value }.compact
|
30
35
|
end
|
31
36
|
end
|
32
|
-
end
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
data/lib/ruby_home/version.rb
CHANGED
data/rubyhome.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency 'dnssd', '~> 3.0'
|
31
31
|
spec.add_dependency 'hkdf', '~> 0.3.0'
|
32
32
|
spec.add_dependency 'nio4r', '~> 2.3', '>= 2.3.1'
|
33
|
-
spec.add_dependency 'oj', '3.7.
|
33
|
+
spec.add_dependency 'oj', '3.7.4'
|
34
34
|
spec.add_dependency 'rbnacl', '~> 6.0'
|
35
35
|
spec.add_dependency 'ruby_home-srp', '~> 1.2'
|
36
36
|
spec.add_dependency 'sinatra', '2.0.4'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_home
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Entwistle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -98,14 +98,14 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - '='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 3.7.
|
101
|
+
version: 3.7.4
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - '='
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: 3.7.
|
108
|
+
version: 3.7.4
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: rbnacl
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- lib/ruby_home/hap/values/base_value.rb
|
301
301
|
- lib/ruby_home/hap/values/bool_value.rb
|
302
302
|
- lib/ruby_home/hap/values/float_value.rb
|
303
|
+
- lib/ruby_home/hap/values/identify_value.rb
|
303
304
|
- lib/ruby_home/hap/values/int32_value.rb
|
304
305
|
- lib/ruby_home/hap/values/null_value.rb
|
305
306
|
- lib/ruby_home/hap/values/string_value.rb
|