openhab-scripting 3.1.1 → 3.1.2

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: beab2ee97613a8a2016969c8410f4abcddc9c780ad16c5683e382bee28526122
4
- data.tar.gz: 33f9ecf81357a4812e59188ad3d3f5b7ef034e79e874ec942e3bc880352853d4
3
+ metadata.gz: f4238eb3161f714b74aed518a4a3e6d02f2aeed634fc21d7276df152f8aeead8
4
+ data.tar.gz: 57666ad4b06970ea2859ab252a19b5801c34657025e11becb766ad2876157a1b
5
5
  SHA512:
6
- metadata.gz: 97b3a91ecda58df5763a79b6f9d0c3020f7064774e84f62c3716cbb6fc441a0848dee14778126f01cde1ca327e0c5413ea3f5e37e3b3fda1a0d5e432bfe36007
7
- data.tar.gz: cece3de478210c8236d6d74a04af2edb1efe136bf4e380f86225df8b76b7b7edf3fcf83fde9dcc376dbcbcc62e443bbd5719cbb2efdc2949249467f06fa677ae
6
+ metadata.gz: 4617faef054fc5f6e388314ff2ab46c1a80ad525fb576fb1d2d2a89bde37f5f420a3ca77000da6bf62546f8b3ab2ba77d24ab271c9ea2c232c02d547677ad61f
7
+ data.tar.gz: bf889c204885dc28b6416138d8cba0d116e8d3c408bfd2720b481f47820ea51bb5e067c1492df352db13e2e0267b4f647b48ed3d68591a5a8d444972640d6270
@@ -29,6 +29,7 @@ module OpenHAB
29
29
  set_name(config.name)
30
30
  set_description(config.description)
31
31
  set_triggers(config.triggers)
32
+ @run_context = config.caller
32
33
  @run_queue = config.run
33
34
  @guard = config.guard
34
35
  between = config.between&.yield_self { between(config.between) }
@@ -288,7 +289,7 @@ module OpenHAB
288
289
  #
289
290
  def process_otherwise_task(event, task)
290
291
  logger.trace { "Executing rule '#{name}' otherwise block with event(#{event})" }
291
- task.block.call(event)
292
+ @run_context.instance_exec(event, &task.block)
292
293
  end
293
294
 
294
295
  #
@@ -316,7 +317,7 @@ module OpenHAB
316
317
  return unless event&.item
317
318
 
318
319
  logger.trace { "Executing rule '#{name}' trigger block with item (#{event.item})" }
319
- task.block.call(event.item)
320
+ @run_context.instance_exec(event.item, &task.block)
320
321
  end
321
322
 
322
323
  #
@@ -328,7 +329,7 @@ module OpenHAB
328
329
  #
329
330
  def process_run_task(event, task)
330
331
  logger.trace { "Executing rule '#{name}' run block with event(#{event})" }
331
- task.block.call(event)
332
+ @run_context.instance_exec(event, &task.block)
332
333
  end
333
334
 
334
335
  #
@@ -23,10 +23,11 @@ module OpenHAB
23
23
  def rule(rule_name, &block)
24
24
  @rule_name = rule_name
25
25
  config = RuleConfig.new(rule_name, block.binding)
26
- config.instance_eval(&block)
26
+ config.instance_exec(config, &block)
27
27
  config.guard = Guard::Guard.new(only_if: config.only_if, not_if: config.not_if)
28
28
  logger.trace { config.inspect }
29
29
  process_rule_config(config)
30
+ config
30
31
  rescue StandardError => e
31
32
  re_raise_with_backtrace(e)
32
33
  end
@@ -40,6 +40,9 @@ module OpenHAB
40
40
  # @return [Array] Of trigger guards
41
41
  attr_accessor :guard
42
42
 
43
+ # @return [Object] object that invoked rule method
44
+ attr_accessor :caller
45
+
43
46
  #
44
47
  # Struct holding a run block
45
48
  #
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '3.1.1'
8
+ VERSION = '3.1.2'
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: 3.1.1
4
+ version: 3.1.2
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-03-08 00:00:00.000000000 Z
11
+ date: 2021-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler