class Dogen::Configuration
Constants
- CONFIG_FILE_NAME
Public Instance Methods
clear()
click to toggle source
# File lib/dogen/configuration.rb, line 21 def clear File.write(config_file, {}.to_yaml) end
get()
click to toggle source
# File lib/dogen/configuration.rb, line 10 def get File.exist?(config_file) ? load_configuration : {} end
set(hash)
click to toggle source
# File lib/dogen/configuration.rb, line 14 def set(hash) raise SetConfigError, 'argument is not kind of hash' unless hash.kind_of?(Hash) updated_config = get.merge(hash) save_configuration(updated_config) end
Private Instance Methods
config_file()
click to toggle source
# File lib/dogen/configuration.rb, line 37 def config_file File.expand_path(CONFIG_FILE_NAME, Dir.home) end
load_configuration()
click to toggle source
# File lib/dogen/configuration.rb, line 31 def load_configuration Hashie::Mash.new(YAML.load_file(config_file)) rescue {} end
save_configuration(config)
click to toggle source
# File lib/dogen/configuration.rb, line 27 def save_configuration(config) File.write(config_file, config.to_yaml) end