openhab-scripting 5.52.0 → 5.52.1

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: 44b392f4d106e9bc092ddf981e4597e6fd68c4d4eaca45120f6409712ec877ad
4
- data.tar.gz: cd319b4063c404b98d922878c5aaa75c8e5278be43ed05dc52d7e03d80d64e24
3
+ metadata.gz: 812b7da8502621c2f714866875c11481f05e8a58f095e754f95516a7d7c7ab5c
4
+ data.tar.gz: d5649ec57124b188ca983aa1c24985bfe54819d4b5f6940439ccb695e38c7596
5
5
  SHA512:
6
- metadata.gz: 3c0d8fabc27ea76a5aa3d9f9062f7371a61f20017535192ac410e57ac13c1c5a03b50970fdb61a6bdb7d6729572282765d55cec7475920037a23b761511dbf51
7
- data.tar.gz: a49a9d2f4827353397c126c30a89e9ffb00a50693ec3ca9d0b20bf9e7c05de972190e5bb60e0672f492553a63fa13622694c678006041c61a9038ce2ea6cf4f6
6
+ metadata.gz: 37898f5f960c4d26cfcf6f217d1279c28443a3218890b55a4befc6445c0b87491c3f2b65d7bf92247d280cc54e50dd54bbd53df6a6394968f951d4bde575834f
7
+ data.tar.gz: f91109958718c7ab2e0a0220f60a95ff65cb1e788f5455751fbbfbcc7bd94fe7bba409ad331a24592e55a4aef33348288f8987a907e70f82592cbcd802d8eb3e
@@ -12,6 +12,13 @@ module OpenHAB
12
12
  module IRB
13
13
  class Exit < Exception; end # rubocop:disable Lint/InheritException
14
14
 
15
+ module InteractiveStdin
16
+ def tty?
17
+ $stdin.tty?
18
+ end
19
+ end
20
+ STDIN.singleton_class.prepend(InteractiveStdin) # rubocop:disable Style/GlobalStdStream
21
+
15
22
  module Irb
16
23
  # Define #exit instead of using Kernel#exit, to raise an error if we're not
17
24
  # on the main thread (i.e. in the signal handler)
@@ -6,10 +6,11 @@ if defined?($dependencyListener)
6
6
  klass = Class.new(org.jruby.util.collections.StringArraySet) do
7
7
  def initialize(other)
8
8
  super(JRuby.runtime)
9
- other.each { |feature| append(feature) }
9
+ other.each { |feature| append(JRuby.runtime.current_context, feature) }
10
10
  end
11
11
 
12
- def append(name)
12
+ # JRuby's load service uses the overload that takes a ThreadContext.
13
+ def append(context, name)
13
14
  $dependencyListener.accept(name)
14
15
 
15
16
  super
@@ -102,14 +102,13 @@ module OpenHAB
102
102
  raise ArgumentError, "Specify one of bundle_or_actor, bundle or actor"
103
103
  end
104
104
 
105
- # rubocop:disable Style/CaseEquality
105
+ # rubocop:disable-next Style/CaseEquality
106
106
  components.any? do |sender|
107
107
  (bundle && bundle === sender.bundle) ||
108
108
  (actor && actor === sender.actor) ||
109
109
  (bundle_or_actor && bundle_or_actor === sender.bundle) ||
110
110
  (bundle_or_actor && bundle_or_actor === sender.actor)
111
111
  end
112
- # rubocop:enable Style/CaseEquality
113
112
  end
114
113
 
115
114
  #
@@ -557,7 +557,7 @@ end
557
557
  # @!parse Semantics = OpenHAB::Core::Items::Semantics
558
558
 
559
559
  # Additions to Enumerable to allow easily filtering groups of items based on the semantic model
560
- module Enumerable
560
+ module Enumerable # rubocop:disable Style/OneClassPerFile
561
561
  #
562
562
  # @!group Filtering Methods
563
563
  #
@@ -128,10 +128,10 @@ module OpenHAB
128
128
  .select { |k| k <= GenericItem && k != GroupItem && k != StringItem }
129
129
  .sort { |a, b| (a < b) ? 1 : -1 }
130
130
  .each do |klass|
131
- klass.field_reader :ACCEPTED_COMMAND_TYPES, :ACCEPTED_DATA_TYPES unless klass == GenericItem
131
+ klass.field_reader :ACCEPTED_COMMAND_TYPES, :ACCEPTED_DATA_TYPES unless klass == GenericItem
132
132
 
133
- def_predicate_methods(klass)
134
- def_command_methods(klass)
133
+ def_predicate_methods(klass)
134
+ def_command_methods(klass)
135
135
  end
136
136
 
137
137
  prepend_accepted_data_types
@@ -7,7 +7,8 @@ module OpenHAB
7
7
  # Compatibility helpers for old model-backed sitemaps and the new core sitemap registry.
8
8
  #
9
9
  # @deprecated OH 5.2: Remove entire module when dropping OH 5.1, collapsing calls to match the registry branch
10
- # Don't forget to remove the reference to it in .yardopts
10
+ # Don't forget to remove the reference to it in .yardopts
11
+ # @deprecated OH 5.3: Directly use argument for conditions and value for rules
11
12
  # @!visibility private
12
13
  module Compatibility
13
14
  class << self
@@ -15,6 +16,14 @@ module OpenHAB
15
16
  Provider.factory
16
17
  end
17
18
 
19
+ def set_rule_value(rule, value)
20
+ if rule.respond_to?(:value=)
21
+ rule.value = value
22
+ else
23
+ rule.argument = value
24
+ end
25
+ end
26
+
18
27
  if Provider.registry
19
28
  def supported_widget_type?(type)
20
29
  return true if type == :sitemap
@@ -35,7 +44,11 @@ module OpenHAB
35
44
  end
36
45
 
37
46
  def set_condition(condition, sign:, state:)
38
- condition.value = "#{sign}#{state}"
47
+ if condition.respond_to?(:argument=)
48
+ condition.argument = "#{sign}#{state}"
49
+ else
50
+ condition.value = "#{sign}#{state}"
51
+ end
39
52
  end
40
53
  else
41
54
  def supported_widget_type?(type)
@@ -189,7 +189,7 @@ module OpenHAB
189
189
  }.each do |java_op, ruby_op|
190
190
  convert = "self.class.new(other, thread_unit)"
191
191
 
192
- class_eval( # rubocop:disable Style/DocumentDynamicEvalDefinition -- https://github.com/rubocop/rubocop/issues/10179
192
+ class_eval(
193
193
  # def +(other)
194
194
  # logger.trace { "#{self} + #{other} (#{other.class})" }
195
195
  # other = other.state if other.is_a?(Core::Items::Persistence::PersistedState)
@@ -43,39 +43,39 @@ module OpenHAB
43
43
  .grep(Module)
44
44
  .select { |k| k < java.lang.Enum }
45
45
  .each do |klass|
46
- # make sure == from Type is inherited
47
- klass.remove_method(:==)
46
+ # make sure == from Type is inherited
47
+ klass.remove_method(:==)
48
48
 
49
- # dynamically define predicate methods
50
- klass.values.each do |value| # rubocop:disable Style/HashEachMethods -- this isn't a Ruby hash
51
- # include all the aliases that we define for items both command and
52
- # state aliases (since types can be interrogated as an incoming
53
- # command, or as the state of an item)
54
- command = :"#{Types::COMMAND_ALIASES[value.to_s]}?"
55
- states = Types::PREDICATE_ALIASES[value.to_s]
49
+ # dynamically define predicate methods
50
+ klass.values.each do |value| # rubocop:disable Style/HashEachMethods -- this isn't a Ruby hash
51
+ # include all the aliases that we define for items both command and
52
+ # state aliases (since types can be interrogated as an incoming
53
+ # command, or as the state of an item)
54
+ command = :"#{Types::COMMAND_ALIASES[value.to_s]}?"
55
+ states = Types::PREDICATE_ALIASES[value.to_s]
56
56
 
57
- ([command] | states).each do |method|
58
- logger.trace { "Defining #{klass}##{method} for #{value}" }
59
- klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
60
- def #{method} # def on?
61
- as(#{value.class.java_class.simple_name}).equal?(#{value}) # as(OnOffType).equal?(ON)
62
- end # end
63
- RUBY
64
- end
57
+ ([command] | states).each do |method|
58
+ logger.trace { "Defining #{klass}##{method} for #{value}" }
59
+ klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
60
+ def #{method} # def on?
61
+ as(#{value.class.java_class.simple_name}).equal?(#{value}) # as(OnOffType).equal?(ON)
62
+ end # end
63
+ RUBY
64
+ end
65
65
 
66
- method = states.last
67
- Events::ItemState.class_eval <<~RUBY, __FILE__, __LINE__ + 1
68
- def #{method} # def on?
69
- item_state.as(#{value.class.java_class.simple_name}).equal?(#{value}) # item_state.as(OnOffType).equal?(ON)
70
- end # end
71
- RUBY
66
+ method = states.last
67
+ Events::ItemState.class_eval <<~RUBY, __FILE__, __LINE__ + 1
68
+ def #{method} # def on?
69
+ item_state.as(#{value.class.java_class.simple_name}).equal?(#{value}) # item_state.as(OnOffType).equal?(ON)
70
+ end # end
71
+ RUBY
72
72
 
73
- Events::ItemStateChangedEvent.class_eval <<~RUBY, __FILE__, __LINE__ + 1
74
- def was_#{method} # def was_on?
75
- old_item_state.as(#{value.class.java_class.simple_name}).equal?(#{value}) # old_item_state.as(OnOffType).equal?(ON)
76
- end # end
77
- RUBY
78
- end
73
+ Events::ItemStateChangedEvent.class_eval <<~RUBY, __FILE__, __LINE__ + 1
74
+ def was_#{method} # def was_on?
75
+ old_item_state.as(#{value.class.java_class.simple_name}).equal?(#{value}) # old_item_state.as(OnOffType).equal?(ON)
76
+ end # end
77
+ RUBY
78
+ end
79
79
  end
80
80
  end
81
81
  end
@@ -14,8 +14,6 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
14
14
  :intersection,
15
15
  :pack,
16
16
  :product,
17
- :repeated_combination,
18
- :repeated_permutation,
19
17
  :reverse,
20
18
  :rotate,
21
19
  :sample,
@@ -88,7 +86,7 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
88
86
  raise NotImplementedError unless block_given?
89
87
 
90
88
  itr = list_iterator
91
- while itr.has_next? # rubocop:disable Style/WhileUntilModifier
89
+ while itr.has_next?
92
90
  itr.remove if yield(itr.next)
93
91
  end
94
92
  self
@@ -224,7 +222,7 @@ module Java::JavaUtil::List # rubocop:disable Style/ClassAndModuleChildren
224
222
  raise NotImplementedError unless block_given?
225
223
 
226
224
  itr = list_iterator
227
- while itr.has_next? # rubocop:disable Style/WhileUntilModifier
225
+ while itr.has_next?
228
226
  itr.remove unless yield(itr.next)
229
227
  end
230
228
  self
@@ -52,7 +52,7 @@ module Java::JavaUtil::Map # rubocop:disable Style/ClassAndModuleChildren
52
52
  end
53
53
 
54
54
  def transform_values
55
- map do |k, v| # rubocop:disable Style/MapToHash, Style/HashTransformValues
55
+ map do |k, v| # rubocop:disable Style/MapToHash
56
56
  [k, (yield v)]
57
57
  end.to_h
58
58
  end
@@ -8,7 +8,7 @@ module Java::JavaxMeasure::Unit # rubocop:disable Style/ClassAndModuleChildren
8
8
  end
9
9
 
10
10
  # @!visibility private
11
- module Java::JavaxMeasure::Dimension # rubocop:disable Style/ClassAndModuleChildren
11
+ module Java::JavaxMeasure::Dimension # rubocop:disable Style/ClassAndModuleChildren, Style/OneClassPerFile
12
12
  def inspect
13
13
  to_s
14
14
  end
@@ -63,7 +63,7 @@ class Integer
63
63
  end
64
64
 
65
65
  # Extensions to Float
66
- class Float
66
+ class Float # rubocop:disable Style/OneClassPerFile
67
67
  #
68
68
  # Create {Duration} of `self` milliseconds
69
69
  #
@@ -136,7 +136,7 @@ class Float
136
136
  alias_method :year, :years
137
137
  end
138
138
 
139
- module OpenHAB
139
+ module OpenHAB # rubocop:disable Style/OneClassPerFile
140
140
  module CoreExt
141
141
  module Ruby
142
142
  #
@@ -11,7 +11,7 @@ module OpenHAB
11
11
  def method_added(method)
12
12
  return super unless equal?(::Object)
13
13
 
14
- if DSL.private_instance_methods.include?(method)
14
+ if DSL.private_method_defined?(method)
15
15
  # Duplicate methods that conflict with DSL onto `main`'s singleton class,
16
16
  # so that they'll take precedence over DSL's method.
17
17
  TOPLEVEL_BINDING.receiver.singleton_class.define_method(method, instance_method(method))
@@ -154,7 +154,7 @@ module OpenHAB
154
154
  item.metadata
155
155
  .reject { |namespace, _| builder.metadata.key?(namespace) }
156
156
  .each do |namespace, metadata|
157
- item.metadata.delete(namespace) if metadata.provider == Core::Items::Metadata::Provider.current
157
+ item.metadata.delete(namespace) if metadata.provider == Core::Items::Metadata::Provider.current
158
158
  end
159
159
  else
160
160
  item = builder.build
@@ -33,8 +33,6 @@ module OpenHAB
33
33
  # check if this item is in the command's state before actually
34
34
  # sending the command
35
35
  %i[command update].each do |ensured_method|
36
- # rubocop:disable Style/IfUnlessModifier
37
-
38
36
  # def command(state, **kwargs)
39
37
  # # immediately send the command if it's a command, but not a state (like REFRESH)
40
38
  # return super(state, **kwargs) if state.is_a?(Command) && !state.is_a?(State)
@@ -63,7 +61,6 @@ module OpenHAB
63
61
  super(formatted_state, **kwargs)
64
62
  end
65
63
  RUBY
66
- # rubocop:enable Style/IfUnlessModifier
67
64
  end
68
65
  end
69
66
 
@@ -152,7 +152,7 @@ module OpenHAB
152
152
  def script(name = nil, description: nil, id: nil, tag: nil, tags: nil, replace: false, script: nil, &block)
153
153
  raise ArgumentError, "Block is required" unless block
154
154
 
155
- inferred_id = nil # rubocop:disable Lint/UselessAssignment -- it is used below
155
+ inferred_id = nil
156
156
  id ||= inferred_id = NameInference.infer_rule_id_from_block(block)
157
157
  name ||= id
158
158
  script ||= block.source rescue nil # rubocop:disable Style/RescueModifier
@@ -200,7 +200,7 @@ module OpenHAB
200
200
  def scene(name = nil, description: nil, id: nil, tag: nil, tags: nil, replace: false, script: nil, &block)
201
201
  raise ArgumentError, "Block is required" unless block
202
202
 
203
- inferred_id = nil # rubocop:disable Lint/UselessAssignment
203
+ inferred_id = nil
204
204
  id ||= inferred_id = NameInference.infer_rule_id_from_block(block)
205
205
  name ||= id
206
206
  script ||= block.source rescue nil # rubocop:disable Style/RescueModifier
@@ -257,14 +257,14 @@ module OpenHAB
257
257
  colors.delete(:default)&.tap { |default_color| colors.merge!(nil => default_color) }
258
258
 
259
259
  add_conditions(widget, method, colors.keys, :color) do |rule, key|
260
- rule.argument = colors[key]
260
+ Core::Sitemaps::Compatibility.set_rule_value(rule, colors[key])
261
261
  end
262
262
  end
263
263
 
264
264
  def add_icons(widget)
265
265
  icon.delete(:default)&.tap { |default_icon| icon.merge!(nil => default_icon) }
266
266
  add_conditions(widget, :icon_rules, icon.keys, :icon) do |rule, key|
267
- rule.argument = icon[key]
267
+ Core::Sitemaps::Compatibility.set_rule_value(rule, icon[key])
268
268
  end
269
269
  end
270
270
 
@@ -1415,7 +1415,7 @@ module OpenHAB
1415
1415
  missing_args = (REQUIRED_BUTTON_ARGS - kwargs.keys).compact
1416
1416
  unless missing_args.empty?
1417
1417
  args = kwargs.map { |k, v| "#{k}: #{v.inspect}" }.join(", ")
1418
- missing_args = missing_args.map(&:to_s).join(", ")
1418
+ missing_args = missing_args.join(", ")
1419
1419
  raise ArgumentError, "button(#{args}) missing required parameters: #{missing_args}"
1420
1420
  end
1421
1421
 
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.52.0"
7
+ VERSION = "5.52.1"
8
8
  end
9
9
  end
@@ -43,9 +43,7 @@ module OpenHAB
43
43
  end
44
44
  end
45
45
  end
46
- end
47
46
 
48
- module OpenHAB
49
47
  module RSpec
50
48
  #
51
49
  # Provides helper methods for use in specs, to easily work with and adjust
@@ -201,7 +199,7 @@ module OpenHAB
201
199
  .split(File::PATH_SEPARATOR)
202
200
  .reject(&:empty?)
203
201
  .reject do |path|
204
- $LOAD_PATH.include?(path)
202
+ $LOAD_PATH.include?(path)
205
203
  end)
206
204
 
207
205
  requires = jrubyscripting_config&.get("require") || ""
@@ -275,16 +273,16 @@ module OpenHAB
275
273
  OSGi.service_component_classes(bundle)
276
274
  .select { |klass, _services| klass.ancestors.include?(ast.java_class) }
277
275
  .each do |klass, services|
278
- new_ast_klass = Class.new(ast)
279
- new_ast_klass.become_java!
280
- wrapped_storage_service = Mocks::AbstractStorageBasedTypeProviderWrappedStorageService
281
- .new(storage_service,
282
- new_ast_klass.java_class,
283
- klass)
284
- new_ast = new_ast_klass.new(wrapped_storage_service)
285
-
286
- services -= [klass.name]
287
- OSGi.register_service(new_ast, *services, bundle: ast_bundle)
276
+ new_ast_klass = Class.new(ast)
277
+ new_ast_klass.become_java!
278
+ wrapped_storage_service = Mocks::AbstractStorageBasedTypeProviderWrappedStorageService
279
+ .new(storage_service,
280
+ new_ast_klass.java_class,
281
+ klass)
282
+ new_ast = new_ast_klass.new(wrapped_storage_service)
283
+
284
+ services -= [klass.name]
285
+ OSGi.register_service(new_ast, *services, bundle: ast_bundle)
288
286
  end
289
287
  end
290
288
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # rubocop:disable Naming/MethodName, Naming/AccessorMethodName
3
+ # rubocop:disable Naming/AccessorMethodName
4
4
 
5
5
  require "singleton"
6
6
 
@@ -83,4 +83,4 @@ module OpenHAB
83
83
  end
84
84
  end
85
85
  end
86
- # rubocop:enable Naming/MethodName, Naming/AccessorMethodName
86
+ # rubocop:enable Naming/AccessorMethodName
@@ -62,7 +62,7 @@ module OpenHAB
62
62
 
63
63
  # have to completely replace this method. only change is the regex splitting
64
64
  # into parts now allows `.` as part of the identifier
65
- # rubocop:disable Style/NestedTernaryOperator, Style/StringConcatenation, Style/TernaryParentheses
65
+ # rubocop:disable-next Style/NestedTernaryOperator, Style/StringConcatenation, Style/TernaryParentheses
66
66
  def format_types(typelist, brackets = true) # rubocop:disable Style/OptionalBooleanParameter
67
67
  return unless typelist.is_a?(Array)
68
68
 
@@ -73,7 +73,6 @@ module OpenHAB
73
73
  end
74
74
  list.empty? ? "" : (brackets ? "(#{list.join(", ")})" : list.join(", "))
75
75
  end
76
- # rubocop:enable Style/NestedTernaryOperator, Style/StringConcatenation, Style/TernaryParentheses
77
76
  end
78
77
  end
79
78
  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.52.0
4
+ version: 5.52.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
@@ -63,16 +63,22 @@ dependencies:
63
63
  name: marcel
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - - "<"
70
+ - !ruby/object:Gem::Version
71
+ version: '3.0'
69
72
  type: :runtime
70
73
  prerelease: false
71
74
  version_requirements: !ruby/object:Gem::Requirement
72
75
  requirements:
73
- - - "~>"
76
+ - - ">="
74
77
  - !ruby/object:Gem::Version
75
78
  version: '1.0'
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
76
82
  - !ruby/object:Gem::Dependency
77
83
  name: method_source
78
84
  requirement: !ruby/object:Gem::Requirement
@@ -389,7 +395,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
389
395
  - !ruby/object:Gem::Version
390
396
  version: '0'
391
397
  requirements: []
392
- rubygems_version: 4.0.19
398
+ rubygems_version: 4.0.24
393
399
  specification_version: 4
394
400
  summary: JRuby Helper Libraries for openHAB Scripting
395
401
  test_files: []