openhab-scripting 5.46.1 → 5.47.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 +4 -4
- data/lib/openhab/console/irb.rb +3 -2
- data/lib/openhab/console/stdio.rb +41 -5
- data/lib/openhab/core/abstract_uid.rb +11 -0
- data/lib/openhab/core/proxy.rb +14 -0
- data/lib/openhab/dsl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7789ba23937f06bb67047cbd521c7d92cc39d2de07d4e9fdf6537d86d06bfc32
|
|
4
|
+
data.tar.gz: 75a33c51386b1cff67e16c10de9f412bd9055389f4780be1b68a9d98409545a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a7f5e8fcf1a0bbf52d9af80e9de6a6552c319c259d62ed7ae42cae373da1356e09236ee29687f479678849e5c49a6d7d65eac40d7f5e7505a88745c800a6d7fe
|
|
7
|
+
data.tar.gz: 7171205645a97d3bb6e2fbfc089f103d2e0be94c7f77eb02d1667b06b5812f223750d147a97ae0313903079c65ecaedc8074ed129ffca2b91e34e1eda0c33b22
|
data/lib/openhab/console/irb.rb
CHANGED
|
@@ -67,6 +67,7 @@ module OpenHAB
|
|
|
67
67
|
|
|
68
68
|
def completion_candidates(_preposing, target, _postposing, bind:)
|
|
69
69
|
return super unless defined?(OpenHAB::Core::EntityLookup)
|
|
70
|
+
return super if target.empty?
|
|
70
71
|
return super unless VALID_ENTITY_PREFIXES.include?(target[0])
|
|
71
72
|
|
|
72
73
|
this = bind.eval("self")
|
|
@@ -88,8 +89,8 @@ module OpenHAB
|
|
|
88
89
|
end
|
|
89
90
|
end
|
|
90
91
|
|
|
91
|
-
# disable Reline
|
|
92
|
-
IRB.conf[:USE_MULTILINE] = false
|
|
92
|
+
# Uncomment to disable Reline and use Readline or StdioInputMethod
|
|
93
|
+
# IRB.conf[:USE_MULTILINE] = false
|
|
93
94
|
# Uncomment to disable Readline and force StdioInputMethod
|
|
94
95
|
# IRB.conf[:USE_SINGLELINE] = false
|
|
95
96
|
|
|
@@ -39,6 +39,11 @@ module OpenHAB
|
|
|
39
39
|
|
|
40
40
|
@byte_stream = terminal.input
|
|
41
41
|
@buffer = StringIO.new.set_encoding(external_encoding)
|
|
42
|
+
@eof = false
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def eof?
|
|
46
|
+
@buffer.eof? && @eof
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def getbyte
|
|
@@ -47,6 +52,7 @@ module OpenHAB
|
|
|
47
52
|
@buffer.truncate(0) if @buffer.eof?
|
|
48
53
|
return b
|
|
49
54
|
end
|
|
55
|
+
return nil if eof?
|
|
50
56
|
|
|
51
57
|
b = @byte_stream.read
|
|
52
58
|
return nil if b.negative?
|
|
@@ -60,6 +66,8 @@ module OpenHAB
|
|
|
60
66
|
@buffer.truncate(0) if @buffer.eof?
|
|
61
67
|
return c
|
|
62
68
|
end
|
|
69
|
+
return nil if eof?
|
|
70
|
+
|
|
63
71
|
bytes = (+"").force_encoding(Encoding::BINARY)
|
|
64
72
|
loop do
|
|
65
73
|
b = getbyte
|
|
@@ -110,7 +118,9 @@ module OpenHAB
|
|
|
110
118
|
end
|
|
111
119
|
|
|
112
120
|
def read(bytes)
|
|
113
|
-
r = readpartial(bytes)
|
|
121
|
+
r = readpartial(bytes) if !eof? || (@buffer.size - @buffer.tell).positive?
|
|
122
|
+
return nil if r.nil?
|
|
123
|
+
|
|
114
124
|
r.concat(readpartial(bytes - r.bytesize)) while r.bytesize < bytes
|
|
115
125
|
r
|
|
116
126
|
end
|
|
@@ -124,6 +134,8 @@ module OpenHAB
|
|
|
124
134
|
return r
|
|
125
135
|
end
|
|
126
136
|
|
|
137
|
+
raise EOFError, "end of file reached" if eof?
|
|
138
|
+
|
|
127
139
|
buffer = Java::byte[bytes].new
|
|
128
140
|
read = @byte_stream.read_buffered(buffer)
|
|
129
141
|
buffer = buffer[0..read] if read != bytes
|
|
@@ -134,19 +146,43 @@ module OpenHAB
|
|
|
134
146
|
def wait_readable(timeout = nil)
|
|
135
147
|
return true if (@buffer.size - @buffer.tell).positive?
|
|
136
148
|
|
|
137
|
-
|
|
149
|
+
return @byte_stream.available.positive? ? self : nil if timeout == 0 # rubocop:disable Style/NumericPredicate
|
|
150
|
+
|
|
151
|
+
timeout = timeout ? timeout * 1000 : 0
|
|
138
152
|
char = @byte_stream.read(timeout)
|
|
153
|
+
if char == -1
|
|
154
|
+
@eof = true
|
|
155
|
+
# this is not normal behavior for wait_readable, but it seems like when the SSH client
|
|
156
|
+
# disconnects, JLine just "closes" the NonBlockingPumpInputStream, and doesn't trigger
|
|
157
|
+
# any signals. On the other end, Reline just keeps calling this repetitively forever
|
|
158
|
+
# if we're at EOF, with the only way to break out to be check signals. So raise an exception
|
|
159
|
+
# here.
|
|
160
|
+
raise EOFError, "end of file reached"
|
|
161
|
+
end
|
|
139
162
|
return nil if char.negative? # timeout
|
|
140
163
|
|
|
141
164
|
ungetc(char.chr(external_encoding))
|
|
142
165
|
self
|
|
143
166
|
end
|
|
144
167
|
|
|
145
|
-
def raw(
|
|
146
|
-
previous_attributes = @terminal.
|
|
168
|
+
def raw(min: nil, time: nil, intr: nil)
|
|
169
|
+
previous_attributes = @terminal.attributes
|
|
170
|
+
new_attributes = @terminal.attributes
|
|
171
|
+
new_attributes.set_local_flags(java.util.EnumSet.of(org.jline.terminal.Attributes::LocalFlag::ICANON,
|
|
172
|
+
org.jline.terminal.Attributes::LocalFlag::ECHO,
|
|
173
|
+
org.jline.terminal.Attributes::LocalFlag::IEXTEN),
|
|
174
|
+
false)
|
|
175
|
+
new_attributes.set_local_flag(org.jline.terminal.Attributes::LocalFlag::ISIG, !!intr) # rubocop:disable Style/DoubleNegation
|
|
176
|
+
new_attributes.set_input_flags(java.util.EnumSet.of(org.jline.terminal.Attributes::InputFlag::IXON,
|
|
177
|
+
org.jline.terminal.Attributes::InputFlag::ICRNL,
|
|
178
|
+
org.jline.terminal.Attributes::InputFlag::INLCR),
|
|
179
|
+
false)
|
|
180
|
+
new_attributes.set_control_char(org.jline.terminal.Attributes::ControlChar::VMIN, min || 1)
|
|
181
|
+
new_attributes.set_control_char(org.jline.terminal.Attributes::ControlChar::VTIME, ((time || 0) * 10).to_i)
|
|
182
|
+
@terminal.attributes = new_attributes
|
|
147
183
|
yield self
|
|
148
184
|
ensure
|
|
149
|
-
@terminal.set_attributes(previous_attributes)
|
|
185
|
+
@terminal.set_attributes(previous_attributes) if previous_attributes
|
|
150
186
|
end
|
|
151
187
|
end
|
|
152
188
|
|
|
@@ -6,6 +6,8 @@ module OpenHAB
|
|
|
6
6
|
|
|
7
7
|
# A non specific base class for unique identifiers.
|
|
8
8
|
class AbstractUID
|
|
9
|
+
extend Forwardable
|
|
10
|
+
|
|
9
11
|
# implicit conversion to string
|
|
10
12
|
alias_method :to_str, :to_s
|
|
11
13
|
# inspect result is just the string representation
|
|
@@ -18,6 +20,15 @@ module OpenHAB
|
|
|
18
20
|
|
|
19
21
|
to_s == other
|
|
20
22
|
end
|
|
23
|
+
|
|
24
|
+
def_delegators :to_s,
|
|
25
|
+
:start_with?,
|
|
26
|
+
:end_with?,
|
|
27
|
+
:include?,
|
|
28
|
+
:match,
|
|
29
|
+
:match?,
|
|
30
|
+
:=~,
|
|
31
|
+
:length
|
|
21
32
|
end
|
|
22
33
|
|
|
23
34
|
# have to remove == from all descendant classes so that they'll inherit
|
data/lib/openhab/core/proxy.rb
CHANGED
|
@@ -251,6 +251,20 @@ module OpenHAB
|
|
|
251
251
|
!(self == other) # rubocop:disable Style/InverseMethods
|
|
252
252
|
end
|
|
253
253
|
|
|
254
|
+
#
|
|
255
|
+
# Check if delegates are case-like
|
|
256
|
+
#
|
|
257
|
+
# Otherwise items can't be used in Ruby case statements
|
|
258
|
+
#
|
|
259
|
+
# @return [true, false]
|
|
260
|
+
#
|
|
261
|
+
# @!visibility private
|
|
262
|
+
def ===(other)
|
|
263
|
+
return __getobj__ === other.__getobj__ if other.instance_of?(@klass) # rubocop:disable Style/CaseEquality
|
|
264
|
+
|
|
265
|
+
super
|
|
266
|
+
end
|
|
267
|
+
|
|
254
268
|
# @return [String]
|
|
255
269
|
def to_s
|
|
256
270
|
target = __getobj__
|
data/lib/openhab/dsl/version.rb
CHANGED