openhab-scripting 5.39.2 → 5.40.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: 2081031ffcc82e70d291fcc40fdd07392594de2a23b4651779344eee695ac07a
4
- data.tar.gz: 70a936e23a9ec88481ebff305cb00cde0a135f3055ccc53e2f45ca8af59ab22b
3
+ metadata.gz: 0b6537168353f3323482af5e045d5b219eb4b6bad9fc08e8e2bcc354c05b06da
4
+ data.tar.gz: 3ef5da367c87c63824267faea340a9c84344062532fabde415455faf96854e93
5
5
  SHA512:
6
- metadata.gz: 5d6d93194d2c3f73a507199fef247c997f417d9680690afe750d8c4057d9eba71df8bcd149e08a777bc684a3a4f46dd7881d657d07a28afa3b2736d60ef09a58
7
- data.tar.gz: 473cfd4c44219a29872c94e9d443e204c6622ca792d6e82bc9fe14f15a7614e7f0bf6ae9e81f642ca55567492a34e1ec23a3e344fe157d4918f84d1673836798
6
+ metadata.gz: c09161c22502c0ba7857709166e52f98e160cb78b8b3694c904a2dab4b70da3216ff1c1b73f390be8485f1a2619241ae208bba867882a65a2ae9d3a0d2cbb95f
7
+ data.tar.gz: b4cffd48bc9f39d9ca0a01a254372157fee86823a0c7bf561273b4084b68ef22ef49c3d95a86c46ac8356d6977170c73d2f0d1997c2f0badfe91e37f9b26ccde
@@ -5,10 +5,6 @@ module OpenHAB
5
5
  module Ruby
6
6
  # @!visibility private
7
7
  module Object
8
- class << self
9
- attr_reader :top_self
10
- end
11
-
12
8
  # @!visibility private
13
9
  module ClassMethods
14
10
  # capture methods defined at top level (which get added to Object)
@@ -18,7 +14,7 @@ module OpenHAB
18
14
  if DSL.private_instance_methods.include?(method)
19
15
  # Duplicate methods that conflict with DSL onto `main`'s singleton class,
20
16
  # so that they'll take precedence over DSL's method.
21
- Object.top_self.singleton_class.define_method(method, instance_method(method))
17
+ TOPLEVEL_BINDING.receiver.singleton_class.define_method(method, instance_method(method))
22
18
  end
23
19
 
24
20
  super
@@ -313,6 +313,8 @@ module OpenHAB
313
313
  # Google Assistant metadata (see {ItemBuilder#ga})
314
314
  # @param homekit [String, Symbol, Array<(String, Hash<String, Object>)>, nil]
315
315
  # Homekit metadata (see {ItemBuilder#homekit})
316
+ # @param matter [String, Symbol, Array<(String, Hash<String, Object>)>, nil]
317
+ # Matter metadata (see {ItemBuilder#matter})
316
318
  # @param metadata [Hash<String, Hash>] Generic metadata (see {ItemBuilder#metadata})
317
319
  # @param state [State] Initial state
318
320
  def initialize(type,
@@ -340,6 +342,7 @@ module OpenHAB
340
342
  alexa: nil,
341
343
  ga: nil, # rubocop:disable Naming/MethodParameterName
342
344
  homekit: nil,
345
+ matter: nil,
343
346
  metadata: nil,
344
347
  state: nil)
345
348
  raise ArgumentError, "`name` cannot be nil" if name.nil?
@@ -389,6 +392,7 @@ module OpenHAB
389
392
  self.alexa(alexa) if alexa
390
393
  self.ga(ga) if ga
391
394
  self.homekit(homekit) if homekit
395
+ self.matter(matter) if matter
392
396
  self.state = state
393
397
 
394
398
  self.group(*group)
@@ -495,7 +499,18 @@ module OpenHAB
495
499
  # @return [void]
496
500
  #
497
501
 
498
- %i[alexa ga homekit].each do |shortcut|
502
+ #
503
+ # @!method matter(value, config = nil)
504
+ # Shortcut for adding Matter metadata
505
+ #
506
+ # @see https://www.openhab.org/addons/bindings/matter/#matter-bridge
507
+ #
508
+ # @param value [String, Symbol] Matter device type or attribute(s)
509
+ # @param config [Hash, nil] Additional Matter configuration
510
+ # @return [void]
511
+ #
512
+
513
+ %i[alexa ga homekit matter].each do |shortcut|
499
514
  define_method(shortcut) do |value = nil, config = nil|
500
515
  value, config = value if value.is_a?(Array)
501
516
  metadata[shortcut] = [value, config]
@@ -2,13 +2,7 @@
2
2
 
3
3
  require "forwardable"
4
4
 
5
- require_relative "property"
6
- require_relative "guard"
7
- require_relative "triggers"
8
- require_relative "rule_triggers"
9
- require_relative "terse"
10
-
11
- Dir[File.expand_path("triggers/*.rb", __dir__)].each do |f|
5
+ Dir[File.expand_path("**/*.rb", __dir__)].each do |f|
12
6
  require f
13
7
  end
14
8
 
@@ -10,7 +10,3 @@ module OpenHAB
10
10
  end
11
11
  end
12
12
  end
13
-
14
- Dir[File.expand_path("triggers/**/*.rb", __dir__)].each do |f|
15
- require f
16
- 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.39.2"
7
+ VERSION = "5.40.0"
8
8
  end
9
9
  end
data/lib/openhab/dsl.rb CHANGED
@@ -45,13 +45,14 @@ module OpenHAB
45
45
 
46
46
  module Rules
47
47
  # sorted alphabetically
48
- autoload :AutomationRule, "openhab/dsl/rules/automation_rule"
48
+ autoload :AutomationRule, "openhab/dsl/rules/builder"
49
49
  autoload :Builder, "openhab/dsl/rules/builder"
50
- autoload :Guard, "openhab/dsl/rules/guard"
51
- autoload :NameInference, "openhab/dsl/rules/name_inference"
52
- autoload :Property, "openhab/dsl/rules/property"
53
- autoload :RuleTriggers, "openhab/dsl/rules/rule_triggers"
54
- autoload :Terse, "openhab/dsl/rules/terse"
50
+ autoload :Guard, "openhab/dsl/rules/builder"
51
+ autoload :NameInference, "openhab/dsl/rules/builder"
52
+ autoload :Property, "openhab/dsl/rules/builder"
53
+ autoload :RuleTriggers, "openhab/dsl/rules/builder"
54
+ autoload :Terse, "openhab/dsl/rules/builder"
55
+ autoload :Triggers, "openhab/dsl/rules/builder"
55
56
  end
56
57
 
57
58
  # include this before Core::Actions so that Core::Action's method_missing
@@ -1138,6 +1139,5 @@ OpenHAB::Core::Items.import_into_global_namespace
1138
1139
  singleton_class.include(OpenHAB::DSL)
1139
1140
  # Patch Object to work around https://github.com/openhab/openhab-jruby/issues/4
1140
1141
  Object.extend(OpenHAB::CoreExt::Ruby::Object::ClassMethods)
1141
- OpenHAB::CoreExt::Ruby::Object.instance_variable_set(:@top_self, self)
1142
1142
 
1143
1143
  logger.debug { "openHAB JRuby Scripting Library Version #{OpenHAB::DSL::VERSION} Loaded" }
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.39.2
4
+ version: 5.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell