Class: AutomateIt::DownloadManager::OpenURI
- Inherits:
-
BaseDriver
- Object
- Common
- Plugin::Base
- Plugin::Driver
- BaseDriver
- AutomateIt::DownloadManager::OpenURI
- Defined in:
- lib/automateit/download_manager.rb
Overview
DownloadManager::OpenURI
A DownloadManager driver using the OpenURI module for handling HTTP and FTP transfers.
Constant Summary
Constants inherited from Plugin::Driver
Plugin::Driver::BASE_DRIVER_NAME
Constants included from Constants
Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary
Attributes inherited from Plugin::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#download(*arguments) ⇒ Object
See DownloadManager#download.
-
#suitability(method, *args) ⇒ Object
:nodoc:.
Methods inherited from Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token, #setup
Methods inherited from Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Method Details
#download(*arguments) ⇒ Object
See DownloadManager#download
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/automateit/download_manager.rb', line 31 def download(*arguments) args, opts = args_and_opts(*arguments) source = args[0] or raise ArgumentError.new("No source specified") target = args[1] || opts[:to] || File.basename(source) target = File.join(target, File.basename(source)) if File.directory?(target) log.info(PNOTE+"Downloading #{target}") if writing? open(target, "w+") do |writer| open(source) do |reader| writer.write(reader.read) end end end return writing? end |
#suitability(method, *args) ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/automateit/download_manager.rb', line 26 def suitability(method, *args) # :nodoc: return available? ? 1 : 0 end |