class FcrepoWrapper::Downloader

Public Class Methods

fetch_with_progressbar(url, output) click to toggle source
# File lib/fcrepo_wrapper/downloader.rb, line 5
def self.fetch_with_progressbar(url, output)
  pbar = SafeProgressBar.new(title: File.basename(url), total: nil, format: '%t: |%B| %p%% (%e )')
  open(url,
       content_length_proc: ->(bytes) { pbar.total = bytes },
       progress_proc: ->(bytes) { pbar.progress = bytes }) do |io|
    IO.copy_stream(io, output)
  end
end