class Torba::RemoteSources::GetFile

File downloading abstraction @since 0.3.0

Public Class Methods

process(url) click to toggle source

@param url [String] to be downloaded. @return [Tempfile] temporarily stored content of the URL. @raise [Errors::ShellCommandFailed] if failed to fetch the URL

# 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