Sha256: df75ddb92ead4ff9596aea03996354a7cad427bf385dc2dd125d050aec02b91d

Contents?: true

Size: 595 Bytes

Versions: 4

Compression:

Stored size: 595 Bytes

Contents

# encoding: utf-8

require 'fileutils'
require_relative '../config/config'

module Jetel
  module Downloaders
    class BaseDownloader
      DATA_DIRECTORY = Config[:DATA_DIRECTORY]

      OPTS_DOWNLOAD = {
        :dir => DATA_DIRECTORY,
        :timeout => 600
      }

      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jetel-0.0.15 lib/jetel/downloaders/base_downloader.rb
jetel-0.0.14 lib/jetel/downloaders/base_downloader.rb
jetel-0.0.12 lib/jetel/downloaders/base_downloader.rb
jetel-0.0.11 lib/jetel/downloaders/base_downloader.rb