openhab-scripting 5.44.1 → 5.45.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd60fb96afbab0b86a01d0cbfce296604179e63899be95d6faefdc27e805dfe5
4
- data.tar.gz: 88a9935ff405de0fef0cf645e936ea521fe940c88a8e40da6069183476019c00
3
+ metadata.gz: 6a6ff4c8c427bbcf314fb2226da8fcc4791ee9395394f404e88567a4417e1b4f
4
+ data.tar.gz: 254980e2b97d5cd3f3c44990ed5e1cd84e0c31d2a8a9490146d317e0c2f3d9a9
5
5
  SHA512:
6
- metadata.gz: 8851a00c95338d7797062a7d901a763146ee96f4a8f652b3a30b380c5248961b3f418661c2cd2b899d292a7077723bbca818e778223996a98165b84a35c6cab6
7
- data.tar.gz: 4ff6ccb08cb630373a385daec0bbb9accf3ec13358e373942fea74fb2f95c0b8f489a22f0de7b37f52765611a7ca6a921f743e1e57b7d3adf57e78fe2f362e1e
6
+ metadata.gz: 01b946e0402acf49358f2de450960fd716f654c668bd40f419a5c768672d2bd7272fa89d5bef1c0e7f61f57968156c2a9d9b2a47b01b0e6065432962df568a12
7
+ data.tar.gz: 6ef1bc5b35034eac211a4024586e04d27c8aeeba8f2e7d21ab6999ba32b6d72c567a29c81010b559685af51d2bd69d461ea32726149c044fe090a8aa757fd09f
@@ -7,7 +7,7 @@ module OpenHAB
7
7
  class Transformation
8
8
  class << self
9
9
  # @!visibility private
10
- alias_method :raw_transform, :transform if instance_methods.include?(:transform)
10
+ alias_method :raw_transform, :transform if method_defined?(:transform)
11
11
 
12
12
  #
13
13
  # Applies a transformation of a given type with some function to a value.
@@ -7,7 +7,7 @@ module OpenHAB
7
7
  class Voice
8
8
  class << self
9
9
  # @!visibility private
10
- alias_method :raw_say, :say if instance_methods.include?(:say)
10
+ alias_method :raw_say, :say if method_defined?(:say)
11
11
 
12
12
  #
13
13
  # Say text via openHAB Text-To-Speech service, Voice.say()
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ openhab_spec = Gem::Specification.new do |s|
4
+ s.name = "openhab"
5
+ s.version = -(ENV["OPENHAB_VERSION"] || "5.1.0")
6
+
7
+ def s.deleted_gem?
8
+ false
9
+ end
10
+
11
+ def s.installation_missing?
12
+ false
13
+ end
14
+ end
15
+
16
+ Gem::Specification.add_spec(openhab_spec)
17
+ Gem.post_reset { Gem::Specification.add_spec(openhab_spec) }
@@ -42,7 +42,7 @@ module OpenHAB
42
42
  def def_predicate_methods(klass)
43
43
  values_for_enums(klass.ACCEPTED_DATA_TYPES).each do |state|
44
44
  _command_predicate, state_predicate = Types::PREDICATE_ALIASES[state.to_s]
45
- next if klass.instance_methods.include?(state_predicate)
45
+ next if klass.method_defined?(state_predicate)
46
46
 
47
47
  logger.trace { "Defining #{klass}##{state_predicate} for #{state}" }
48
48
  klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1
@@ -62,7 +62,7 @@ module OpenHAB
62
62
  def def_command_methods(klass)
63
63
  values_for_enums(klass.ACCEPTED_COMMAND_TYPES).each do |value|
64
64
  command = Types::COMMAND_ALIASES[value.to_s]
65
- next if klass.instance_methods.include?(command)
65
+ next if klass.method_defined?(command)
66
66
 
67
67
  if value.is_a?(Types::State)
68
68
  logger.trace { "Defining #{klass}/Enumerable##{command}/#{command}! for #{value}" }
@@ -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
@@ -36,14 +36,14 @@ module OpenHAB
36
36
 
37
37
  # Delegate any other methods to the actual array, exclude mutating methods
38
38
  def method_missing(method, ...)
39
- return to_a.send(method, ...) if method[-1] != "!" && Array.instance_methods.include?(method)
39
+ return to_a.send(method, ...) if method[-1] != "!" && Array.method_defined?(method)
40
40
 
41
41
  super
42
42
  end
43
43
 
44
44
  # @!visibility private
45
45
  def respond_to_missing?(method, include_private = false)
46
- return true if method[-1] != "!" && Array.instance_methods.include?(method.to_sym)
46
+ return true if method[-1] != "!" && Array.method_defined?(method.to_sym)
47
47
 
48
48
  super
49
49
  end
@@ -225,7 +225,7 @@ module OpenHAB
225
225
  # @deprecated OH 4.2 Remove version check when dropping OH 4.2
226
226
  return true if OpenHAB::Core.version >= OpenHAB::Core::V4_3 && to_instant.respond_to?(method)
227
227
  return true if zoned_date_time.respond_to?(method)
228
- return true if ::Time.instance_methods.include?(method.to_sym)
228
+ return true if ::Time.method_defined?(method.to_sym)
229
229
 
230
230
  super
231
231
  end
@@ -241,7 +241,7 @@ module OpenHAB
241
241
  end
242
242
 
243
243
  return zoned_date_time.send(method, ...) if zoned_date_time.respond_to?(method)
244
- return to_time.send(method, ...) if ::Time.instance_methods.include?(method.to_sym)
244
+ return to_time.send(method, ...) if ::Time.method_defined?(method.to_sym)
245
245
 
246
246
  super
247
247
  end
@@ -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
data/lib/openhab/core.rb CHANGED
@@ -17,6 +17,8 @@ module OpenHAB
17
17
  V5_0 = Gem::Version.new("5.0.0").freeze
18
18
  # @!visibility private
19
19
  V5_1 = Gem::Version.new("5.1.0").freeze
20
+ # @!visibility private
21
+ V5_2 = Gem::Version.new("5.2.0").freeze
20
22
 
21
23
  # @return [Gem::Version] Returns the current openHAB version as a Gem::Version object
22
24
  # Note, this strips off snapshots, milestones and RC versions and returns the release version.
@@ -159,6 +161,10 @@ end
159
161
  require_relative "core/provider"
160
162
 
161
163
  Dir[File.expand_path("core/**/*.rb", __dir__)].each do |f|
164
+ # already been run by either a binstub, or the addon
165
+ next if f.end_with?("gem.rb")
162
166
  # metadata is autoloaded
163
- require f unless f.include?("/metadata/")
167
+ next if f.include?("/metadata/")
168
+
169
+ require f
164
170
  end
@@ -36,7 +36,7 @@ module OpenHAB
36
36
  # @return [true,false] Returns true if the duration is less than zero.
37
37
  #
38
38
 
39
- unless instance_methods.include?(:positive?)
39
+ unless method_defined?(:positive?)
40
40
  #
41
41
  # @return [true, false] Returns true if the duration is greater than zero.
42
42
  #
@@ -3,5 +3,5 @@
3
3
  # Extensions to Symbol
4
4
  class Symbol
5
5
  # Ruby 3.0 already has #name
6
- alias_method :name, :to_s unless instance_methods.include?(:name)
6
+ alias_method :name, :to_s unless method_defined?(:name)
7
7
  end
@@ -106,29 +106,33 @@ module OpenHAB
106
106
  unit_label: nil,
107
107
  verify: false)
108
108
  # Extract the named arguments into a hash
109
- @parameters << method(__method__).parameters
110
- .select { |param_type, _| param_type == :key } # rubocop:disable Style/HashSlice
111
- .to_h { |_, key| [key, binding.local_variable_get(key)] }
112
- .then do |p|
113
- p[:options] = p[:options].map do |opt_value, opt_label|
114
- org.openhab.core.config.core.ParameterOption.new(opt_value, opt_label)
115
- end
116
- p[:filter_criteria] = p[:filter_criteria].map do |filter_name, filter_value|
117
- org.openhab.core.config.core.FilterCriteria.new(filter_name, filter_value)
118
- end
119
- p[:minimum] = p.delete(:min)&.to_d&.to_java
120
- p[:maximum] = p.delete(:max)&.to_d&.to_java
121
- p[:step] = p.delete(:step)&.to_d&.to_java
122
- p[:group_name] ||= @current_group
123
- type = org.openhab.core.config.core.ConfigDescriptionParameter::Type.value_of(type.to_s.upcase)
109
+ @parameters <<
110
+ method(__method__)
111
+ .parameters
112
+ .select { |param_type, _| param_type == :key } # rubocop:disable Style/HashSlice
113
+ .to_h { |_, key| [key, binding.local_variable_get(key)] }
114
+ .then do |p|
115
+ p[:options] = p[:options].map do |opt_value, opt_label|
116
+ org.openhab.core.config.core.ParameterOption.new(opt_value, opt_label)
117
+ end
118
+ p[:filter_criteria] = p[:filter_criteria].map do |filter_name, filter_value|
119
+ org.openhab.core.config.core.FilterCriteria.new(filter_name, filter_value)
120
+ end
121
+ p[:minimum] = p.delete(:min)&.to_d&.to_java
122
+ p[:maximum] = p.delete(:max)&.to_d&.to_java
123
+ p[:step] = p.delete(:step)&.to_d&.to_java
124
+ p[:group_name] ||= @current_group
125
+ type = org.openhab.core.config.core.ConfigDescriptionParameter::Type.value_of(type.to_s.upcase)
124
126
 
125
- parameter = org.openhab.core.config.core.ConfigDescriptionParameterBuilder.create(name.to_s, type)
127
+ parameter = org.openhab.core.config.core.ConfigDescriptionParameterBuilder.create(
128
+ name.to_s, type
129
+ )
126
130
 
127
- p.each do |key, value|
128
- parameter.send(:"with_#{key}", value) unless value.nil?
131
+ p.each do |key, value|
132
+ parameter.send(:"with_#{key}", value) unless value.nil?
133
+ end
134
+ parameter.build
129
135
  end
130
- parameter.build
131
- end
132
136
  end
133
137
 
134
138
  #
@@ -152,7 +152,7 @@ module OpenHAB
152
152
  item.metadata
153
153
  .reject { |namespace, _| builder.metadata.key?(namespace) }
154
154
  .each do |namespace, metadata|
155
- item.metadata.delete(namespace) if metadata.provider == Core::Items::Metadata::Provider.current
155
+ item.metadata.delete(namespace) if metadata.provider == Core::Items::Metadata::Provider.current
156
156
  end
157
157
  else
158
158
  item = builder.build
@@ -4,6 +4,6 @@ module OpenHAB
4
4
  module DSL
5
5
  # Version of openHAB helper libraries
6
6
  # @return [String]
7
- VERSION = "5.44.1"
7
+ VERSION = "5.45.0"
8
8
  end
9
9
  end
@@ -201,7 +201,7 @@ module OpenHAB
201
201
  .split(File::PATH_SEPARATOR)
202
202
  .reject(&:empty?)
203
203
  .reject do |path|
204
- $LOAD_PATH.include?(path)
204
+ $LOAD_PATH.include?(path)
205
205
  end)
206
206
 
207
207
  requires = jrubyscripting_config&.get("require") || ""
@@ -268,16 +268,16 @@ module OpenHAB
268
268
  OSGi.service_component_classes(bundle)
269
269
  .select { |klass, _services| klass.ancestors.include?(ast.java_class) }
270
270
  .each do |klass, services|
271
- new_ast_klass = Class.new(ast)
272
- new_ast_klass.become_java!
273
- wrapped_storage_service = Mocks::AbstractStorageBasedTypeProviderWrappedStorageService
274
- .new(storage_service,
275
- new_ast_klass.java_class,
276
- klass)
277
- new_ast = new_ast_klass.new(wrapped_storage_service)
278
-
279
- services -= [klass.name]
280
- OSGi.register_service(new_ast, *services, bundle: ast_bundle)
271
+ new_ast_klass = Class.new(ast)
272
+ new_ast_klass.become_java!
273
+ wrapped_storage_service = Mocks::AbstractStorageBasedTypeProviderWrappedStorageService
274
+ .new(storage_service,
275
+ new_ast_klass.java_class,
276
+ klass)
277
+ new_ast = new_ast_klass.new(wrapped_storage_service)
278
+
279
+ services -= [klass.name]
280
+ OSGi.register_service(new_ast, *services, bundle: ast_bundle)
281
281
  end
282
282
  end
283
283
  rescue NameError
@@ -786,7 +786,7 @@ module OpenHAB
786
786
 
787
787
  <blacklistedFeatures>
788
788
  <feature>openhab-runtime-ui</feature>
789
- <feature>openhab-core-ui*</feature>
789
+ <feature>openhab-core-ui</feature>
790
790
  <feature>openhab-misc-*</feature>
791
791
  <feature>openhab-persistence-*</feature>
792
792
  <feature>openhab-package-standard</feature>
@@ -807,6 +807,7 @@ module OpenHAB
807
807
  <f:feature>openhab-core-model-sitemap</f:feature>
808
808
  <f:feature>openhab-core-model-thing</f:feature>
809
809
  <f:feature>openhab-core-storage-json</f:feature>
810
+ <f:feature>openhab-core-ui-icon</f:feature>
810
811
  <f:feature>openhab-transport-http</f:feature>
811
812
  <f:feature prerequisite="true">wrapper</f:feature>
812
813
  <f:bundle>mvn:org.openhab.core.bundles/org.openhab.core.karaf/#{version}</f:bundle>
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.44.1
4
+ version: 5.45.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
@@ -53,6 +53,26 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: openhab
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 4.1.0
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '5.3'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 4.1.0
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.3'
56
76
  email:
57
77
  - broconne+github@gmail.com
58
78
  - cody@cutrer.us
@@ -100,6 +120,7 @@ files:
100
120
  - lib/openhab/core/events/startlevel_event.rb
101
121
  - lib/openhab/core/events/thing_status_info_event.rb
102
122
  - lib/openhab/core/events/timer_event.rb
123
+ - lib/openhab/core/gem.rb
103
124
  - lib/openhab/core/items.rb
104
125
  - lib/openhab/core/items/accepted_data_types.rb
105
126
  - lib/openhab/core/items/call_item.rb