Sha256: 5140b718559b5b3bc29751ca683b5c9b5bb09e12abf645536604d4bdeb54bd01
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
# == DownloadManager # # The DownloadManager provides a way of downloading files. module AutomateIt class DownloadManager < Plugin::Manager alias_methods :download # Downloads the +source+ document. # # Options: # * :to -- Saves source to this filename or directory. Defaults to current directory. def download(source, opts={}) dispatch(source, opts) end # == DownloadManager::BaseDriver # # Base class for all DownloadManager drivers. class BaseDriver < Plugin::Driver end # == DownloadManager::OpenURI # # A DownloadManager driver using the OpenURI module for handling HTTP and FTP transfers. class OpenURI < BaseDriver depends_on :libraries => %w(open-uri) def suitability(method, *args) # :nodoc: return available? ? 1 : 0 end # See DownloadManager#download def download(source, opts={}) target = 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
automateit-0.70928 | lib/automateit/download_manager.rb |
automateit-0.70930 | lib/automateit/download_manager.rb |
automateit-0.71003 | lib/automateit/download_manager.rb |