Class: ReplacerBot::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/replacer_bot/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
# File 'lib/replacer_bot/config.rb', line 5

def initialize
  reset!
end

Instance Method Details

#configObject



17
18
19
# File 'lib/replacer_bot/config.rb', line 17

def config
  @config
end

#reset!Object

testing a singleton is hard



9
10
11
12
13
14
15
# File 'lib/replacer_bot/config.rb', line 9

def reset! # testing a singleton is hard
  custom = fetch_yaml "#{ENV['HOME']}/.replacer_bot/config.yml"
  defaults = fetch_yaml (File.join(File.dirname(__FILE__), '..', '..', 'config/defaults.yml'))
  defaults.merge! custom

  @config = OpenStruct.new defaults
end