openhab-scripting 4.28.0 → 4.28.1

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: 738583da2cd48296525b6b6a2999fe1daba82b0cbb1c410beb7e3575fdf6afbb
4
- data.tar.gz: e7d4ff645268380636f69bff6eec42d8b8f650784225afe9d456027b44e11d77
3
+ metadata.gz: 824e2af85aba6737c05884f3f6ca06adc1873a388b8091062781b274290c6476
4
+ data.tar.gz: 159ed6ce10d55640c37b61429a937f4dafaecf529479b3423552bff9d929d30d
5
5
  SHA512:
6
- metadata.gz: e06a080cedde9ffbb29983f087c93dff1533fe521112c1036015c1f42f93c5a9d164bd0c307d21109c8f3a6abe7cb74e0f63b144cd21d2f7086a1e03d0b9c545
7
- data.tar.gz: e23ccc89ee67bc2152efaa91ff33157c74d99d244da3cc11b497b8500b094f40dfc66b61fcb04c18763fe53afaabccba8baa6f2bf05c9f3d5d194915255f8078
6
+ metadata.gz: 3f6f18504814c73aad6e9c5d5a7548ae17165dff3d4f85a618103f79574389d201c82a528ec09b27b37e975b05b47bb0cd78e958ba0a4bb3b094314f842b9c0e
7
+ data.tar.gz: d0baf3b51e76656b68e24faa3ceb8d0e76e6afea89b2ba6f81c152ce0f2ddb560fe1942af225f8f1b7ace9c5d3e9c1605c83a1654bddecdceb16f57d47c93b6e
@@ -304,7 +304,7 @@ module OpenHAB
304
304
  end
305
305
  false
306
306
  rescue StandardError => e
307
- print_backtrace(e)
307
+ logger.log_exception(e, name)
308
308
  end
309
309
  # rubocop:enable Metrics/MethodLength
310
310
 
@@ -328,7 +328,7 @@ module OpenHAB
328
328
  end
329
329
  end
330
330
  rescue StandardError => e
331
- print_backtrace(e)
331
+ logger.log_exception(e, name)
332
332
  end
333
333
 
334
334
  #
@@ -399,16 +399,6 @@ module OpenHAB
399
399
  @run_context.instance_exec(event, &task.block)
400
400
  end
401
401
 
402
- #
403
- # Print error and stack trace without calls to internal classes
404
- #
405
- # @param [Exception] error A rescued error
406
- #
407
- def print_backtrace(error)
408
- error = logger.clean_backtrace(error)
409
- logger.error { "#{error.message} (#{error.class})\nIn rule: #{name}\n#{error.backtrace&.join("\n")}" }
410
- end
411
-
412
402
  #
413
403
  # Create a new hash in which all elements are converted to strings
414
404
  #
@@ -26,7 +26,7 @@ module OpenHAB
26
26
  @registry = OpenHAB::Core.rule_registry
27
27
  class << self
28
28
  attr_reader :script_rules, :automation_manager, :registry
29
- end
29
+ end
30
30
 
31
31
  #
32
32
  # Create a new rule
@@ -35,7 +35,7 @@ end
35
35
  # @yield [] Block executed in context of a RuleConfig
36
36
  #
37
37
  #
38
- # rubocop: disable Metrics
38
+ # rubocop: disable Metrics/MethodLength
39
39
  def rule(rule_name, &block)
40
40
  thread_local(RULE_NAME: rule_name) do
41
41
  @rule_name = rule_name
@@ -47,10 +47,9 @@ end
47
47
  nil # Must return something other than the rule object. See https://github.com/boc-tothefuture/openhab-jruby/issues/438
48
48
  end
49
49
  rescue StandardError => e
50
- puts "#{e.class}: #{e.message}"
51
- re_raise_with_backtrace(e)
50
+ logger.log_exception(e, @rule_name)
52
51
  end
53
- # rubocop: enable Metrics
52
+ # rubocop: enable Metrics/MethodLength
54
53
 
55
54
  #
56
55
  # Cleanup rules in this script file
@@ -62,16 +61,6 @@ end
62
61
 
63
62
  private
64
63
 
65
- #
66
- # Re-raises a rescued error to OpenHAB with added rule name and stack trace
67
- #
68
- # @param [Exception] error A rescued error
69
- #
70
- def re_raise_with_backtrace(error)
71
- error = logger.clean_backtrace(error)
72
- raise error, "#{error.message}\nIn rule: #{@rule_name}\n#{error.backtrace.join("\n")}"
73
- end
74
-
75
64
  #
76
65
  # Process a rule based on the supplied configuration
77
66
  #
@@ -7,8 +7,8 @@ require 'java'
7
7
  module OpenHAB
8
8
  module DSL
9
9
  module Types
10
- java_import org.openhab.core.library.types.DateTimeType
11
- java_import java.time.ZonedDateTime
10
+ DateTimeType = org.openhab.core.library.types.DateTimeType
11
+ java_import java.time.ZonedDateTime # This is needed for the addon prior to ruby_class fix (OH 3.2.0)
12
12
 
13
13
  # global alias
14
14
  ::DateTimeType = DateTimeType
@@ -6,7 +6,7 @@ require_relative 'numeric_type'
6
6
  module OpenHAB
7
7
  module DSL
8
8
  module Types
9
- java_import org.openhab.core.library.types.DecimalType
9
+ DecimalType = org.openhab.core.library.types.DecimalType
10
10
 
11
11
  #
12
12
  # Add methods to core OpenHAB DecimalType to make it behave as a Ruby
@@ -6,7 +6,7 @@ require_relative 'percent_type'
6
6
  module OpenHAB
7
7
  module DSL
8
8
  module Types
9
- java_import org.openhab.core.library.types.HSBType
9
+ HSBType = org.openhab.core.library.types.HSBType
10
10
 
11
11
  # global alias
12
12
  ::HSBType = HSBType
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.IncreaseDecreaseType
6
+ IncreaseDecreaseType = org.openhab.core.library.types.IncreaseDecreaseType
7
7
 
8
8
  # Adds methods to core OpenHAB IncreaseDecreaseType to make it more
9
9
  # natural in Ruby
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.NextPreviousType
6
+ NextPreviousType = org.openhab.core.library.types.NextPreviousType
7
7
 
8
8
  # Adds methods to core OpenHAB NextPreviousType to make it more
9
9
  # natural in Ruby
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.OnOffType
6
+ OnOffType = org.openhab.core.library.types.OnOffType
7
7
 
8
8
  # Adds methods to core OpenHAB OnOffType to make it more natural in Ruby
9
9
  class OnOffType
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.OpenClosedType
6
+ OpenClosedType = org.openhab.core.library.types.OpenClosedType
7
7
 
8
8
  # Adds methods to core OpenHAB OpenClosedType to make it more natural in Ruby
9
9
  class OpenClosedType
@@ -5,7 +5,7 @@ require_relative 'decimal_type'
5
5
  module OpenHAB
6
6
  module DSL
7
7
  module Types
8
- java_import org.openhab.core.library.types.PercentType
8
+ PercentType = org.openhab.core.library.types.PercentType
9
9
 
10
10
  # global alias
11
11
  ::PercentType = PercentType
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.PlayPauseType
6
+ PlayPauseType = org.openhab.core.library.types.PlayPauseType
7
7
 
8
8
  # Adds methods to core OpenHAB PlayPauseType to make it more
9
9
  # natural in Ruby
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.PointType
6
+ PointType = org.openhab.core.library.types.PointType
7
7
 
8
8
  # global scope
9
9
  # @!visibility private
@@ -5,7 +5,7 @@ require_relative 'numeric_type'
5
5
  module OpenHAB
6
6
  module DSL
7
7
  module Types
8
- java_import org.openhab.core.library.types.QuantityType
8
+ QuantityType = org.openhab.core.library.types.QuantityType
9
9
 
10
10
  # global alias
11
11
  ::QuantityType = QuantityType
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.types.RefreshType
6
+ RefreshType = org.openhab.core.types.RefreshType
7
7
 
8
8
  # Adds methods to core OpenHAB RefreshType to make it more natural in Ruby
9
9
  class RefreshType # rubocop:disable Lint/EmptyClass
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.RewindFastforwardType
6
+ RewindFastforwardType = org.openhab.core.library.types.RewindFastforwardType
7
7
 
8
8
  # Adds methods to core OpenHAB RewindFastforwardType to make it more
9
9
  # natural in Ruby
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.StopMoveType
6
+ StopMoveType = org.openhab.core.library.types.StopMoveType
7
7
 
8
8
  # Adds methods to core OpenHAB StopMoveType to make it more
9
9
  # natural in Ruby
@@ -7,7 +7,7 @@ require_relative 'comparable_type'
7
7
  module OpenHAB
8
8
  module DSL
9
9
  module Types
10
- java_import org.openhab.core.library.types.StringType
10
+ StringType = org.openhab.core.library.types.StringType
11
11
 
12
12
  #
13
13
  # Add methods to core OpenHAB StringType to make it behave as a Ruby
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.types.UnDefType
6
+ UnDefType = org.openhab.core.types.UnDefType
7
7
 
8
8
  # Adds methods to core OpenHAB UnDefType to make it more natural in Ruby
9
9
  class UnDefType # rubocop:disable Lint/EmptyClass
@@ -3,7 +3,7 @@
3
3
  module OpenHAB
4
4
  module DSL
5
5
  module Types
6
- java_import org.openhab.core.library.types.UpDownType
6
+ UpDownType = org.openhab.core.library.types.UpDownType
7
7
 
8
8
  # Adds methods to core OpenHAB UpDownType to make it more natural in Ruby
9
9
  class UpDownType
@@ -6,7 +6,7 @@ module OpenHAB
6
6
  # This module holds global configuration values
7
7
  module Configuration
8
8
  # -*- coding: utf-8 -*-
9
- LOG_PREFIX = 'jsr223.jruby'
9
+ LOG_PREFIX = 'org.openhab.automation.jruby'
10
10
 
11
11
  #
12
12
  # Gets the log prefix
@@ -82,6 +82,16 @@ module OpenHAB
82
82
  error
83
83
  end
84
84
 
85
+ #
86
+ # Print error and stack trace without calls to internal classes
87
+ #
88
+ # @param [Exception] error A rescued error
89
+ #
90
+ def log_exception(exception, rule_name)
91
+ exception = clean_backtrace(exception)
92
+ error { "#{exception.message} (#{exception.class})\nIn rule: #{rule_name}\n#{exception.backtrace&.join("\n")}" }
93
+ end
94
+
85
95
  private
86
96
 
87
97
  #
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '4.28.0'
8
+ VERSION = '4.28.1'
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: 4.28.0
4
+ version: 4.28.1
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: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler