class Scatter::Config
Constants
- CONFIG_FILE
- DEFAULTS
Public Class Methods
get(key=nil)
click to toggle source
# File lib/scatter/config.rb, line 18 def self.get(key=nil) config = self.parse key ? config[key] : config end
parse()
click to toggle source
# File lib/scatter/config.rb, line 8 def self.parse return DEFAULTS unless File.exists? CONFIG_FILE begin return DEFAULTS.merge YAML.load(File.read CONFIG_FILE) rescue abort "There was a problem parsing #{CONFIG_FILE}, it should be valid YAML" end end
save(options)
click to toggle source
# File lib/scatter/config.rb, line 23 def self.save(options) File.open(CONFIG_FILE, 'w') do |f| f.write options.to_yaml end end
set(key, value)
click to toggle source
# File lib/scatter/config.rb, line 29 def self.set(key, value) config = get config[key] = value save config end
show(key=nil)
click to toggle source
# File lib/scatter/config.rb, line 35 def self.show(key=nil) if key value = get[key] else value = get end value.to_yaml end