openhab-scripting 4.40.0 → 4.41.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7aaa16073cb2b4d71edb5e80debef49282a864bad1e057fb307b5cd8b9ca7844
4
- data.tar.gz: 641502dca198f6cf42d5a489153f6c04fd3bf70900d4a0873bfb01d686bea6b7
3
+ metadata.gz: 101fdd6964b1dd5eaefcf5ecaf528ecc01ca12c280440da11ce8646d10fbd67c
4
+ data.tar.gz: 40bf18765cc29aee28d9ae486cd7c965435f5cbcf8f47867559bb72ccec7f3d9
5
5
  SHA512:
6
- metadata.gz: 978fe9d74ac7bc6481bb59cfb32a5c917f7707933e68d686be6119096f64daf78a49af1c9e4870abaecc0eec234e50314fae8093f1f04d1c38f6e15cdbe89bd9
7
- data.tar.gz: b959d2aef01f436f90a56142e4e2c9a4a532de091bd846b97b799a609e16d849d5df2e3de77d91b0a2de588f0da6cf3e6904205b9236538c123484552484565f
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
- # otherwise, it's a non-nil thing comparing to nil, which is undefined
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
- # Returns +self+ if this Item is a Location. Otherwise, checks ancestor
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
- # Returns +self+ if this Item is an Equipment. Otherwise, checks ancestor
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 sublocations(type = nil)
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
  #
@@ -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}_enabled?") { @sl4fj_logger.send("is_#{level}_enabled") }
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 trace_enabled?
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 debug_enabled?
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}_enabled?")
127
+ return unless send("#{severity}?")
126
128
 
127
129
  # Process block if no message provided
128
130
  msg = yield if msg.nil? && block_given?
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '4.40.0'
8
+ VERSION = '4.41.0'
9
9
  end
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.40.0
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-24 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler