Module: Twtr::Config
- Defined in:
- lib/twtr/config.rb
Class Method Summary collapse
Class Method Details
.load(config_file) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/twtr/config.rb', line 10 def self.load(config_file) if File.exist?(config_file) config = YAML::load(ERB.new(IO.read(config_file)).result) else raise Twtr::ConfigFileNotFoundException.new("#{config_file} not found!") end end |
.save(config_file, config = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/twtr/config.rb', line 18 def self.save(config_file, config = {}) FileUtils.mkdir_p(File.dirname(config_file)) store = YAML::Store.new(config_file) store.transaction do |yaml| %W(account proxy).each do |name| yaml.delete(name) if yaml[name] yaml[name] = config[name] if config[name] end end end |