Sha256: f6782365bc96ff511de583ea5be12de698fe4781bbcf955fb60ccb1869555735
Contents?: true
Size: 745 Bytes
Versions: 4
Compression:
Stored size: 745 Bytes
Contents
require 'yaml' require 'hashie' module Glman class ConfigManager class SetConfigError < StandardError; end def get File.exist?(config_file) ? load_configuration : {} end 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 def clear File.write(config_file, {}.to_yaml) end private def save_configuration(config) File.write(config_file, config.to_yaml) end def load_configuration Hashie::Mash.new(YAML.load_file(config_file)) rescue {} end def config_file File.expand_path('.glmanrc',Dir.home) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
glman-0.1.3 | lib/glman/config_manager.rb |
glman-0.1.2 | lib/glman/config_manager.rb |
glman-0.1.1 | lib/glman/config_manager.rb |
glman-0.1.0 | lib/glman/config_manager.rb |