Class: OpenC3::ToolConfigModel
- Inherits:
-
Object
- Object
- OpenC3::ToolConfigModel
show all
- Defined in:
- lib/openc3/models/tool_config_model.rb
Defined Under Namespace
Classes: InvalidNameError
Constant Summary
collapse
- VALID_NAME_PATTERN =
Allowlist: letters, digits, hyphens, underscores, spaces, and periods
/\A[A-Za-z0-9_\-. ]+\z/
Class Method Summary
collapse
-
.config_tool_names(scope: $openc3_scope) ⇒ Object
-
.delete_config(tool, name, local_mode: true, scope: $openc3_scope) ⇒ Object
-
.list_configs(tool, scope: $openc3_scope) ⇒ Object
-
.load_config(tool, name, scope: $openc3_scope) ⇒ Object
-
.save_config(tool, name, data, local_mode: true, scope: $openc3_scope) ⇒ Object
Class Method Details
27
28
29
30
31
|
# File 'lib/openc3/models/tool_config_model.rb', line 27
def self.config_tool_names(scope: $openc3_scope)
_, keys = Store.scan(0, match: "#{scope}__config__*", type: 'hash', count: 100)
return keys.map! { |key| key.split('__')[2] }.sort
end
|
.delete_config(tool, name, local_mode: true, scope: $openc3_scope) ⇒ Object
.list_configs(tool, scope: $openc3_scope) ⇒ Object
33
34
35
36
|
# File 'lib/openc3/models/tool_config_model.rb', line 33
def self.list_configs(tool, scope: $openc3_scope)
raise InvalidNameError, "Invalid tool name: #{tool}" unless tool.match?(VALID_NAME_PATTERN)
Store.hkeys("#{scope}__config__#{tool}")
end
|
.load_config(tool, name, scope: $openc3_scope) ⇒ Object
.save_config(tool, name, data, local_mode: true, scope: $openc3_scope) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/openc3/models/tool_config_model.rb', line 44
def self.save_config(tool, name, data, local_mode: true, scope: $openc3_scope)
raise InvalidNameError, "Invalid tool name: #{tool}" unless tool.match?(VALID_NAME_PATTERN)
raise InvalidNameError, "Invalid config name: #{name}" unless name.match?(VALID_NAME_PATTERN)
Store.hset("#{scope}__config__#{tool}", name, data)
LocalMode.save_tool_config(scope, tool, name, data) if local_mode
end
|