Class: Ruborg::Config
- Inherits:
-
Object
- Object
- Ruborg::Config
- Defined in:
- lib/ruborg/config.rb
Overview
Configuration management for ruborg Only supports multi-repository format
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #get_repository(name) ⇒ Object
- #global_settings ⇒ Object
-
#initialize(config_path, validate_types: true) ⇒ Config
constructor
A new instance of Config.
- #load_config ⇒ Object
- #repositories ⇒ Object
- #repository_names ⇒ Object
Constructor Details
#initialize(config_path, validate_types: true) ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 |
# File 'lib/ruborg/config.rb', line 12 def initialize(config_path, validate_types: true) @config_path = config_path @validate_types = validate_types load_config validate_format validate_schema if @validate_types end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/ruborg/config.rb', line 10 def data @data end |
Instance Method Details
#get_repository(name) ⇒ Object
34 35 36 |
# File 'lib/ruborg/config.rb', line 34 def get_repository(name) repositories.find { |r| r["name"] == name } end |
#global_settings ⇒ Object
42 43 44 45 |
# File 'lib/ruborg/config.rb', line 42 def global_settings @data.slice("passbolt", "compression", "encryption", "auto_init", "borg_options", "log_file", "retention", "auto_prune", "hostname", "allow_remove_source", "borg_path", "skip_hash_check", "lock_wait") end |
#load_config ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/ruborg/config.rb', line 20 def load_config raise ConfigError, "Configuration file not found: #{@config_path}" unless File.exist?(@config_path) @data = YAML.safe_load_file(@config_path, permitted_classes: [Symbol], aliases: true) rescue Psych::SyntaxError => e raise ConfigError, "Invalid YAML syntax: #{e.}" rescue Psych::DisallowedClass => e raise ConfigError, "Invalid YAML content: #{e.}" end |
#repositories ⇒ Object
30 31 32 |
# File 'lib/ruborg/config.rb', line 30 def repositories @data["repositories"] || [] end |
#repository_names ⇒ Object
38 39 40 |
# File 'lib/ruborg/config.rb', line 38 def repository_names repositories.map { |r| r["name"] } end |