Class: Torba::RemoteSources::GetFile

Inherits:
Object
  • Object
show all
Defined in:
lib/torba/remote_sources/get_file.rb

Overview

File downloading abstraction

Since:

  • 0.3.0

Class Method Summary collapse

Class Method Details

.process(url) ⇒ Tempfile

Returns temporarily stored content of the URL.

Parameters:

  • url (String)

    to be downloaded.

Returns:

  • (Tempfile)

    temporarily stored content of the URL.

Raises:

Since:

  • 0.3.0



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/torba/remote_sources/get_file.rb', line 11

def self.process(url)
  tempfile = Tempfile.new("torba")
  tempfile.close

  Torba.ui.info "downloading '#{url}'"

  command = "curl --retry 5 --retry-max-time 60 -Lf -o #{tempfile.path} #{url}"
  system(command) || raise(Errors::ShellCommandFailed.new(command))

  tempfile
end