Class: SolrWrapper::Downloader
- Inherits:
-
Object
- Object
- SolrWrapper::Downloader
- Defined in:
- lib/solr_wrapper/downloader.rb
Defined Under Namespace
Classes: SafeProgressBar
Class Method Summary collapse
Class Method Details
.fetch_with_progressbar(url, output) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/solr_wrapper/downloader.rb', line 6 def self.(url, output) = SafeProgressBar.new(title: File.basename(url), total: nil, format: '%t: |%B| %p%% (%e )') response = HTTP.follow.get(url) .total = response.headers['content-length'].to_i File.open(output, 'w') do |f| response.body.each do |chunk| f.write(chunk) .progress += chunk.length end nil end rescue HTTP::Error => e raise SolrWrapperError, "Unable to download solr from #{url}\n#{e}" end |