class ReplacerBot::Config

Public Class Methods

new() click to toggle source
# File lib/replacer_bot/config.rb, line 5
def initialize
  reset!
end

Public Instance Methods

config() click to toggle source
# File lib/replacer_bot/config.rb, line 17
def config
  @config
end
reset!() click to toggle source
# 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

Private Instance Methods

fetch_yaml(file) click to toggle source
# File lib/replacer_bot/config.rb, line 23
def fetch_yaml file
  begin
    YAML.load File.open file
  rescue
    {}
  end
end