0.01
No commit activity in last 3 years
No release in over 3 years
progressbar for enumerables
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.5
~> 1.3
>= 0
>= 0

Runtime

 Project Readme

with_progress Build Status Gem Version

Brings the great ruby-progressbar to Enumerable.

Usage

This gem adds the method Enumerable#with_progress.

Calling with_progress displays a progress bar while the iteration takes place.

It uses the ruby-progressbar gem and accepts the same options.

In Ruby 2.0+, most enumerables return a size, so with_progress uses that to deduce the total, there's no need to specify it:

42.times.with_progress { do_something }
# Will create the progress bar, provide the {total: 42} option
# (in Ruby 2.0+) and call increment after each do_something

For Ruby older than 2.0.0, some enumerators won't work, so progression will only show the elapsed time but won't be able to guess the remaining time. You can require some backports to improve the situation, for example:

require 'backports/2.0.0/range/size' (10...42).with_progress { do_something } # will calculate the remaining time, even in old Rubies

Installation

Add this line to your application's Gemfile:

gem 'with_progress'

And then execute:

$ bundle

Or install it yourself as:

$ gem install with_progress

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request