openhab-scripting 5.35.1 → 5.36.0
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 +105 -0
- data/lib/openhab/console/jline.rb +104 -0
- data/lib/openhab/console/registry.rb +12 -0
- data/lib/openhab/console/stdio.rb +178 -0
- data/lib/openhab/console.rb +5 -0
- data/lib/openhab/core/emulate_hash.rb +11 -11
- data/lib/openhab/core/entity_lookup.rb +2 -4
- data/lib/openhab/core/events/item_state_updated_event.rb +0 -3
- data/lib/openhab/core/events/item_time_series_updated_event.rb +0 -3
- data/lib/openhab/core/events/startlevel_event.rb +0 -3
- data/lib/openhab/core/events/timer_event.rb +0 -3
- data/lib/openhab/core/items/generic_item.rb +14 -154
- data/lib/openhab/core/items/group_item.rb +2 -2
- data/lib/openhab/core/items/image_item.rb +5 -21
- data/lib/openhab/core/items/item.rb +161 -7
- data/lib/openhab/core/items/persistence.rb +8 -10
- data/lib/openhab/core/items/provider.rb +1 -1
- data/lib/openhab/core/items/proxy.rb +33 -94
- data/lib/openhab/core/items/registry.rb +1 -1
- data/lib/openhab/core/items/semantics/enumerable.rb +1 -1
- data/lib/openhab/core/items/semantics/provider.rb +1 -5
- data/lib/openhab/core/items/semantics/semantic_tag.rb +0 -3
- data/lib/openhab/core/items/semantics.rb +105 -141
- data/lib/openhab/core/items/switch_item.rb +1 -1
- data/lib/openhab/core/items.rb +22 -22
- data/lib/openhab/core/lazy_array.rb +4 -4
- data/lib/openhab/core/profile_factory.rb +16 -25
- data/lib/openhab/core/provider.rb +3 -4
- data/lib/openhab/core/proxy.rb +160 -4
- data/lib/openhab/core/rules/registry.rb +2 -2
- data/lib/openhab/core/rules/rule.rb +4 -8
- data/lib/openhab/core/script_handling.rb +2 -2
- data/lib/openhab/core/sitemaps/provider.rb +1 -1
- data/lib/openhab/core/things/channel.rb +0 -28
- data/lib/openhab/core/things/profile_callback.rb +3 -3
- data/lib/openhab/core/things/proxy.rb +8 -51
- data/lib/openhab/core/things/registry.rb +1 -1
- data/lib/openhab/core/things/thing.rb +3 -5
- data/lib/openhab/core/types/command_description.rb +31 -0
- data/lib/openhab/core/types/date_time_type.rb +5 -10
- data/lib/openhab/core/types/decimal_type.rb +1 -1
- data/lib/openhab/core/types/hsb_type.rb +3 -5
- data/lib/openhab/core/types/point_type.rb +1 -1
- data/lib/openhab/core/types/quantity_type.rb +22 -2
- data/lib/openhab/core/types/raw_type.rb +10 -4
- data/lib/openhab/core/types/state_description.rb +54 -0
- data/lib/openhab/core/types/time_series.rb +0 -3
- data/lib/openhab/core/types.rb +2 -2
- data/lib/openhab/core/value_cache.rb +3 -3
- data/lib/openhab/core.rb +3 -5
- data/lib/openhab/core_ext/java/duration.rb +27 -8
- data/lib/openhab/core_ext/java/list.rb +1 -1
- data/lib/openhab/core_ext/java/local_date.rb +6 -2
- data/lib/openhab/core_ext/java/local_time.rb +4 -2
- data/lib/openhab/core_ext/java/map.rb +2 -2
- data/lib/openhab/core_ext/java/period.rb +9 -6
- data/lib/openhab/core_ext/java/temporal_amount.rb +5 -0
- data/lib/openhab/core_ext/java/zoned_date_time.rb +12 -6
- data/lib/openhab/core_ext/ruby/date.rb +8 -7
- data/lib/openhab/core_ext/ruby/date_time.rb +2 -2
- data/lib/openhab/core_ext/ruby/time.rb +2 -2
- data/lib/openhab/core_ext.rb +1 -1
- data/lib/openhab/dsl/config_description/builder.rb +1 -1
- data/lib/openhab/dsl/items/builder.rb +5 -13
- data/lib/openhab/dsl/items/ensure.rb +3 -5
- data/lib/openhab/dsl/items/timed_command.rb +4 -4
- data/lib/openhab/dsl/rules/automation_rule.rb +3 -3
- data/lib/openhab/dsl/rules/builder.rb +40 -52
- data/lib/openhab/dsl/rules/rule_triggers.rb +1 -1
- data/lib/openhab/dsl/rules/triggers/changed.rb +16 -15
- data/lib/openhab/dsl/rules/triggers/channel.rb +1 -1
- data/lib/openhab/dsl/rules/triggers/command.rb +2 -2
- data/lib/openhab/dsl/rules/triggers/conditions/duration.rb +4 -4
- data/lib/openhab/dsl/rules/triggers/cron/cron.rb +4 -14
- data/lib/openhab/dsl/rules/triggers/updated.rb +6 -6
- data/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +69 -124
- data/lib/openhab/dsl/sitemaps/builder.rb +7 -17
- data/lib/openhab/dsl/things/builder.rb +8 -8
- data/lib/openhab/dsl/timer_manager.rb +2 -2
- data/lib/openhab/dsl/version.rb +1 -1
- data/lib/openhab/dsl.rb +14 -15
- data/lib/openhab/log.rb +3 -3
- data/lib/openhab/osgi.rb +1 -1
- data/lib/openhab/rspec/helpers.rb +3 -3
- data/lib/openhab/rspec/hooks.rb +2 -8
- data/lib/openhab/rspec/jruby.rb +1 -1
- data/lib/openhab/rspec/karaf.rb +5 -27
- data/lib/openhab/rspec/mocks/persistence_service.rb +5 -5
- data/lib/openhab/yard/html_helper.rb +1 -1
- data/lib/openhab/yard.rb +1 -1
- metadata +18 -13
- data/lib/openhab/core/items/semantics/tag_class_methods.rb +0 -73
- data/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +0 -118
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f198e81a6fc5f5fa47a8a9ac4ac64e4749e64b94edb36771859bebdab249af0a
|
4
|
+
data.tar.gz: a1ab30b88528a5571f23e9ba0583a18821110c3f2bbfe1741e4bfe51ba819f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52404aa905b6e01c85350b714c8b4ee92f7aed669e28fb7502064ac86fa2a46833830eeb76a8f1055e5ebd51b22c2b0941bb1b6b548f11ef363bea5f080c99d9
|
7
|
+
data.tar.gz: ac2c7fc1e398ac72b36f63e83601ab3889570c9b759f218e3ef3a9421c71e92854ec5d2c2cde2053ea2de5bf96232c3dc2c0138690400c1187ed03799a6f9682
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "openhab/console/stdio"
|
4
|
+
|
5
|
+
gem "irb", "~> 1.15"
|
6
|
+
|
7
|
+
require "irb"
|
8
|
+
|
9
|
+
module OpenHAB
|
10
|
+
# @!visibility private
|
11
|
+
module Console
|
12
|
+
module IRB
|
13
|
+
class Exit < Exception; end # rubocop:disable Lint/InheritException
|
14
|
+
|
15
|
+
module Irb
|
16
|
+
# Define #exit instead of using Kernel#exit, to raise an error if we're not
|
17
|
+
# on the main thread (i.e. in the signal handler)
|
18
|
+
def exit
|
19
|
+
raise Exit unless Thread.current == context.thread
|
20
|
+
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
# Define #trap instead of using Kernel#trap, so that we register a signal handler against JLine.
|
25
|
+
# It can also never be as effective, since it's an SSH session, not a true signal, and thus it
|
26
|
+
# comes in as part of the input stream, and if we're not actively reading the input stream (cause
|
27
|
+
# we're executing a blocking Ruby method), we won't see it to be able to interrupt the Ruby code.
|
28
|
+
def trap(signal, handler = nil)
|
29
|
+
jline_signal = org.jline.terminal.Terminal::Signal.const_get(signal.sub(/^SIG/, ""), false)
|
30
|
+
return $terminal.handle(jline_signal, handler) if handler
|
31
|
+
|
32
|
+
$terminal.handle(jline_signal) do
|
33
|
+
yield
|
34
|
+
rescue StandardError, Exit => e
|
35
|
+
context.thread.raise e
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
::IRB::Irb.include(Irb)
|
40
|
+
|
41
|
+
module StdioInputMethod
|
42
|
+
# make sure we use our replacement stdio streams, and not the
|
43
|
+
# re-opened ones based on STDIN/STDOUT
|
44
|
+
def initialize
|
45
|
+
super
|
46
|
+
|
47
|
+
@stdin = $stdin
|
48
|
+
@stdout = $stdout
|
49
|
+
end
|
50
|
+
end
|
51
|
+
::IRB::StdioInputMethod.prepend(StdioInputMethod)
|
52
|
+
[::IRB::ReadlineInputMethod, ::IRB::RelineInputMethod].each do |klass|
|
53
|
+
klass.include(StdioInputMethod)
|
54
|
+
end
|
55
|
+
|
56
|
+
module ReadlineInputMethod
|
57
|
+
def initialize
|
58
|
+
super
|
59
|
+
|
60
|
+
$terminal.echo_enabled = false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
::IRB::ReadlineInputMethod.prepend(ReadlineInputMethod)
|
64
|
+
|
65
|
+
module EntityCompletor
|
66
|
+
VALID_ENTITY_PREFIXES = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
|
67
|
+
|
68
|
+
def completion_candidates(_preposing, target, _postposing, bind:)
|
69
|
+
return super unless defined?(OpenHAB::Core::EntityLookup)
|
70
|
+
return super unless VALID_ENTITY_PREFIXES.include?(target[0])
|
71
|
+
|
72
|
+
this = bind.eval("self")
|
73
|
+
return super unless this.is_a?(OpenHAB::Core::EntityLookup)
|
74
|
+
|
75
|
+
matching_items = OpenHAB::DSL.items.filter_map do |item|
|
76
|
+
item.name if item.name.start_with?(target)
|
77
|
+
end
|
78
|
+
matching_things = OpenHAB::DSL.things.filter_map do |thing|
|
79
|
+
id = thing.uid.to_s.tr(":", "_")
|
80
|
+
id if id.start_with?(target)
|
81
|
+
end
|
82
|
+
matching_items | matching_things | super
|
83
|
+
end
|
84
|
+
end
|
85
|
+
::IRB::RegexpCompletor.prepend(EntityCompletor)
|
86
|
+
::IRB::TypeCompletor.prepend(EntityCompletor)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# disable Reline for now; it's not working
|
92
|
+
IRB.conf[:USE_MULTILINE] = false
|
93
|
+
# Uncomment to disable Readline and force StdioInputMethod
|
94
|
+
# IRB.conf[:USE_SINGLELINE] = false
|
95
|
+
|
96
|
+
# IRB uses Reline to find the window size initially, even if it's not
|
97
|
+
# using the Reline input method
|
98
|
+
Reline.input = $stdin
|
99
|
+
Reline.output = $stdout
|
100
|
+
|
101
|
+
begin
|
102
|
+
IRB.start("karaf")
|
103
|
+
rescue OpenHAB::Console::IRB::Exit
|
104
|
+
exit
|
105
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "openhab/console/stdio"
|
4
|
+
|
5
|
+
module OpenHAB
|
6
|
+
module Console
|
7
|
+
#
|
8
|
+
# A basic JRuby REPL for openHAB Karaf console
|
9
|
+
#
|
10
|
+
# To use this, set the jrubyscripting add-on `console` configuration to `jline`
|
11
|
+
#
|
12
|
+
class JLine
|
13
|
+
# Create constants instead of java_import to avoid polluting the global namespace
|
14
|
+
LineReader = org.jline.reader.LineReader
|
15
|
+
Bracket = org.jline.reader.impl.DefaultParser::Bracket
|
16
|
+
|
17
|
+
BOLD = "\e[1m"
|
18
|
+
RESET = "\e[0m"
|
19
|
+
RED = "\e[31m"
|
20
|
+
GREEN = "\e[32m"
|
21
|
+
YELLOW = "\e[33m"
|
22
|
+
BLUE = "\e[34m"
|
23
|
+
CYAN = "\e[36m"
|
24
|
+
|
25
|
+
ERROR = RED
|
26
|
+
STRING = BOLD + YELLOW
|
27
|
+
NUMBER = BOLD + BLUE
|
28
|
+
OBJECT = BOLD + GREEN
|
29
|
+
SIMPLE_CLASS = BOLD + CYAN
|
30
|
+
PROMPT = "#{BOLD}JRuby> #{RESET}".freeze
|
31
|
+
|
32
|
+
class << self
|
33
|
+
def start
|
34
|
+
puts "Welcome to JRuby REPL. Press Ctrl+D to exit, Alt+Enter (or Esc,Enter) to insert a new line."
|
35
|
+
|
36
|
+
console = new
|
37
|
+
|
38
|
+
loop do
|
39
|
+
begin
|
40
|
+
input = console.read_line
|
41
|
+
next if input.strip.empty?
|
42
|
+
rescue org.jline.reader.UserInterruptException # Ctrl+C is pressed
|
43
|
+
next
|
44
|
+
rescue org.jline.reader.EndOfFileException # Ctrl+D is pressed
|
45
|
+
break
|
46
|
+
end
|
47
|
+
|
48
|
+
begin
|
49
|
+
# Use TOPLEVEL_BINDING to isolate and keep the local variables between loops
|
50
|
+
result = TOPLEVEL_BINDING.eval(input)
|
51
|
+
console.print_result(result)
|
52
|
+
rescue Exception => e
|
53
|
+
console.print_error(e)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def initialize
|
60
|
+
parser = org.jline.reader.impl.DefaultParser.new
|
61
|
+
.eof_on_unclosed_bracket(Bracket::CURLY, Bracket::ROUND, Bracket::SQUARE)
|
62
|
+
.eof_on_unclosed_quote(true)
|
63
|
+
.eof_on_escaped_new_line(true)
|
64
|
+
|
65
|
+
completer =
|
66
|
+
org.jline.reader.Completer.impl do |_method_name, _reader, _line, candidates|
|
67
|
+
sources = TOPLEVEL_BINDING.local_variables + Object.constants
|
68
|
+
sources += DSL.items.map(&:name) + DSL.methods(false) if defined?(DSL)
|
69
|
+
|
70
|
+
candidates.add_all(sources.map { |c| org.jline.reader.Candidate.new(c.to_s) })
|
71
|
+
end
|
72
|
+
|
73
|
+
@reader = org.jline.reader.LineReaderBuilder.builder
|
74
|
+
.terminal($terminal)
|
75
|
+
.app_name("jrubyscripting")
|
76
|
+
.parser(parser)
|
77
|
+
.completer(completer)
|
78
|
+
.variable(LineReader::SECONDARY_PROMPT_PATTERN, "%M%P > ")
|
79
|
+
.variable(LineReader::INDENTATION, 2)
|
80
|
+
.build
|
81
|
+
end
|
82
|
+
|
83
|
+
def read_line
|
84
|
+
@reader.read_line(PROMPT)
|
85
|
+
end
|
86
|
+
|
87
|
+
def print_result(result)
|
88
|
+
puts "=> " + # rubocop:disable Style/StringConcatenation
|
89
|
+
case result
|
90
|
+
when nil, true, false then SIMPLE_CLASS + result.inspect + RESET
|
91
|
+
when String then %("#{STRING}#{result.dump[1..-2]}#{RESET}")
|
92
|
+
when Numeric, Array, Hash then NUMBER + result.to_s + RESET
|
93
|
+
else OBJECT + result.inspect + RESET
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def print_error(error)
|
98
|
+
puts ERROR + "Error: #{error.message}" + RESET
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
OpenHAB::Console::JLine.start
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This provides the list for the `jrubyscripting console --list` command
|
4
|
+
module OpenHAB
|
5
|
+
module Console
|
6
|
+
# The keys are the names of the file to be required
|
7
|
+
REGISTRY = {
|
8
|
+
jline: "A basic JRuby REPL",
|
9
|
+
irb: "IRB console"
|
10
|
+
}.freeze
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "openhab/console"
|
4
|
+
require "stringio"
|
5
|
+
|
6
|
+
module OpenHAB
|
7
|
+
# @!visibility private
|
8
|
+
module Console
|
9
|
+
class Stdio
|
10
|
+
attr_reader :internal_encoding
|
11
|
+
|
12
|
+
def initialize(terminal)
|
13
|
+
@terminal = terminal
|
14
|
+
@external_encoding = Encoding.find(@terminal.encoding.name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_encoding(_external, internal = nil, _options = {})
|
18
|
+
@internal_encoding = internal
|
19
|
+
end
|
20
|
+
|
21
|
+
def tty?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def winsize
|
26
|
+
[@terminal.width, @terminal.height]
|
27
|
+
end
|
28
|
+
|
29
|
+
def inspect
|
30
|
+
"#<#{self.class}>"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Stdin < Stdio
|
35
|
+
attr_reader :external_encoding, :internal_encoding
|
36
|
+
|
37
|
+
def initialize(terminal)
|
38
|
+
super
|
39
|
+
|
40
|
+
@byte_stream = terminal.input
|
41
|
+
@buffer = StringIO.new.set_encoding(external_encoding)
|
42
|
+
end
|
43
|
+
|
44
|
+
def getbyte
|
45
|
+
unless @buffer.eof?
|
46
|
+
b = @buffer.getbyte
|
47
|
+
@buffer.truncate(0) if @buffer.eof?
|
48
|
+
return b
|
49
|
+
end
|
50
|
+
|
51
|
+
b = @byte_stream.read
|
52
|
+
return nil if b.negative?
|
53
|
+
|
54
|
+
b
|
55
|
+
end
|
56
|
+
|
57
|
+
def getc
|
58
|
+
unless @buffer.eof?
|
59
|
+
c = @buffer.getc
|
60
|
+
@buffer.truncate(0) if @buffer.eof?
|
61
|
+
return c
|
62
|
+
end
|
63
|
+
bytes = (+"").force_encoding(Encoding::BINARY)
|
64
|
+
loop do
|
65
|
+
b = getbyte
|
66
|
+
return nil if b.nil?
|
67
|
+
|
68
|
+
bytes << b.chr
|
69
|
+
c = bytes.encode(external_encoding,
|
70
|
+
internal_encoding || Encoding.default_internal,
|
71
|
+
invalid: :replace,
|
72
|
+
undef: :replace,
|
73
|
+
replace: "")
|
74
|
+
return c unless c.empty?
|
75
|
+
end
|
76
|
+
rescue java.io.InterruptedIOException
|
77
|
+
raise Interrupt
|
78
|
+
end
|
79
|
+
|
80
|
+
def ungetbyte(byte)
|
81
|
+
@buffer.ungetbyte(byte)
|
82
|
+
end
|
83
|
+
|
84
|
+
def ungetc(char)
|
85
|
+
@buffer.ungetc(char)
|
86
|
+
end
|
87
|
+
|
88
|
+
def gets
|
89
|
+
result = +""
|
90
|
+
loop do
|
91
|
+
c = getc
|
92
|
+
if c.nil?
|
93
|
+
return nil if result.empty?
|
94
|
+
|
95
|
+
break
|
96
|
+
end
|
97
|
+
|
98
|
+
if c == "\x04" && result.empty? # ^D
|
99
|
+
return nil
|
100
|
+
elsif c == "\x7f"
|
101
|
+
result.slice(0...-1)
|
102
|
+
else
|
103
|
+
result << c
|
104
|
+
end
|
105
|
+
break if c == "\n"
|
106
|
+
end
|
107
|
+
result
|
108
|
+
rescue java.io.InterruptedIOException
|
109
|
+
raise Interrupt
|
110
|
+
end
|
111
|
+
|
112
|
+
def read(bytes)
|
113
|
+
r = readpartial(bytes)
|
114
|
+
r.concat(readpartial(bytes - r.bytesize)) while r.bytesize < bytes
|
115
|
+
r
|
116
|
+
end
|
117
|
+
|
118
|
+
def readpartial(bytes)
|
119
|
+
available = @buffer.size - @buffer.tell
|
120
|
+
if available.positive?
|
121
|
+
bytes = available if available < bytes
|
122
|
+
r = @buffer.read(bytes)
|
123
|
+
@buffer.truncate(0) if @buffer.eof?
|
124
|
+
return r
|
125
|
+
end
|
126
|
+
|
127
|
+
buffer = Java::byte[bytes].new
|
128
|
+
read = @byte_stream.read_buffered(buffer)
|
129
|
+
buffer = buffer[0..read] if read != bytes
|
130
|
+
String.from_java_bytes(buffer)
|
131
|
+
end
|
132
|
+
alias_method :read_nonblock, :readpartial
|
133
|
+
|
134
|
+
def wait_readable(timeout = nil)
|
135
|
+
return true if (@buffer.size - @buffer.tell).positive?
|
136
|
+
|
137
|
+
timeout = timeout ? 0 : timeout * 1000
|
138
|
+
char = @byte_stream.read(timeout)
|
139
|
+
return nil if char.negative? # timeout
|
140
|
+
|
141
|
+
ungetc(char.chr(external_encoding))
|
142
|
+
self
|
143
|
+
end
|
144
|
+
|
145
|
+
def raw(*)
|
146
|
+
previous_attributes = @terminal.enter_raw_mode
|
147
|
+
yield self
|
148
|
+
ensure
|
149
|
+
@terminal.set_attributes(previous_attributes)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
class Stdout < Stdio
|
154
|
+
def initialize(terminal)
|
155
|
+
super
|
156
|
+
@writer = terminal.writer
|
157
|
+
end
|
158
|
+
|
159
|
+
def write(output)
|
160
|
+
@writer.print(output)
|
161
|
+
@writer.flush
|
162
|
+
end
|
163
|
+
alias_method :<<, :write
|
164
|
+
|
165
|
+
def flush
|
166
|
+
@writer.flush
|
167
|
+
end
|
168
|
+
|
169
|
+
def puts(output)
|
170
|
+
output = output.join("\n") if output.is_a?(Array)
|
171
|
+
@writer.println(output.to_s)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
$stdin = OpenHAB::Console::Stdin.new($terminal)
|
178
|
+
$stdout = $stderr = OpenHAB::Console::Stdout.new($terminal)
|
@@ -86,16 +86,16 @@ module OpenHAB
|
|
86
86
|
# java.util.Map#merge is incompatible to Ruby's, but JRuby provides #ruby_merge for it
|
87
87
|
#
|
88
88
|
# @!visibility private
|
89
|
-
def merge(*others, &
|
89
|
+
def merge(*others, &)
|
90
90
|
return self if others.empty?
|
91
91
|
|
92
92
|
others.map! { |hash| hash.transform_keys(&:to_s) }
|
93
93
|
map = to_map
|
94
94
|
if map.respond_to?(:ruby_merge)
|
95
|
-
map.ruby_merge(*others, &
|
95
|
+
map.ruby_merge(*others, &)
|
96
96
|
else
|
97
97
|
# fall back to #merge in case #to_map returns a Ruby Hash
|
98
|
-
map.merge(*others, &
|
98
|
+
map.merge(*others, &)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -123,8 +123,8 @@ module OpenHAB
|
|
123
123
|
end
|
124
124
|
|
125
125
|
# @!visibility private
|
126
|
-
def fetch(key, *default, &
|
127
|
-
to_map.fetch(key.to_s, *default, &
|
126
|
+
def fetch(key, *default, &)
|
127
|
+
to_map.fetch(key.to_s, *default, &)
|
128
128
|
end
|
129
129
|
|
130
130
|
# @!visibility private
|
@@ -170,8 +170,8 @@ module OpenHAB
|
|
170
170
|
end
|
171
171
|
|
172
172
|
# @!visibility private
|
173
|
-
def keep_if(&
|
174
|
-
select!(&
|
173
|
+
def keep_if(&)
|
174
|
+
select!(&)
|
175
175
|
self
|
176
176
|
end
|
177
177
|
|
@@ -191,13 +191,13 @@ module OpenHAB
|
|
191
191
|
end
|
192
192
|
|
193
193
|
# @!visibility private
|
194
|
-
def fetch_values(*keys, &
|
195
|
-
to_map.fetch_values(*keys.map(&:to_s), &
|
194
|
+
def fetch_values(*keys, &)
|
195
|
+
to_map.fetch_values(*keys.map(&:to_s), &)
|
196
196
|
end
|
197
197
|
|
198
198
|
# @!visibility private
|
199
|
-
def transform_keys!(
|
200
|
-
replace(transform_keys(
|
199
|
+
def transform_keys!(...)
|
200
|
+
replace(transform_keys(...))
|
201
201
|
end
|
202
202
|
|
203
203
|
# @!visibility private
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "ruby2_keywords"
|
4
|
-
|
5
3
|
module OpenHAB
|
6
4
|
module Core
|
7
5
|
#
|
@@ -123,7 +121,7 @@ module OpenHAB
|
|
123
121
|
#
|
124
122
|
# @return [Item, Things::Thing, nil]
|
125
123
|
#
|
126
|
-
|
124
|
+
def method_missing(method, *args)
|
127
125
|
return super unless args.empty? && !block_given?
|
128
126
|
|
129
127
|
logger.trace { "method missing, performing openHAB Lookup for: #{method}" }
|
@@ -160,7 +158,7 @@ module OpenHAB
|
|
160
158
|
def lookup_entity(name, create_dummy_items: false)
|
161
159
|
# make sure we have a nil return
|
162
160
|
create_dummy_items = nil if create_dummy_items == false
|
163
|
-
lookup_item(name) || lookup_thing_const(name) || (create_dummy_items && Items::Proxy.new(name.
|
161
|
+
lookup_item(name) || lookup_thing_const(name) || (create_dummy_items && Items::Proxy.new(name.to_s))
|
164
162
|
end
|
165
163
|
|
166
164
|
#
|