+ USERCONF_PATH = ENV['HOME'] + '/.whatever-dl.conf.yml'
+ @dict = {}
+
+ def initialize()
+ cfg = default_configuration()
+
+ # Now, load the user configuration which will override the
+ # variables defined above.
+ begin
+ user_config = YAML.load(File.open(USERCONF_PATH))
+
+ # We require ruby-1.9.x now so this should exist.
+ cfg.merge!(user_config)
+
+ 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]
+ end
+
+
+ private;
+
+ def default_configuration()
+ d = {}
+
+ d['download_method'] = 'openuri'
+ d['user_agent'] = 'whatever-dl'
+
+ return d
+ end
+