Sha256: 043946d5425a7734328ff4a8420835d53f11cf79d337dce008e73a17c6b1eecb
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
require 'yaml' module Flow::Cli module Utils class DbManager class << self FLOW_CLI_CONFIG = "#{ENV['HOME']}/.flow_cli_config.yml".freeze def overide_save(hash) File.open(FLOW_CLI_CONFIG, "w") do |file| file << hash.to_yaml end hash end def reset overide_save({}) end def save(settings) old = read settings = old.merge(settings).compact.stringify_keys yaml = settings.to_yaml File.open(FLOW_CLI_CONFIG, "w") do |file| file << yaml end settings end def save_attribute(key, val) dict = read dict[key.to_s] = val save(dict) end def read return {} unless File.file?(FLOW_CLI_CONFIG) config = YAML.safe_load(File.read(FLOW_CLI_CONFIG)) raise "yaml load is not a hash #{config.class}" unless config.is_a? Hash config end def read_attribute(key) read[key.to_s] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flow-cli-0.0.7 | lib/flow/cli/utils/db_manager.rb |
flow-cli-0.0.6 | lib/flow/cli/utils/db_manager.rb |
flow-cli-0.0.5 | lib/flow/cli/utils/db_manager.rb |