openhab-scripting 5.38.2 → 5.38.3

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: 80e5c451235909f43f9b0b0a82f80a501f0a978d65f52d3bc8dcf8ae5e74fd5e
4
- data.tar.gz: 57633cd38589cc8e9bd8d11c0bccf66761cdf0aaaffcdde4b6c77ee9388df527
3
+ metadata.gz: 5d7aee54d03e87992e3febb4d12eef831d42156837dcd7b8ed61e09edbf78a3d
4
+ data.tar.gz: c9a792688e50984ef7463eb6e49abbfbdbccd4ab619d704b3d4eca0537f7a5f7
5
5
  SHA512:
6
- metadata.gz: 67035be352872b9eb97049875648d7e3c5c190e8ea10ee6eb580f039266746f927d24b51844c022c19e75dadd20baaf23450fb35d34d6df43b5046f7cf4fedc9
7
- data.tar.gz: 74be0ee645c5ba2b480250a5dd3db36773596bb8aec3e0e27b5e96b48da765e4cf5a544d1ae4613ac761c6662e17bde7b1c5bce34038c212080f682dda64508d
6
+ metadata.gz: 3e23bd7be96cbaf3e3b6ad00d731562f2059e1f2061f5e34f2bf25ef1087b06ccd77bc916ecb8b2aff55ce6de75cb24feac730fa2a2171f444e518ac1688c1a7
7
+ data.tar.gz: '0149d4812c49c7bdd7ae5b7919deeccc068bfc1acf42b94c8962e67a8657252f55269648706759f9f55cb7e73573314273b73f9a6af7b2264111c8c87874c5b1'
@@ -2,10 +2,10 @@
2
2
 
3
3
  require "openhab/console/stdio"
4
4
 
5
- gem "irb", "~> 1.15"
6
-
7
5
  require "irb"
8
6
 
7
+ raise "IRB Version 1.14 or later is required." unless Gem::Version.new(IRB::VERSION) >= Gem::Version.new("1.14")
8
+
9
9
  module OpenHAB
10
10
  # @!visibility private
11
11
  module Console
@@ -8,10 +8,30 @@ module OpenHAB
8
8
  # Add attachments event data.
9
9
  class AbstractEvent
10
10
  # @return [Object]
11
- attr_accessor :attachment
11
+ attr_reader :attachment
12
12
 
13
13
  # @return [Hash]
14
- attr_accessor :inputs
14
+ attr_reader :inputs
15
+
16
+ # @!visibility private
17
+ def attachment=(value)
18
+ # Disable "instance vars on non-persistent Java type"
19
+ original_verbose = $VERBOSE
20
+ $VERBOSE = nil
21
+ @attachment = value
22
+ ensure
23
+ $VERBOSE = original_verbose
24
+ end
25
+
26
+ # @!visibility private
27
+ def inputs=(value)
28
+ # Disable "instance vars on non-persistent Java type"
29
+ original_verbose = $VERBOSE
30
+ $VERBOSE = nil
31
+ @inputs = value
32
+ ensure
33
+ $VERBOSE = original_verbose
34
+ end
15
35
 
16
36
  # @!attribute [r] source
17
37
  # @return [String] The component that sent the event.
@@ -24,7 +44,12 @@ module OpenHAB
24
44
  #
25
45
  def payload
26
46
  require "json"
47
+ # Disable "instance vars on non-persistent Java type"
48
+ original_verbose = $VERBOSE
49
+ $VERBOSE = nil
27
50
  @payload ||= JSON.parse(get_payload, symbolize_names: true) unless get_payload.empty?
51
+ ensure
52
+ $VERBOSE = original_verbose
28
53
  end
29
54
 
30
55
  # @return [String]
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "base64"
4
3
  require "pathname"
5
4
  require "net/http"
6
5
  require "marcel"
@@ -25,10 +25,10 @@ module OpenHAB
25
25
  OpenHAB::OSGi.service("org.openhab.core.io.rest.sse.internal.SseItemStatesEventBuilder")&.tap do |builder|
26
26
  m = builder.class.java_class.get_declared_method("getDisplayState", Item, java.util.Locale)
27
27
  m.accessible = true
28
- builder.instance_variable_set(:@getDisplayState, m)
29
28
  # Disable "singleton on non-persistent Java type"
30
29
  original_verbose = $VERBOSE
31
30
  $VERBOSE = nil
31
+ builder.instance_variable_set(:@getDisplayState, m)
32
32
  def builder.get_display_state(item)
33
33
  @getDisplayState.invoke(self, item, nil)
34
34
  end
@@ -390,7 +390,7 @@ module OpenHAB
390
390
  # # Item1's metadata after: {"namespace2"=>["value", {"config1"=>"foo", "config2"=>"bar"}], "namespace"=>["value", {"config1"=>"foo", "config2"=>"bar"}]}
391
391
  #
392
392
  def metadata
393
- @metadata ||= Metadata::NamespaceHash.new(name)
393
+ Metadata::NamespaceHash.new(name)
394
394
  end
395
395
  # rubocop:enable Layout/LineLength
396
396
 
@@ -8,16 +8,23 @@ module OpenHAB
8
8
  # and channels.
9
9
  #
10
10
  module ProfileCallback
11
+ class << self
12
+ # @!visibility private
13
+ def dummy_channel_item(accepted_item_type)
14
+ @dummy_channel_items[accepted_item_type]
15
+ end
16
+ end
17
+ @dummy_channel_items = Hash.new do |hash, key|
18
+ hash[key] = DSL::Items::ItemBuilder.item_factory.create_item(key, "")
19
+ end
20
+
11
21
  #
12
22
  # Forward the given command to the respective thing handler.
13
23
  #
14
24
  # @param [Command] command
15
25
  #
16
26
  def handle_command(command)
17
- unless instance_variable_defined?(:@dummy_channel_item)
18
- @dummy_channel_item = DSL::Items::ItemBuilder.item_factory.create_item(link.channel.accepted_item_type, "")
19
- end
20
- command = @dummy_channel_item.format_command(command) if @dummy_channel_item
27
+ command = ProfileCallback.dummy_channel_item(link.channel.accepted_item_type)&.format_command(command)
21
28
  super
22
29
  end
23
30
 
@@ -175,7 +175,7 @@ module OpenHAB
175
175
 
176
176
  # @see https://docs.ruby-lang.org/en/master/Hash.html#method-i-to_proc Hash#to_proc
177
177
  def to_proc
178
- @to_proc ||= ->(k) { self[k] }
178
+ ->(k) { self[k] }
179
179
  end
180
180
 
181
181
  # @see https://docs.ruby-lang.org/en/master/Hash.html#method-i-values_at Hash#values_at
@@ -87,9 +87,9 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
87
87
  def delete_if
88
88
  raise NotImplementedError unless block_given?
89
89
 
90
- it = list_iterator
91
- while it.has_next? # rubocop:disable Style/WhileUntilModifier
92
- it.remove if yield(it.next)
90
+ itr = list_iterator
91
+ while itr.has_next? # rubocop:disable Style/WhileUntilModifier
92
+ itr.remove if yield(itr.next)
93
93
  end
94
94
  self
95
95
  end
@@ -160,17 +160,17 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
160
160
  start = range.begin
161
161
  start = 0 if start.negative?
162
162
  start = length if start > length
163
- it = list_iterator(start)
163
+ itr = list_iterator(start)
164
164
 
165
- while range.cover?(it.next_index)
166
- break if range.end.nil? && !it.has_next?
165
+ while range.cover?(itr.next_index)
166
+ break if range.end.nil? && !itr.has_next?
167
167
 
168
- obj = yield(it.next_index) if block_given?
169
- if it.has_next?
170
- it.next
171
- it.set(obj)
168
+ obj = yield(itr.next_index) if block_given?
169
+ if itr.has_next?
170
+ itr.next
171
+ itr.set(obj)
172
172
  else
173
- it.add(obj)
173
+ itr.add(obj)
174
174
  end
175
175
  end
176
176
 
@@ -183,22 +183,22 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
183
183
  "wrong number of arguments calling `flatten` (given #{args.length}, expect 0..1)"
184
184
  end
185
185
 
186
- it = list_iterator
186
+ itr = list_iterator
187
187
 
188
188
  args = [args.first - 1] unless args.empty?
189
189
  done = args.first == 0 # rubocop:disable Style/NumericPredicate
190
190
 
191
191
  changed = false
192
- while it.has_next?
193
- element = it.next
192
+ while itr.has_next?
193
+ element = itr.next
194
194
  next unless element.respond_to?(:to_ary)
195
195
 
196
196
  changed = true
197
- it.remove
197
+ itr.remove
198
198
  arr = element.to_ary
199
199
  arr = arr.flatten(*args) unless done
200
200
  arr.each do |e|
201
- it.add(e)
201
+ itr.add(e)
202
202
  end
203
203
  end
204
204
  changed ? self : nil
@@ -223,9 +223,9 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
223
223
  def keep_if?
224
224
  raise NotImplementedError unless block_given?
225
225
 
226
- it = list_iterator
227
- while it.has_next? # rubocop:disable Style/WhileUntilModifier
228
- it.remove unless yield(it.next)
226
+ itr = list_iterator
227
+ while itr.has_next? # rubocop:disable Style/WhileUntilModifier
228
+ itr.remove unless yield(itr.next)
229
229
  end
230
230
  self
231
231
  end
@@ -257,10 +257,10 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
257
257
  count = args.first
258
258
  start = [length - count, 0].max
259
259
  result = self[start..-1].to_a # rubocop:disable Style/SlicingWithRange
260
- it = list_iterator(start)
261
- while it.has_next?
262
- it.next
263
- it.remove
260
+ itr = list_iterator(start)
261
+ while itr.has_next?
262
+ itr.next
263
+ itr.remove
264
264
  end
265
265
  result
266
266
  end
@@ -278,12 +278,12 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
278
278
  def reject!
279
279
  raise NotImplementedError unless block_given?
280
280
 
281
- it = list_iterator
281
+ itr = list_iterator
282
282
  changed = false
283
- while it.has_next
284
- if yield(it.next)
283
+ while itr.has_next
284
+ if yield(itr.next)
285
285
  changed = true
286
- it.remove
286
+ itr.remove
287
287
  end
288
288
  end
289
289
  self if changed
@@ -319,12 +319,12 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
319
319
  def select!
320
320
  raise NotImplementedError unless block_given?
321
321
 
322
- it = list_iterator
322
+ itr = list_iterator
323
323
  changed = false
324
- while it.has_next?
325
- unless yield(it.next)
324
+ while itr.has_next?
325
+ unless yield(itr.next)
326
326
  changed = true
327
- it.remove
327
+ itr.remove
328
328
  end
329
329
  end
330
330
  self if changed
@@ -344,12 +344,12 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
344
344
 
345
345
  count = args.first
346
346
  result = self[0...count].to_a
347
- it = list_iterator
347
+ itr = list_iterator
348
348
  count.times do
349
- break unless it.has_next?
349
+ break unless itr.has_next?
350
350
 
351
- it.next
352
- it.remove
351
+ itr.next
352
+ itr.remove
353
353
  end
354
354
  result
355
355
  end
@@ -377,10 +377,10 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
377
377
 
378
378
  result = slice(*args).to_a
379
379
 
380
- it = list_iterator(start)
380
+ itr = list_iterator(start)
381
381
  result.length.times do
382
- it.next
383
- it.remove
382
+ itr.next
383
+ itr.remove
384
384
  end
385
385
  result
386
386
  end
@@ -395,14 +395,14 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
395
395
  def uniq!
396
396
  seen = Set.new
397
397
 
398
- it = list_iterator
398
+ itr = list_iterator
399
399
  changed = false
400
- while it.has_next?
401
- n = it.next
400
+ while itr.has_next?
401
+ n = itr.next
402
402
  n = yield(n) if block_given?
403
403
  if seen.include?(n)
404
404
  changed = true
405
- it.remove
405
+ itr.remove
406
406
  end
407
407
  seen << n
408
408
  end
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.38.2"
7
+ VERSION = "5.38.3"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openhab-scripting
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.38.2
4
+ version: 5.38.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '8.0'
62
+ version: '9.2'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '8.0'
69
+ version: '9.2'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: cuke_linter
72
72
  requirement: !ruby/object:Gem::Requirement