class Configuration
USERCONF_PATH = ENV['HOME'] + '/.mailshears.conf.yml'
-
+ @dict = {}
+
def initialize()
- cfg = self.default_configuration()
+ cfg = default_configuration()
# Now, load the user configuration which will override the
# variables defined above.
begin
- user_config = Config.new(YAML.load(File.open(USERCONF_PATH)))
- cfg.update!(user_config)
- rescue LoadError
+ user_config = YAML.load(File.open(USERCONF_PATH))
+
+ # Write our own update() method for Ruby 1.8.
+ user_config.each do |key, value|
+ cfg[key] = value
+ end
+ rescue Errno::ENOENT
# If the user config file doesn't exist, whatever.
end
+ # Convert all of the keys to symbols.
+ cfg = cfg.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
+
@dict = cfg
end
-
+
def method_missing(sym, *args)
# Replace all missing method calls with dictionary lookups.
return @dict[sym]