module Gtin2atc::DownloadMethod
Private Instance Methods
download_as(file, option='r')
click to toggle source
# File lib/gtin2atc/downloader.rb, line 10 def download_as(file, option='r') tempFile = File.join(WorkDir, File.basename(file)) file2save = File.join(Util.get_archive, File.basename(file)) Gtin2atc.log "download_as file #{file2save} via #{tempFile} from #{@url}" data = nil FileUtils.rm_f(tempFile, :verbose => false) if Gtin2atc.skip_download(file) io = File.open(file, option) data = io.read else begin response = @agent.get(@url) response.save_as(file) response = nil # win io = File.open(file, option) data = io.read rescue Timeout::Error, Errno::ETIMEDOUT retrievable? ? retry : raise ensure io.close if io and !io.closed? # win Gtin2atc.download_finished(tempFile) end end return data end