openhab-scripting 5.27.0 → 5.27.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openhab/core/provider.rb +10 -0
- data/lib/openhab/core/sitemaps/provider.rb +1 -10
- data/lib/openhab/core/types/date_time_type.rb +7 -23
- data/lib/openhab/dsl/version.rb +1 -1
- data/lib/openhab/dsl.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e0abb8ef69de3f3ee26fa45213d2d9afa55f4b4816cde92ab6dd68ea9f95ad5
|
4
|
+
data.tar.gz: bcb8c93446e87d55b2d07cfa24762b684e313f2f546c77bfa1b946c227061a00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec47bcf9491772968a8f6ca7ac5853ed403986d75eb1ae69f92f43ada70af126552abec30af4a7d02bd5cf63daaf4ce5d7b9b86433899f1161e72e5807f6c06e
|
7
|
+
data.tar.gz: ad58da972b4b1bbf34e4a9e0af7bc56f8debec4126ce64e1c8133b6d1dd10d584c3c7344bb9740be56977f5c948a6ccb6db055a0179fd4fb84d77d53e88e36e1
|
@@ -213,8 +213,18 @@ module OpenHAB
|
|
213
213
|
old
|
214
214
|
end
|
215
215
|
|
216
|
+
# @!visibility private
|
217
|
+
def clear
|
218
|
+
elements = @elements
|
219
|
+
@elements = java.util.concurrent.ConcurrentHashMap.new
|
220
|
+
elements.each_value do |v|
|
221
|
+
notify_listeners_about_removed_element(v)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
216
225
|
# @!visibility private
|
217
226
|
def unregister
|
227
|
+
clear
|
218
228
|
# @deprecated OH3.4 safe navigation only required for missing Semantics registry
|
219
229
|
self.class.registry&.remove_provider(self)
|
220
230
|
end
|
@@ -47,6 +47,7 @@ module OpenHAB
|
|
47
47
|
# rubocop:enable Naming/MethodName
|
48
48
|
|
49
49
|
# @!visibility private
|
50
|
+
# Override this because we don't have a registry
|
50
51
|
def unregister
|
51
52
|
clear
|
52
53
|
@registration.unregister
|
@@ -140,16 +141,6 @@ module OpenHAB
|
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
143
|
-
# For use in specs
|
144
|
-
# @!visibility private
|
145
|
-
def clear
|
146
|
-
elements = @elements
|
147
|
-
@elements = java.util.concurrent.ConcurrentHashMap.new
|
148
|
-
elements.each_value do |v|
|
149
|
-
notify_listeners_about_removed_element(v)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
144
|
#
|
154
145
|
# Notify listeners about updated sitemap
|
155
146
|
#
|
@@ -26,36 +26,20 @@ module OpenHAB
|
|
26
26
|
include Comparable
|
27
27
|
end
|
28
28
|
|
29
|
-
#
|
30
|
-
# Regex expression to identify strings defining a time in hours, minutes and optionally seconds
|
31
|
-
#
|
32
|
-
TIME_ONLY_REGEX = /\A(?<hours>\d\d):(?<minutes>\d\d)(?<seconds>:\d\d)?\Z/.freeze
|
33
|
-
|
34
|
-
#
|
35
|
-
# Regex expression to identify strings defining a time in year, month, and day
|
36
|
-
#
|
37
|
-
DATE_ONLY_REGEX = /\A\d{4}-\d\d-\d\d\Z/.freeze
|
38
|
-
private_constant :TIME_ONLY_REGEX, :DATE_ONLY_REGEX
|
39
|
-
|
40
29
|
class << self
|
41
30
|
#
|
42
|
-
#
|
43
|
-
# using Java's parser, then falls back to the Ruby `Time.parse`.
|
31
|
+
# Parse a time string into a {DateTimeType}.
|
44
32
|
#
|
45
|
-
# @
|
33
|
+
# @note openHAB's DateTimeType.new(String) constructor will parse time-only strings and fill in `1970-01-01`
|
34
|
+
# as the date, whereas this method will use the current date.
|
46
35
|
#
|
36
|
+
# @param (see DSL#try_parse_time_like)
|
47
37
|
# @return [DateTimeType]
|
48
38
|
#
|
49
39
|
def parse(time_string)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# Try Ruby's Time.parse if DateTimeType parser fails
|
54
|
-
begin
|
55
|
-
DateTimeType.new(::Time.parse(time_string).to_zoned_date_time)
|
56
|
-
rescue ArgumentError
|
57
|
-
raise ArgumentError, e.message
|
58
|
-
end
|
40
|
+
DateTimeType.new(DSL.try_parse_time_like(time_string).to_zoned_date_time)
|
41
|
+
rescue ArgumentError
|
42
|
+
raise ArgumentError, e.message
|
59
43
|
end
|
60
44
|
end
|
61
45
|
|
data/lib/openhab/dsl/version.rb
CHANGED
data/lib/openhab/dsl.rb
CHANGED
@@ -1072,6 +1072,16 @@ module OpenHAB
|
|
1072
1072
|
Thread.current[:openhab_holiday_file] = file
|
1073
1073
|
end
|
1074
1074
|
|
1075
|
+
#
|
1076
|
+
# @param [String] string Date/time string to parse.
|
1077
|
+
# The string can be in any format recognized by:
|
1078
|
+
# - {OpenHAB::CoreExt::Java::LocalTime.parse LocalTime.parse}
|
1079
|
+
# - {OpenHAB::CoreExt::Java::LocalDate.parse LocalDate.parse}
|
1080
|
+
# - {OpenHAB::CoreExt::Java::MonthDay.parse MonthDay.parse}, e.g. "12-25"
|
1081
|
+
# - {OpenHAB::CoreExt::Java::ZonedDateTime.parse ZonedDateTime.parse}
|
1082
|
+
# - [Time.parse](https://rubyapi.org/o/time#method-c-parse), e.g. "2021-01-01 12:00:", or "3:30pm"
|
1083
|
+
# @return [LocalTime, LocalDate, MonthDay, ZonedDateTime, Time] the parsed date/time
|
1084
|
+
#
|
1075
1085
|
# @!visibility private
|
1076
1086
|
def try_parse_time_like(string)
|
1077
1087
|
return string unless string.is_a?(String)
|
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.27.
|
4
|
+
version: 5.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian O'Connell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-09-
|
13
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|