]>
gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - lib/whatever-dl/configuration.rb
6 # We support a couple of different download methods. The 'openuri'
7 # method utilizes the ruby open-uri library, and provides its own
8 # progress bar with no external dependencies. The 'wget' method, on the
9 # other hand, requires GNU Wget (http://www.gnu.org/software/wget/),
10 # but will support auto-resume of partially-downloaded files for
13 USERCONF_PATH
= ENV['HOME'] +
'/.whatever-dl.conf.yml'
17 cfg
= default_configuration()
19 # Now, load the user configuration which will override the
20 # variables defined above.
22 user_config
= YAML
.load(File
.open(USERCONF_PATH
))
24 # We require ruby-1.9.x now so this should exist.
25 cfg
.merge!
(user_config
)
28 # If the user config file doesn't exist, whatever.
31 # Convert all of the keys to symbols.
32 cfg
= cfg
.inject({}){|memo
,(k
,v
)| memo
[k
.to_sym
] = v
; memo
}
37 def method_missing(sym
, *args
)
38 # Replace all missing method calls with dictionary lookups.
45 def default_configuration()
48 d
['download_method'] = 'openuri'
49 d
['user_agent'] = 'whatever-dl'