mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[jrubyscripting] Accept generic global variable names (#12539)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
parent
e8c944281a
commit
77c765085e
@ -48,9 +48,6 @@ public class JRubyScriptEngineFactory extends AbstractScriptEngineFactory {
|
||||
// difficult ways to debug.
|
||||
private static final Set<String> FILTERED_PRESETS = Set.of("File", "Files", "Path", "Paths");
|
||||
private static final Set<String> INSTANCE_PRESETS = Set.of();
|
||||
private static final Set<String> GLOBAL_PRESETS = Set.of("scriptExtension", "automationManager", "ruleRegistry",
|
||||
"items", "voice", "rules", "things", "events", "itemRegistry", "ir", "actions", "se", "audio",
|
||||
"lifecycleTracker");
|
||||
|
||||
private final javax.script.ScriptEngineFactory factory = new org.jruby.embed.jsr223.JRubyEngineFactory();
|
||||
|
||||
@ -69,7 +66,8 @@ public class JRubyScriptEngineFactory extends AbstractScriptEngineFactory {
|
||||
|
||||
// Adds $ in front of a set of variables so that Ruby recognizes them as global variables
|
||||
private static Map.Entry<String, Object> mapGlobalPresets(Map.Entry<String, Object> entry) {
|
||||
if (GLOBAL_PRESETS.contains(entry.getKey())) {
|
||||
if (Character.isLowerCase(entry.getKey().charAt(0)) && !(entry.getValue() instanceof Class)
|
||||
&& !(entry.getValue() instanceof Enum)) {
|
||||
return Map.entry("$" + entry.getKey(), entry.getValue());
|
||||
} else {
|
||||
return entry;
|
||||
|
Loading…
Reference in New Issue
Block a user