class ChefBackup::Config

ChefBackup Global Config

Constants

DEFAULT_BASE
DEFAULT_CONFIG

Public Class Methods

[](key) click to toggle source
# File lib/chef_backup/config.rb, line 32
def [](key)
  config[key]
end
[]=(key, value) click to toggle source
# File lib/chef_backup/config.rb, line 36
def []=(key, value)
  config[key] = value
end
config() click to toggle source
# File lib/chef_backup/config.rb, line 24
def config
  @config ||= new
end
config=(hash) click to toggle source
# File lib/chef_backup/config.rb, line 28
def config=(hash)
  @config = new(hash)
end
from_json_file(file) click to toggle source

@param file [String] path to a JSON configration file

# File lib/chef_backup/config.rb, line 43
def from_json_file(file)
  path = File.expand_path(file)
  @config = new(JSON.parse(File.read(path))) if File.exist?(path)
end
new(config = {}) click to toggle source

@param config [Hash] a Hash of the private-chef-running.json

# 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

Public Instance Methods

to_hash() click to toggle source
# File lib/chef_backup/config.rb, line 61
def to_hash
  @config
end