class Glman::ConfigManager
Public Instance Methods
clear()
click to toggle source
# File lib/glman/config_manager.rb, line 19 def clear File.write(config_file, {}.to_yaml) end
get()
click to toggle source
# File lib/glman/config_manager.rb, line 8 def get File.exist?(config_file) ? load_configuration : {} end
set(hash)
click to toggle source
# File lib/glman/config_manager.rb, line 12 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/glman/config_manager.rb, line 35 def config_file File.expand_path('.glmanrc',Dir.home) end
load_configuration()
click to toggle source
# File lib/glman/config_manager.rb, line 29 def load_configuration Hashie::Mash.new(YAML.load_file(config_file)) rescue {} end
save_configuration(config)
click to toggle source
# File lib/glman/config_manager.rb, line 25 def save_configuration(config) File.write(config_file, config.to_yaml) end