end
# Warn about nonsensical options.
-if options[:continue] and not Configuration::DOWNLOAD_METHOD == :wget
- log.warn('The --continue flag does nothing unless DOWNLOAD_METHOD is :wget.')
+if options[:continue] and not cfg.download_method == 'wget'
+ log.warn("The --continue flag does nothing unless download_method is wget.")
end
# Note that GetoptLong steals its arguments from ARGV, so we don't need
Kernel.exit(ExitCodes::EXIT_NO_URL)
end
+
+cfg = Configuration.new()
+
# Factory method.
site = Website.create(ARGV[0])
# The Downloader class is a factory; it should decide
# which subclass we get.
-downloader = Downloader.create(Configuration::DOWNLOAD_METHOD)
+puts "download_method: #{cfg.download_method}"
+downloader = Downloader.create(cfg.download_method)
# Attempt to download the file, and rescue and report
# any (predictable) exceptions. The wget downloader will
class Configuration
# Configurable Options
#
- # We support a couple of different download methods. The :openuri
+ # We support a couple of different download methods. The 'openuri'
# method utilizes the ruby open-uri library, and provides its own
- # progress bar with no external dependencies. The :wget method, on the
+ # progress bar with no external dependencies. The 'wget' method, on the
# other hand, requires GNU Wget (http://www.gnu.org/software/wget/),
# but will support auto-resume of partially-downloaded files for
# example.
def self.create(download_method)
# Return the subclass corresponding to download_method.
case download_method
- when :openuri
+ when 'openuri'
return OpenUriDownloader.new()
- when :wget
+ when 'wget'
return WgetDownloader.new()
end
end