Progress Download

Simple customisable progress bar for downloading remote files in Ruby.

Installation

In your shell:

gem install progress_download

or, form source

git clone https://github.com/Demonstrandum/progress_download.git
cd progress_download/

Then install it:

gem build progress_download.gemspec
gem install progress_download-*

or use it directly:

ruby -Ilib bin/* [OPTIONS] ... [URL]
# or just copy the lib direcotry to where you need it

Usage

You may test it out in your terminal by doing:

progress-download [STYLE] [URI]
# For example
progress-download --style pump http://ipv4.download.thinkbroadband.com/10MB.zip

Output should look something like:

‘10MB.zip’ — 8.44 / 10.0 MiB at 1.76 MiB/s in 4.78s
⠴ [ █████████████████████████████████████████████▒▒▒▒▒▒▒▒▒ ]  84%
# ...
‘10MB.zip’ — 10.00 / 10.0 MiB at 1.85 MiB/s in 5.41s
⠶ [ ██████████████████████████████████████████████████████ ] 100%

where the bar fills the entier width of the terminal

In Ruby

# Basic usage
url = 'http://ipv4.download.thinkbroadband.com/10MB.zip'
ProgressBar.download url
# More advanced options include:
ProgressBar.download url, :location => '~/Downloads', :style => :classic, :speed => 0.1, :refresh => 0.5

By default:

  • :location is the current working directory (Dir.getwd)
  • :style is :dots
  • :speed is 1 and
  • :refresh is 0.125

:refresh is the amount of time between each 'frame' in seconds, by this, :speed is how many times the spinner updates per frame drawn, meaning thusly that :speed must be 1 or less, 1 meaning that the spinner advances one step for every 'frame' drawn, and 0.5 would be every second frame, etc.