github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

mwlang / ruby-progressbar forked from nex3/ruby-progressbar

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 9
  • Source
  • Commits
  • Network (9)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Ruby/ProgressBar is a text progress bar library for Ruby. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

removed puts lines from sequel_output 
Michael Lang (author)
Wed Nov 11 12:33:23 -0800 2009
commit  be30d2083ff3acbc210eff78c51721b84ef9970d
tree    217551d094dda35fc93ce30de09fff661b03b4bc
parent  f8bd41a68d1ad0a58f0ae911ac78445c106207a4
ruby-progressbar /
name age
history
message
file GPL_LICENSE Mon Feb 16 13:44:29 -0800 2009 Add LICENSE files. [nex3]
file README.md Thu Nov 05 20:09:17 -0800 2009 added some documentation [Michael Lang]
file RUBY_LICENSE Mon Feb 16 13:44:29 -0800 2009 Add LICENSE files. [nex3]
directory lib/ Wed Nov 11 12:33:23 -0800 2009 removed puts lines from sequel_output [Michael Lang]
file ruby-progressbar-0.1.0.gem Wed Nov 11 12:33:23 -0800 2009 removed puts lines from sequel_output [Michael Lang]
file ruby-progressbar.gemspec Tue Nov 10 09:31:09 -0800 2009 added dbprogressbar to the gemspec [Michael Lang]
file test.rb Mon Jul 27 12:58:11 -0700 2009 accessor for alternate bar mark [daigoro]
file test_sequel.rb Thu Nov 05 19:58:49 -0800 2009 add dbprogressbar [Michael Lang]
README.md

Ruby/ProgressBar: A Text Progress Bar Library for Ruby

Ruby/ProgressBar is a text progress bar library for Ruby. It can indicate progress with percentage, a progress bar, and estimated remaining time.

Ruby/DbProgressBar is an extensions of the above ProgressBar to write output to the database instead of to the console. Implemented for Sequel ORM, but can be easily extended to other ORMs such as ActiveRecord or DataMapper

Examples

% irb --simple-prompt -r progressbar
>> pbar = ProgressBar.new("test", 100)
=> (ProgressBar: 0/100)
>> 100.times {sleep(0.1); pbar.inc}; pbar.finish
test:          100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:10
=> nil

>> pbar = ProgressBar.new("test", 100)
=> (ProgressBar: 0/100)
>> (1..100).each{|x| sleep(0.1); pbar.set(x)}; pbar.finish
test:           67% |oooooooooooooooooooooooooo              | ETA:  00:00:03


>> DB = Sequel.sqlite(File.join(ROOT_DIR, 'demo.db'))
>> SequelOutput.prepare_database(DB)
>> total = 15
>> pbar = DbProgressBar.new("job #1", total, SequelOutput.new(1, DB))
>> total.times do
>>   pbar.inc
>>   sleep(1)
>> end
>> pbar.finish

>> puts DB[:progress_bars].filter(:unique_id => 1).first[:progress_text]
job #1:       100% |oooooooooooooooooooooooooooooooooooooooo| Time: 00:00:15

API

  • ProgressBar#new(title, total, out = STDERR)

Display the initial progress bar and return a ProgressBar object. title specifies the title, and total specifies the total cost of processing. Optional parameter out specifies the output IO.

The display of the progress bar is updated when one or more percent is proceeded or one or more seconds are elapsed from the previous display.

  • ProgressBar#inc(step = 1)

Increase the internal counter by step and update the display of the progress bar. Display the estimated remaining time on the right side of the bar. The counter does not go beyond the total.

  • ProgressBar#set(count)

Set the internal counter to count and update the display of the progress bar. Display the estimated remaining time on the right side of the bar. Raise if count is a negative number or a number more than the total.

  • ProgressBar#finish

Stop the progress bar and update the display of progress bar. Display the elapsed time on the right side of the bar. The progress bar always stops at 100% by the method.

  • ProgressBar#halt

Stop the progress bar and update the display of progress bar. Display the elapsed time on the right side of the bar. The progress bar stops at the current percentage by the method.

  • ProgressBar#format=

Set the format for displaying a progress bar. Default: "%-14s %3d%% %s %s".

  • ProgressBar#format_arguments=

Set the methods for displaying a progress bar. Default: [:title, :percentage, :bar, :stat].

  • ProgressBar#file_transfer_mode

Use :stat_for_file_transfer instead of :stat to display transfered bytes and transfer rate.

ReverseProgressBar class is also available. The functionality is identical to ProgressBar but the direction of the progress bar is just opposite.

Limitations

Since the progress is calculated by the proportion to the total cost of processing, Ruby/ProgressBar cannot be used if the total cost of processing is unknown in advance. Moreover, the estimation of remaining time cannot be accurately performed if the progress does not flow uniformly.


Satoru Takabayashi

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server