Sha256: 38879fb80dd325f8445d9a98c854e117bda1ab736da74ac05d078f080937da8c
Contents?: true
Size: 930 Bytes
Versions: 5
Compression:
Stored size: 930 Bytes
Contents
# encoding: utf-8 require "pathname" require "desi/local_install" require "desi/http_client" require "uri" module Desi class Downloader def initialize(opts = {}) @destination_dir = Pathname(opts.fetch(:destination_dir, Desi::LocalInstall.new)) @host = URI(opts.fetch(:host, 'http://cloud.github.com/')) @client = opts.fetch(:http_client_factory, Desi::HttpClient).new(@host) @verbose = opts[:verbose] end def download!(version, opts = {}) path = "/downloads/elasticsearch/elasticsearch/#{version.archive_name}" destination_name = @destination_dir.join File.basename(version.archive_name) raise "ERROR: File #{destination_name} already present!" if destination_name.exist? puts " * fetching release #{version} from #{@host + path}" if @verbose File.open(destination_name, 'w') {|f| f << @client.get(path).body } destination_name end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
desi-0.2.7 | lib/desi/downloader.rb |
desi-0.2.6 | lib/desi/downloader.rb |
desi-0.2.4 | lib/desi/downloader.rb |
desi-0.2.3 | lib/desi/downloader.rb |
desi-0.2.2 | lib/desi/downloader.rb |