Sha256: 90332b807180b7c6aa63d5c1a6267a333619583fa2459c717a3c4d1c3cab7f74
Contents?: true
Size: 708 Bytes
Versions: 3
Compression:
Stored size: 708 Bytes
Contents
require 'safe_yaml' class ConfigManager def initialize SafeYAML::OPTIONS[:default_mode] = :safe SafeYAML::OPTIONS[:deserialize_symbols] = true @conf_path = "#{Dir.home}/.gito.yml" @default_config = {"editor": "atom"} end def write_editor(new_editor) current_config = get current_config[:editor] = new_editor write(current_config) end def write(config) new_config = config.to_yaml File.open(@conf_path, 'w') { |file| file.write(new_config)} end def get if File.exists? (@conf_path) file = File.open(@conf_path, "rb") contents = file.read config = YAML.load(contents, :safe => true) else write @default_config config = @default_config end config end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gito-0.4.2 | lib/gito/config_manager.rb |
gito-0.4.1 | lib/gito/config_manager.rb |
gito-0.3.1 | lib/gito/config_manager.rb |