Skip Menu |

This queue is for tickets about the Term-ProgressBar-Simple CPAN distribution.

Report information
The Basics
Id: 40038
Status: resolved
Priority: 0/
Queue: Term-ProgressBar-Simple

People
Owner: Nobody in particular
Requestors: leon [...] astray.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Adding +=
Thanks for an excellent module! Sometimes the list of things to do does not accurate reflect the amount of time per thing. For example, when crunching logfiles, it takes a different amount of time per log file with the size being a good guess. The attached patch makes += work for this exact case: my $total_size = sum map { -s } @filenames; my $progress = Term::ProgressBar::Simple->new($total_size); foreach my $filename (@filenames) { ... $progress += -s $filename; } Please consider patching your module, thanks! Leon
Subject: increment.diff
diff -r 601905e8e8d9 lib/Term/ProgressBar/Simple.pm --- a/lib/Term/ProgressBar/Simple.pm Tue Oct 14 14:43:00 2008 +0100 +++ b/lib/Term/ProgressBar/Simple.pm Tue Oct 14 14:51:57 2008 +0100 @@ -6,10 +6,11 @@ use Term::ProgressBar::Quiet; use Term::ProgressBar::Quiet; use overload # - '++' => \&increment; # + '++' => \&increment, # + '+=' => \&increment; # # '--' => \&decrement; # add later -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 NAME @@ -114,8 +115,9 @@ about checking to see if the display nee sub increment { my $self = shift; + my $increment = shift || 1; - $self->{count_so_far}++; + $self->{count_so_far} += $increment; my $now = $self->{count_so_far}; if ( $now >= $self->{next_update} ) { diff -r 601905e8e8d9 t/basic.pl --- a/t/basic.pl Tue Oct 14 14:43:00 2008 +0100 +++ b/t/basic.pl Tue Oct 14 14:51:57 2008 +0100 @@ -18,5 +18,15 @@ use Time::HiRes qw( sleep ); } +{ +use lib 'lib'; + my $progress = Term::ProgressBar::Simple->new(20_000); + + for ( 1 .. 10_000 ) { + $progress += 2; + } + +} + warn "progress destroyed"; ok 1;
Subject: Re: [rt.cpan.org #40038] Adding +=
Date: Tue, 14 Oct 2008 16:39:24 +0100
To: bug-Term-ProgressBar-Simple [...] rt.cpan.org
From: "Edmund von der Burg" <evdb [...] ecclestoad.co.uk>
2008/10/14 Leon Brocard via RT <bug-Term-ProgressBar-Simple@rt.cpan.org>: Show quoted text
> Sometimes the list of things to do does not accurate reflect the amount > of time per thing. For example, when crunching logfiles, it takes a > different amount of time per log file with the size being a good guess. > > Please consider patching your module, thanks! Leon
Lovely idea - shall patch it soon. Thanks for the contribution. Cheers, Edmund
added to version 0.02, which is heading out to a CPAN mirror near you now. Thanks for the patch Leon.