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
5 6 7 8 9 10 11 12 |
# File 'lib/solr_wrapper/downloader.rb', line 5 def self.(url, output) = SafeProgressBar.new(title: File.basename(url), total: nil, format: '%t: |%B| %p%% (%e )') open(url, content_length_proc: ->(bytes) { .total = bytes }, progress_proc: ->(bytes) { .progress = bytes }) do |io| IO.copy_stream(io, output) end rescue OpenURI::HTTPError => e raise SolrWrapperError, "Unable to download solr from #{url}\n#{e.}: #{e.io.read}" end |