Class: ChefBackup::Config
- Inherits:
-
Object
- Object
- ChefBackup::Config
- Extended by:
- Forwardable
- Defined in:
- lib/chef_backup/config.rb
Overview
ChefBackup Global Config
Constant Summary collapse
- DEFAULT_BASE =
"private_chef".freeze
- DEFAULT_CONFIG =
{ "backup" => { "always_dump_db" => true, "strategy" => "none", "export_dir" => "/var/opt/#{ChefUtils::Dist::Infra::SHORT}-backup", "project_name" => ChefUtils::Dist::Org::LEGACY_CONF_DIR, "ctl-command" => ChefUtils::Dist::Server::SERVER_CTL, "running_filepath" => "/etc/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Server::SERVER}-running.json", "database_name" => "opscode_chef", }, }.freeze
Class Method Summary collapse
- .[](key) ⇒ Object
- .[]=(key, value) ⇒ Object
- .config ⇒ Object
- .config=(hash) ⇒ Object
- .from_json_file(file) ⇒ Object
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Config
constructor
A new instance of Config.
- #to_hash ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Config
Returns a new instance of Config.
53 54 55 56 57 58 59 60 |
# File 'lib/chef_backup/config.rb', line 53 def initialize(config = {}) config["config_base"] ||= DEFAULT_BASE base = config["config_base"] config[base] ||= {} config[base]["backup"] ||= {} config[base]["backup"] = DEFAULT_CONFIG["backup"].merge(config[base]["backup"]) @config = config end |
Class Method Details
.[](key) ⇒ Object
33 34 35 |
# File 'lib/chef_backup/config.rb', line 33 def [](key) config[key] end |
.[]=(key, value) ⇒ Object
37 38 39 |
# File 'lib/chef_backup/config.rb', line 37 def []=(key, value) config[key] = value end |
.config ⇒ Object
25 26 27 |
# File 'lib/chef_backup/config.rb', line 25 def config @config ||= new end |
.config=(hash) ⇒ Object
29 30 31 |
# File 'lib/chef_backup/config.rb', line 29 def config=(hash) @config = new(hash) end |
.from_json_file(file) ⇒ Object
44 45 46 47 |
# File 'lib/chef_backup/config.rb', line 44 def from_json_file(file) path = File.(file) @config = new(JSON.parse(File.read(path))) if File.exist?(path) end |
Instance Method Details
#to_hash ⇒ Object
62 63 64 |
# File 'lib/chef_backup/config.rb', line 62 def to_hash @config end |