From 37a7b741692997d8cf7ecc371dc5c829a388067d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 28 Feb 2011 18:47:35 +0100 Subject: Move CLI code from App::Dthumb to bin/dthumb --- lib/App/Dthumb.pm | 65 ++++--------------------------------------------------- 1 file changed, 4 insertions(+), 61 deletions(-) (limited to 'lib') diff --git a/lib/App/Dthumb.pm b/lib/App/Dthumb.pm index f2cf875..bb5a4ce 100755 --- a/lib/App/Dthumb.pm +++ b/lib/App/Dthumb.pm @@ -45,14 +45,10 @@ use base 'Exporter'; use App::Dthumb::Data; use Cwd; use Image::Imlib2; -use IO::Handle; -use Time::Progress; our @EXPORT_OK = (); our $VERSION = '0.1'; -STDERR->autoflush(1); - =head1 METHODS @@ -127,7 +123,6 @@ sub new { $ref->{config} = $conf; $ref->{data} = App::Dthumb::Data->new(); - $ref->{timer} = Time::Progress->new(); $ref->{html} = $ref->{data}->get('html_start'); @@ -140,26 +135,6 @@ sub new { return bless($ref, $obj); } - -=head2 run - -Run dthumb. Read all files, create thumbnails, write index.xhtml, and so on. - -=cut - - -sub run { - my ($self) = @_; - - $self->check_cmd_flags(); - $self->read_directories(); - $self->create_files(); - $self->delete_old_thumbnails(); - $self->create_thumbnails(); - $self->write_out_html(); -} - - =head1 INTERNALS The following methods are internal only and do not need to be called by @@ -226,11 +201,6 @@ sub read_directories { @{$self->{files}} = sort { lc($a) cmp lc($b) } @files; @{$self->{old_thumbnails}} = @old_thumbs; - - $self->{timer}->attr( - min => 1, - max => scalar @files, - ); } @@ -288,28 +258,17 @@ sub delete_old_thumbnails { } -=head2 create_thumbnails +=head2 get_files -Iterate over all files in $self->{files}, print a progress bar to STDERR and -call B and B for each. +Returns an array of all image files found by B. =cut -sub create_thumbnails { +sub get_files { my ($self) = @_; - for my $file (@{$self->{files}}) { - - print STDERR $self->{timer}->report( - "\r\e[KCreating Thumbnails: %p done, %L elapsed, %E remaining", - ++$self->{current_file_id}, - ); - - $self->create_thumbnail_html($file); - $self->create_thumbnail_image($file); - } - print "\n"; + return @{$self->{files}}; } @@ -404,22 +363,6 @@ sub write_out_html { close($fh); } -#sub print_progress { -# my ($self) = @_; -# my $num = $self->{current_file_id}; -# my $name = $self->{current_file_name}; -# -# if (($num % 60) == 0) { -# if ($number) { -# printf(" %4d/%d\n", $number, scalar(@files)); -# } -# printf('[%3d%%] ', $number * 100 / @files); -# } elsif (($number % 10) == 0) { -# print ' '; -# } -# return; -#} - 1; __END__ -- cgit v1.2.3