Sha256: 190a1bdc921dc7243184e46f1448214af173b0ecaf2a2de2ec0d2e22ae362f1c
Contents?: true
Size: 744 Bytes
Versions: 16
Compression:
Stored size: 744 Bytes
Contents
require 'dply/helper' require 'fileutils' require 'tmpdir' module Dply class Curl include Helper def initialize(quiet = false) @quiet = quiet end def download(url, outfile) Dir.mktmpdir "tmp", "./" do |d| tmpfile = "#{d}/f" log "downloading #{url}" http_status = `curl -w "%{http_code}" -f -s -o '#{tmpfile}' '#{url}' ` exit_status = $?.exitstatus if (http_status != "200" || exit_status != 0) error "failed to download #{outfile}, http status #{http_status}, exit_status #{exit_status}" end FileUtils.mv tmpfile, outfile end end private def log(msg) @quiet ? logger.debug(msg) : logger.bullet(msg) end end end
Version data entries
16 entries across 16 versions & 1 rubygems