openhab-scripting 4.11.0 → 4.12.1

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: 7f4fc0e817de7a0a8ef1892e7e397552afb897bc45983935a73ab39f03975733
4
- data.tar.gz: 756291721126083940a335788551a7d1bafdd7643b0bd4cd5cb3bedb7b576ae0
3
+ metadata.gz: f6e235cb755ab3a382e6c26092492655347aeb90fb93b4449c64c7ae78b084ba
4
+ data.tar.gz: 6c595a32a957415cee2e0588bc1dd044f797c9b9c678ea4c130ac37f80d72f0b
5
5
  SHA512:
6
- metadata.gz: 58b0de14c919cdc09bef1d8f37c782052a8a36740feddf797e2a8d38a112b334d795a270b757dbae3938269faf29b117aceb303de2c3878da608214aeb25e7fc
7
- data.tar.gz: a0079a59f25d709814f20527045d7b7c57f4b7c702f3618c616be56117e60b7e0920d023d19d2752556f41f2a85b3e617280e00176a2d60513bef07a0067e882
6
+ metadata.gz: 7641e9056c5a0b2d4e004a585bfddf5fb4c51f4228f3df9dacea2b4af3efcb7a48ca0a38214d92a6571bf5de481dae49a7c62582f917a2226d211b8070ffeac6
7
+ data.tar.gz: 7cd6598c839a75c773b92000660663f2abcee197a128b66323cdcfbd3c0ca887d813fcee0eb207e112e0e19d502919ec938e822fcf8543edcd1d481edd682bfc
@@ -29,7 +29,7 @@ module OpenHAB
29
29
 
30
30
  def initialize(metadata: nil, key: nil, value: nil, config: nil)
31
31
  @metadata = metadata || Metadata.new(key || MetadataKey.new('', ''), value&.to_s, config)
32
- super(to_ruby(@metadata&.configuration))
32
+ super(MetadataItem.to_ruby(@metadata&.configuration))
33
33
  end
34
34
 
35
35
  #
@@ -86,8 +86,6 @@ module OpenHAB
86
86
  [@metadata&.value, @metadata&.configuration || {}]
87
87
  end
88
88
 
89
- private
90
-
91
89
  #
92
90
  # Recursively convert the supplied Hash object into a Ruby Hash and recreate the keys and values
93
91
  #
@@ -95,7 +93,7 @@ module OpenHAB
95
93
  #
96
94
  # @return [Hash] The converted hash
97
95
  #
98
- def to_ruby_hash(hash)
96
+ def self.to_ruby_hash(hash)
99
97
  return unless hash.respond_to? :each_with_object
100
98
 
101
99
  hash.each_with_object({}) { |(key, value), ruby_hash| ruby_hash[to_ruby(key)] = to_ruby(value) }
@@ -108,14 +106,14 @@ module OpenHAB
108
106
  #
109
107
  # @return [Array] The converted array
110
108
  #
111
- def to_ruby_array(array)
109
+ def self.to_ruby_array(array)
112
110
  return unless array.respond_to? :each_with_object
113
111
 
114
112
  array.each_with_object([]) { |value, ruby_array| ruby_array << to_ruby(value) }
115
113
  end
116
114
 
117
115
  # Convert the given object to Ruby equivalent
118
- def to_ruby(value)
116
+ def self.to_ruby(value)
119
117
  case value
120
118
  when Hash, Java::JavaUtil::Map then to_ruby_hash(value)
121
119
  when Array, Java::JavaUtil::List then to_ruby_array(value)
@@ -188,7 +186,9 @@ module OpenHAB
188
186
  return unless block_given?
189
187
 
190
188
  NamespaceAccessor.registry.getAll.each do |meta|
191
- yield meta.uID.namespace, meta.value, meta.configuration if meta.uID.itemName == @item_name
189
+ if meta.uID.itemName == @item_name
190
+ yield meta.uID.namespace, MetadataItem.to_ruby(meta.value), MetadataItem.to_ruby(meta.configuration)
191
+ end
192
192
  end
193
193
  end
194
194
 
@@ -58,11 +58,11 @@ module OpenHAB
58
58
  timer = @timer_manager.reentrant_timer(id: id, &block)
59
59
  if timer
60
60
  logger.trace("Reentrant timer found - #{timer}")
61
- timer.reschedule
61
+ timer.cancel
62
62
  else
63
63
  logger.trace('No reentrant timer found, creating new timer')
64
- ReentrantTimer.new(duration: duration, id: id, &block)
65
64
  end
65
+ ReentrantTimer.new(duration: duration, id: id, &block)
66
66
  end
67
67
  end
68
68
  end
@@ -50,6 +50,9 @@ module OpenHAB
50
50
  def <=>(other) # rubocop:disable Metrics
51
51
  logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})")
52
52
  if other.is_a?(self.class)
53
+ return unitize(other.unit).compare_to(other) if unit == ONE
54
+ return compare_to(other.unitize(unit)) if other.unit == ONE
55
+
53
56
  compare_to(other)
54
57
  elsif other.is_a?(Items::NumericItem) ||
55
58
  (other.is_a?(Items::GroupItem) && other.base_item.is_a?(NumericItem))
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '4.11.0'
8
+ VERSION = '4.12.1'
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.11.0
4
+ version: 4.12.1
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: 2021-11-05 00:00:00.000000000 Z
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -152,15 +152,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
- version: 2.5.0
155
+ version: 2.6.0
156
156
  required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubyforge_project:
163
- rubygems_version: 2.7.6.3
162
+ rubygems_version: 3.0.3.1
164
163
  signing_key:
165
164
  specification_version: 4
166
165
  summary: JRuby Helper Libraries for OpenHAB Scripting