openhab-scripting 4.39.1 → 4.40.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aaa16073cb2b4d71edb5e80debef49282a864bad1e057fb307b5cd8b9ca7844
|
4
|
+
data.tar.gz: 641502dca198f6cf42d5a489153f6c04fd3bf70900d4a0873bfb01d686bea6b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 978fe9d74ac7bc6481bb59cfb32a5c917f7707933e68d686be6119096f64daf78a49af1c9e4870abaecc0eec234e50314fae8093f1f04d1c38f6e15cdbe89bd9
|
7
|
+
data.tar.gz: b959d2aef01f436f90a56142e4e2c9a4a532de091bd846b97b799a609e16d849d5df2e3de77d91b0a2de588f0da6cf3e6904205b9236538c123484552484565f
|
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
|
3
|
+
require 'delegate'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
require_relative 'metadata'
|
7
|
+
require_relative 'persistence'
|
8
|
+
require_relative 'semantics'
|
6
9
|
|
7
10
|
require_relative 'item_equality'
|
8
11
|
|
@@ -170,6 +173,17 @@ module OpenHAB
|
|
170
173
|
other.instance_of?(self.class) && hash == other.hash
|
171
174
|
end
|
172
175
|
|
176
|
+
#
|
177
|
+
# A method to indicate that item comparison is requested instead of state comparison
|
178
|
+
#
|
179
|
+
# Example: Item1.item == items['Item1'].item should return true
|
180
|
+
#
|
181
|
+
# See ItemEquality#==
|
182
|
+
#
|
183
|
+
def item
|
184
|
+
@item ||= GenericItemObject.new(self)
|
185
|
+
end
|
186
|
+
|
173
187
|
# @!method null?
|
174
188
|
# Check if the item state == +NULL+
|
175
189
|
# @return [Boolean]
|
@@ -201,5 +215,15 @@ module OpenHAB
|
|
201
215
|
end
|
202
216
|
end
|
203
217
|
end
|
218
|
+
|
219
|
+
# A helper class to flag that item comparison is wanted instead of state comparison
|
220
|
+
# It is used by ItemEquality#===
|
221
|
+
class GenericItemObject < SimpleDelegator
|
222
|
+
extend Forwardable
|
223
|
+
include Log
|
224
|
+
include OpenHAB::DSL::Items::ItemEquality
|
225
|
+
|
226
|
+
def_delegator :__getobj__, :instance_of? # instance_of? is used by GenericItem#eql? to check for item equality
|
227
|
+
end
|
204
228
|
end
|
205
229
|
end
|
@@ -22,7 +22,8 @@ module OpenHAB
|
|
22
22
|
# @return [Boolean]
|
23
23
|
#
|
24
24
|
def ==(other)
|
25
|
-
logger.trace
|
25
|
+
logger.trace { "ItemEquality#== (#{self.class}) #{self} == #{other} (#{other.class})" }
|
26
|
+
return eql?(other) if generic_item_object?(other)
|
26
27
|
return true if equal?(other) || eql?(other)
|
27
28
|
return true if !state? && other.nil?
|
28
29
|
|
@@ -30,6 +31,28 @@ module OpenHAB
|
|
30
31
|
|
31
32
|
state == other
|
32
33
|
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Check item object equality for grep
|
37
|
+
#
|
38
|
+
def ===(other)
|
39
|
+
logger.trace { "ItemEquality#=== (#{self.class}) #{self} == #{other} (#{other.class})" }
|
40
|
+
eql?(other)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
#
|
46
|
+
# Determines if an object equality check is required, based on whether
|
47
|
+
# either operand is a GenericItemObject
|
48
|
+
#
|
49
|
+
# @param [Object] other
|
50
|
+
#
|
51
|
+
# @return [Boolean]
|
52
|
+
#
|
53
|
+
def generic_item_object?(other)
|
54
|
+
other.is_a?(OpenHAB::DSL::GenericItemObject) || is_a?(OpenHAB::DSL::GenericItemObject)
|
55
|
+
end
|
33
56
|
end
|
34
57
|
end
|
35
58
|
end
|
@@ -57,7 +57,7 @@ module OpenHAB
|
|
57
57
|
# @return [Boolean]
|
58
58
|
#
|
59
59
|
def ==(other) # rubocop:disable Metrics
|
60
|
-
logger.trace
|
60
|
+
logger.trace { "(#{self.class}) #{self} == #{other} (#{other.class})" }
|
61
61
|
if other.is_a?(Items::LocationItem) ||
|
62
62
|
(other.is_a?(Items::GroupItem) && other.base_item.is_a?(LocationItem))
|
63
63
|
return false unless other.state?
|
@@ -48,8 +48,8 @@ module OpenHAB
|
|
48
48
|
# or item state of the same type
|
49
49
|
#
|
50
50
|
def ===(other)
|
51
|
-
logger.trace
|
52
|
-
other = other.state if other.respond_to?(:state)
|
51
|
+
logger.trace { "Type (#{self.class}) #{self} === #{other} (#{other.class})" }
|
52
|
+
other = other.state if other.respond_to?(:state) && !other.is_a?(OpenHAB::DSL::GenericItemObject)
|
53
53
|
return false unless instance_of?(other.class)
|
54
54
|
|
55
55
|
eql?(other)
|
@@ -62,7 +62,7 @@ module OpenHAB
|
|
62
62
|
# type conversions
|
63
63
|
#
|
64
64
|
def ==(other) # rubocop:disable Metrics
|
65
|
-
logger.trace
|
65
|
+
logger.trace { "(#{self.class}) #{self} == #{other} (#{other.class})" }
|
66
66
|
return true if equal?(other)
|
67
67
|
|
68
68
|
# i.e. ON == OFF, REFRESH == ON, ON == REFRESH
|
data/lib/openhab/version.rb
CHANGED