openhab-scripting 4.40.0 → 4.41.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 +4 -4
- data/lib/openhab/dsl/items/comparable_item.rb +22 -10
- data/lib/openhab/dsl/items/semantics.rb +5 -5
- data/lib/openhab/log/logger.rb +6 -4
- data/lib/openhab/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 101fdd6964b1dd5eaefcf5ecaf528ecc01ca12c280440da11ce8646d10fbd67c
|
4
|
+
data.tar.gz: 40bf18765cc29aee28d9ae486cd7c965435f5cbcf8f47867559bb72ccec7f3d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a8ce171ac466b46f28e5a5abc59cc2de62a20d16210e58fb7ea33b6ee5a6ad0b9399afb40491142d52396cbbee33b5be444f4d5530176b9ac34764f06a4ec5b
|
7
|
+
data.tar.gz: 57171fa39cfc71afaa8d8cb7488e184ea031cf6f8b01a135410a97317399e8a478d6cf9691ba81168d023882c488b07de5f47a921e516a05589bd198731da8b8
|
@@ -9,9 +9,12 @@ module OpenHAB
|
|
9
9
|
#
|
10
10
|
# Comparison
|
11
11
|
#
|
12
|
-
# @param [GenericItem, Types::Type, Object] other object to
|
12
|
+
# @param [GenericItem, Types::Type, Object, GenericItemObject] other object to
|
13
13
|
# compare to
|
14
14
|
#
|
15
|
+
# When comparing GenericItemObject on either side, perform object comparison
|
16
|
+
# return 0 if the object is equal, or nil otherwise.
|
17
|
+
#
|
15
18
|
# If this item is +NULL+ or +UNDEF+, and +other+ is nil, they are
|
16
19
|
# considered equal
|
17
20
|
#
|
@@ -28,21 +31,30 @@ module OpenHAB
|
|
28
31
|
#
|
29
32
|
def <=>(other)
|
30
33
|
logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
|
31
|
-
# if we're NULL or UNDEF, implement special logic
|
32
|
-
unless state?
|
33
|
-
# if comparing to nil, consider ourselves equal
|
34
|
-
return 0 if other.nil?
|
35
|
-
# if the other object is an Item, only consider equal if we're
|
36
|
-
# in the same _kind_ of UnDefType state
|
37
|
-
return raw_state == other.raw_state if other.is_a?(GenericItem) && !other.state?
|
38
34
|
|
39
|
-
|
40
|
-
return nil
|
35
|
+
if is_a?(OpenHAB::DSL::GenericItemObject) || other.is_a?(OpenHAB::DSL::GenericItemObject)
|
36
|
+
return eql?(other) ? 0 : nil
|
41
37
|
end
|
42
38
|
|
39
|
+
# if we're NULL or UNDEF, implement special logic
|
40
|
+
return nil_comparison unless state?
|
41
|
+
|
43
42
|
# delegate to how the state compares to the other object
|
44
43
|
state <=> other
|
45
44
|
end
|
45
|
+
|
46
|
+
# Special logic for NULL/UNDEF state comparison
|
47
|
+
# @!visibility private
|
48
|
+
def nil_comparison
|
49
|
+
# if comparing to nil, consider ourselves equal
|
50
|
+
return 0 if other.nil?
|
51
|
+
# if the other object is an Item, only consider equal if we're
|
52
|
+
# in the same _kind_ of UnDefType state
|
53
|
+
return raw_state == other.raw_state if other.is_a?(GenericItem) && !other.state?
|
54
|
+
|
55
|
+
# otherwise, it's a non-nil thing comparing to nil, which is undefined
|
56
|
+
nil
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
48
60
|
end
|
@@ -73,8 +73,7 @@ module OpenHAB
|
|
73
73
|
|
74
74
|
# Gets the related Location Item of this Item.
|
75
75
|
#
|
76
|
-
#
|
77
|
-
# groups one level at a time, returning the first Location Item found.
|
76
|
+
# Checks ancestor groups one level at a time, returning the first Location Item found.
|
78
77
|
#
|
79
78
|
# @return [GenericItem, nil]
|
80
79
|
def location
|
@@ -92,8 +91,7 @@ module OpenHAB
|
|
92
91
|
|
93
92
|
# Gets the related Equipment Item of this Item.
|
94
93
|
#
|
95
|
-
#
|
96
|
-
# groups one level at a time, returning the first Equipment Item found.
|
94
|
+
# Checks ancestor groups one level at a time, returning the first Equipment Item found.
|
97
95
|
#
|
98
96
|
# @return [GenericItem, nil]
|
99
97
|
def equipment
|
@@ -173,7 +171,7 @@ end
|
|
173
171
|
# Additions to Enumerable to allow easily filtering groups of items based on the semantic model
|
174
172
|
module Enumerable
|
175
173
|
# Returns a new array of items that are a semantics Location (optionally of the given type)
|
176
|
-
def
|
174
|
+
def locations(type = nil)
|
177
175
|
if type && !(type < OpenHAB::DSL::Items::Semantics::Location)
|
178
176
|
raise ArgumentError, 'type must be a subclass of Location'
|
179
177
|
end
|
@@ -183,6 +181,8 @@ module Enumerable
|
|
183
181
|
|
184
182
|
result
|
185
183
|
end
|
184
|
+
# @deprecated Please use {#locations}
|
185
|
+
alias sublocations locations
|
186
186
|
|
187
187
|
# Returns a new array of items that are a semantics equipment (optionally of the given type)
|
188
188
|
#
|
data/lib/openhab/log/logger.rb
CHANGED
@@ -54,7 +54,9 @@ module OpenHAB
|
|
54
54
|
define_method(level) do |msg = nil, &block|
|
55
55
|
log(severity: level, msg: msg, &block)
|
56
56
|
end
|
57
|
-
define_method("#{level}
|
57
|
+
define_method("#{level}?") { @sl4fj_logger.send("is_#{level}_enabled") }
|
58
|
+
# @deprecated
|
59
|
+
alias_method "#{level}_enabled?", "#{level}?"
|
58
60
|
end
|
59
61
|
|
60
62
|
#
|
@@ -62,7 +64,7 @@ module OpenHAB
|
|
62
64
|
# @param [String] preamble to put at start of log message
|
63
65
|
# @param [Hash] kwargs key and values to log
|
64
66
|
def state(preamble = 'State:', **kwargs)
|
65
|
-
return unless
|
67
|
+
return unless trace?
|
66
68
|
|
67
69
|
states = kwargs.transform_keys(&:to_s)
|
68
70
|
.transform_keys(&:capitalize)
|
@@ -82,7 +84,7 @@ module OpenHAB
|
|
82
84
|
# @return [Exception] the exception, potentially with a cleaned backtrace.
|
83
85
|
#
|
84
86
|
def clean_backtrace(error)
|
85
|
-
return error if
|
87
|
+
return error if debug?
|
86
88
|
|
87
89
|
if error.respond_to? :backtrace_locations
|
88
90
|
backtrace = error.backtrace_locations.map(&:to_s).grep_v(INTERNAL_CALL_REGEX)
|
@@ -122,7 +124,7 @@ module OpenHAB
|
|
122
124
|
raise ArgumentError, "Unknown Severity #{severity}" unless LEVELS.include? severity
|
123
125
|
|
124
126
|
# Dynamically check enablement of underlying logger, this expands to "is_<level>_enabled"
|
125
|
-
return unless send("#{severity}
|
127
|
+
return unless send("#{severity}?")
|
126
128
|
|
127
129
|
# Process block if no message provided
|
128
130
|
msg = yield if msg.nil? && block_given?
|
data/lib/openhab/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openhab-scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.41.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian O'Connell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|