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/chef-backup", "project_name" => "opscode", "ctl-command" => "chef-server-ctl", "running_filepath" => "/etc/opscode/chef-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.
52 53 54 55 56 57 58 59 |
# File 'lib/chef_backup/config.rb', line 52 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
32 33 34 |
# File 'lib/chef_backup/config.rb', line 32 def [](key) config[key] end |
.[]=(key, value) ⇒ Object
36 37 38 |
# File 'lib/chef_backup/config.rb', line 36 def []=(key, value) config[key] = value end |
.config ⇒ Object
24 25 26 |
# File 'lib/chef_backup/config.rb', line 24 def config @config ||= new end |
.config=(hash) ⇒ Object
28 29 30 |
# File 'lib/chef_backup/config.rb', line 28 def config=(hash) @config = new(hash) end |
.from_json_file(file) ⇒ Object
43 44 45 46 |
# File 'lib/chef_backup/config.rb', line 43 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
61 62 63 |
# File 'lib/chef_backup/config.rb', line 61 def to_hash @config end |