Class: Tenderloin::Downloaders::File

Inherits:
Base
  • Object
show all
Defined in:
lib/tenderloin/downloaders/file.rb

Overview

“Downloads” a file to a temporary file. Basically, this downloader simply does a file copy.

Constant Summary collapse

BUFFERSIZE =

1 MB

1048576

Instance Method Summary collapse

Methods included from Util

#error_and_exit, included, #logger, #wrap_output

Instance Method Details

#download!(source_url, destination_file) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tenderloin/downloaders/file.rb', line 8

def download!(source_url, destination_file)
  # For now we read the contents of one into a buffer
  # and copy it into the other. In the future, we should do
  # a system-level file copy (FileUtils.cp).
  open(::File.expand_path(source_url)) do |f|
    loop do
      break if f.eof?
      destination_file.write(f.read(BUFFERSIZE))
    end
  end
end