openhab-scripting 3.4.1 → 3.4.2
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 +4 -4
- data/lib/openhab/dsl/monkey_patch/items/metadata.rb +39 -1
- data/lib/openhab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f309bd0e53d6ef4d8e738fb95507b79a3467e386b031a7e087c15502c20442cf
|
4
|
+
data.tar.gz: 0fbf71682ac4809b5d804f47ff3e847f8632d91a2749514c04abb6e7b5e02713
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b323582ae4bb7e8e5d5501353f0021437fa53f4170e098f51d518f30103d6a4241474678f80d1330d1c6257de354e58633ad16ea3e5e928315a2235aba51389
|
7
|
+
data.tar.gz: 56ea9c5ec2b80d16c4f9ccdd08fbab04a45aee6460947de4df219c800e2120fa6f169290886984c25b942408ebc62c13913f03bd9a7e54aa52468e5b7e308c72
|
@@ -30,7 +30,7 @@ module OpenHAB
|
|
30
30
|
|
31
31
|
def initialize(metadata: nil, key: nil, value: nil, config: nil)
|
32
32
|
@metadata = metadata || Metadata.new(key || MetadataKey.new('', ''), value&.to_s, config)
|
33
|
-
super(@metadata&.configuration)
|
33
|
+
super(to_ruby(@metadata&.configuration))
|
34
34
|
end
|
35
35
|
|
36
36
|
#
|
@@ -85,6 +85,44 @@ module OpenHAB
|
|
85
85
|
def to_a
|
86
86
|
[@metadata&.value, @metadata&.configuration || {}]
|
87
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
#
|
92
|
+
# Recursively convert the supplied Hash object into a Ruby Hash and recreate the keys and values
|
93
|
+
#
|
94
|
+
# @param [Hash] Hash to convert
|
95
|
+
#
|
96
|
+
# @return [Hash] The converted hash
|
97
|
+
#
|
98
|
+
def to_ruby_hash(hash)
|
99
|
+
return unless hash.respond_to? :each_with_object
|
100
|
+
|
101
|
+
hash.each_with_object({}) { |(key, value), ruby_hash| ruby_hash[to_ruby(key)] = to_ruby(value) }
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# Recursively convert the supplied array to a Ruby array and recreate all String values
|
106
|
+
#
|
107
|
+
# @param [Object] array to convert
|
108
|
+
#
|
109
|
+
# @return [Array] The converted array
|
110
|
+
#
|
111
|
+
def to_ruby_array(array)
|
112
|
+
return unless array.respond_to? :each_with_object
|
113
|
+
|
114
|
+
array.each_with_object([]) { |value, ruby_array| ruby_array << to_ruby(value) }
|
115
|
+
end
|
116
|
+
|
117
|
+
# Convert the given object to Ruby equivalent
|
118
|
+
def to_ruby(value)
|
119
|
+
case value
|
120
|
+
when Hash, Java::JavaUtil::Map then to_ruby_hash(value)
|
121
|
+
when Array, Java::JavaUtil::List then to_ruby_array(value)
|
122
|
+
when String then String.new(value)
|
123
|
+
else value
|
124
|
+
end
|
125
|
+
end
|
88
126
|
end
|
89
127
|
|
90
128
|
#
|
data/lib/openhab/version.rb
CHANGED