Class: Jetel::Downloaders::BaseDownloader

Inherits:
Object
  • Object
show all
Defined in:
lib/jetel/downloaders/base_downloader.rb

Direct Known Subclasses

Aria, Curl, Ruby, Wget

Constant Summary collapse

DATA_DIRECTORY =
Config[:DATA_DIRECTORY]
OPTS_DOWNLOAD =
{
  :dir => DATA_DIRECTORY,
  :timeout => 600
}

Instance Method Summary collapse

Instance Method Details

#download(url, opts = OPTS_DOWNLOAD) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/jetel/downloaders/base_downloader.rb', line 36

def download(url, opts = OPTS_DOWNLOAD)
  opts = OPTS_DOWNLOAD.merge(opts)

  dir = opts[:dir]

  fail 'Dir can not be nil or empty!' if dir.nil? || dir.empty?
  unless Dir.exist?(dir)
    FileUtils.mkdir_p(dir)
  end

  puts "Downloading #{url}"
end