Class: Dply::Curl
Instance Method Summary collapse
- #download(url, outfile) ⇒ Object
-
#initialize(quiet = false) ⇒ Curl
constructor
A new instance of Curl.
Methods included from Helper
#cmd, #error, #git, #logger, #sh, #symlink
Constructor Details
#initialize(quiet = false) ⇒ Curl
Returns a new instance of Curl.
10 11 12 |
# File 'lib/dply/curl.rb', line 10 def initialize(quiet = false) @quiet = quiet end |
Instance Method Details
#download(url, outfile) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dply/curl.rb', line 14 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 |