openhab-scripting 4.45.2 → 4.46.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: 937ebf36e5a0263536ce6b16f246ffa46cff4d9697fed234a9db203ea776f8a8
4
- data.tar.gz: e0a393c3fb4ef78ca9bf20cab5e44adbdd5705e1ac70a28837d1bd18e9a73688
3
+ metadata.gz: c6843041898c2a83a667d7e64e3233b6d8d88cf86909f683ce13ccd3e1194289
4
+ data.tar.gz: ce84f8f828d2c7b193b830c1818a2a3f9333455a1381ffbb7be33d64d0be0210
5
5
  SHA512:
6
- metadata.gz: 24ade32611b92e4b3a646700e973453dd8344d3b5325772ddfe3b589b71b4306c710582374de1819ef0bc0ae80d7f2e17853f4b8faa744bed9963d5fdd6cf67a
7
- data.tar.gz: cd443d2c01bcefd586a37d5563136b600e325806a220940290a4f90f49e907daf0d6c5ad229717d66806b722aa8b4f66798028e9b3315e27ae4bdba3e5846b7f
6
+ metadata.gz: 225f88032d55646e9b397a75e698df1b52e6f5eff09b3ac2cfed672436ffaea40cee492b9216a38d0a051f3a834072ae51919e0d5a3f6d6b93e2fc289707c61e
7
+ data.tar.gz: b464df4e24dbada506a9b14a80b82e714a6fd0e534fbe186de4b6257b0c0bb3a90de7a775d220156d1988b902f9580f3f3824324c8013b816c94b73ebc1241a7
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ruby2_keywords'
4
+ require 'openhab/log/logger'
3
5
  require_relative 'generic_item'
4
6
 
5
7
  module OpenHAB
@@ -81,14 +83,13 @@ module OpenHAB
81
83
  end
82
84
 
83
85
  # activate +ensure_states+ before forwarding to the wrapped object
84
- def method_missing(method, *args, &block)
86
+ ruby2_keywords def method_missing(method, *args, &block)
85
87
  return super unless @item.respond_to?(method)
86
88
 
87
89
  ensure_states do
88
90
  @item.__send__(method, *args, &block)
89
91
  end
90
92
  end
91
- ruby2_keywords :method_missing if respond_to? :ruby2_keywords
92
93
 
93
94
  # .
94
95
  def respond_to_missing?(method, include_private = false)
@@ -174,7 +174,7 @@ module OpenHAB
174
174
  OpenHAB::DSL.import_presets
175
175
  @semaphore.synchronize do
176
176
  thread_local(**@thread_locals) do
177
- logger.trace "Canceling implicit timer #{@timed_command_details.timer} for "\
177
+ logger.trace "Canceling implicit timer #{@timed_command_details.timer} for " \
178
178
  "#{@timed_command_details.item.id} because received event #{inputs}"
179
179
  @timed_command_details.timer.cancel
180
180
  # Disabled due to OpenHAB design
@@ -9,7 +9,7 @@ module OpenHAB
9
9
  # @return [Pathname] OpenHAB conf path
10
10
  #
11
11
  def self.conf_root
12
- Pathname.new(ENV['OPENHAB_CONF'])
12
+ Pathname.new(ENV.fetch('OPENHAB_CONF', nil))
13
13
  end
14
14
 
15
15
  module DSL
@@ -162,7 +162,7 @@ module OpenHAB
162
162
  now = Time.now
163
163
  return true if @between.cover? now
164
164
 
165
- logger.trace("Skipped execution of rule '#{name}' because the current time #{now} "\
165
+ logger.trace("Skipped execution of rule '#{name}' because the current time #{now} " \
166
166
  "is not between #{@between.begin} and #{@between.end}")
167
167
  else
168
168
  logger.trace("Skipped execution of rule '#{name}' because of guard #{@guard}")
@@ -112,7 +112,7 @@ module OpenHAB
112
112
  #
113
113
  def wait_trigger(item:, duration:, to: nil, from: nil, attach: nil)
114
114
  item_name = item.respond_to?(:name) ? item.name : item.to_s
115
- logger.trace("Creating Changed Wait Change Trigger for Item(#{item_name}) Duration(#{duration}) "\
115
+ logger.trace("Creating Changed Wait Change Trigger for Item(#{item_name}) Duration(#{duration}) " \
116
116
  "To(#{to}) From(#{from}) Attach(#{attach})")
117
117
  conditions = Conditions::Duration.new(to: to, from: from, duration: duration)
118
118
  changed_trigger(item: item, to: nil, from: nil, attach: attach, conditions: conditions)
@@ -36,7 +36,7 @@ module OpenHAB
36
36
  @conditions = Conditions::Proc.new(to: to, from: from)
37
37
  @duration = duration
38
38
  @timer = nil
39
- logger.trace "Created Duration Condition To(#{to}) From(#{from}) "\
39
+ logger.trace "Created Duration Condition To(#{to}) From(#{from}) " \
40
40
  "Conditions(#{@conditions}) Duration(#{@duration})"
41
41
  end
42
42
 
@@ -102,16 +102,6 @@ module OpenHAB
102
102
  end
103
103
  end
104
104
 
105
- java_import java.time.Month
106
- # Extend Month with helper method
107
- class Month
108
- # Calcalute and memoize the maximum number of days in a year before this month
109
- # @return [Number] maximum nummber of days in a year before this month
110
- def max_days_before
111
- @max_days_before ||= Month.values.select { |month| month < self }.sum(&:max_length)
112
- end
113
- end
114
-
115
105
  java_import java.time.MonthDay
116
106
  # Extend MonthDay java object with some helper methods
117
107
  class MonthDay
@@ -131,6 +121,12 @@ module OpenHAB
131
121
  MonthDay.of(m, d)
132
122
  end
133
123
 
124
+ # Calcalute the maximum number of days in a year before a supplied month
125
+ # @return [Number] maximum nummber of days in a year before this month
126
+ def max_days_before(month)
127
+ java.time.Month.values.select { |i| i < month }.sum(&:max_length)
128
+ end
129
+
134
130
  # Parse MonthDay string as defined with by Monthday class without leading double dash "--"
135
131
  def self.parse(string)
136
132
  logger.trace("#{self.class}.parse #{string} (#{string.class})")
@@ -146,7 +142,7 @@ module OpenHAB
146
142
 
147
143
  # Get the maximum (supports leap years) day of the year this month day could be
148
144
  def max_day_of_year
149
- day_of_month + month.max_days_before
145
+ day_of_month + max_days_before(month)
150
146
  end
151
147
 
152
148
  # Remove -- from MonthDay string representation
@@ -173,7 +169,7 @@ module OpenHAB
173
169
  self.<=>(MonthDay.parse(other))
174
170
  when OpenHAB::DSL::Between::MonthDayRange::DayOfYear
175
171
  # Compare with DayOfYear and invert result
176
- -other.<=>(self)
172
+ -(other <=> self)
177
173
  else
178
174
  super
179
175
  end
@@ -189,9 +189,9 @@ module OpenHAB
189
189
  def <=>(other)
190
190
  other_second_of_day = to_second_of_day(other)
191
191
  logger.trace do
192
- "SOD(#{sod}) "\
193
- "other SOD(#{other_second_of_day}) "\
194
- "Other Class (#{other.class}) "\
192
+ "SOD(#{sod}) " \
193
+ "other SOD(#{other_second_of_day}) " \
194
+ "Other Class (#{other.class}) " \
195
195
  "Result (#{sod <=> other_second_of_day})"
196
196
  end
197
197
  sod <=> other_second_of_day
@@ -5,5 +5,5 @@
5
5
  #
6
6
  module OpenHAB
7
7
  # @return [String] Version of OpenHAB helper libraries
8
- VERSION = '4.45.2'
8
+ VERSION = '4.46.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.45.2
4
+ version: 4.46.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-10-02 00:00:00.000000000 Z
11
+ date: 2022-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby2_keywords
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.0'
55
69
  description: JRuby Helper Libraries for OpenHAB Scripting
56
70
  email:
57
71
  - broconne@gmail.com