From: Sebastian Riedel Date: Fri, 4 Nov 2005 04:44:31 +0000 (+0000) Subject: Switched to Text::SimpleTable X-Git-Tag: 5.7099_04~1022 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=8c11318848e17f92027484614d393b6ebd365f7d;hp=fe958228637b4d263d563f64303d1511176ac545 Switched to Text::SimpleTable --- diff --git a/Build.PL b/Build.PL index bd21d73..5057499 100644 --- a/Build.PL +++ b/Build.PL @@ -25,7 +25,7 @@ my $build = Module::Build->new( 'Path::Class' => 0.09, 'Scalar::Util' => 0, 'Template' => 0, - 'Text::ASCIITable' => 0.17, + 'Text::SimpleTable' => 0, 'Test::MockObject' => 0, 'Time::HiRes' => 0, 'Tree::Simple' => 0, diff --git a/Changes b/Changes index 70036dc..49639e8 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Tis file documents the revision history for Perl extension Catalyst. +5.5 + - Switched to Text::SimpleTable + 5.49_03 2005-11-03 12:00:00 - Fixed $c->req->{path} for backwards-compatibility. - Allow debug to be disabled via ENV as well as enabled. diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 9b8f706..8470aba 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -11,7 +11,7 @@ use Catalyst::Request::Upload; use Catalyst::Response; use Catalyst::Utils; use NEXT; -use Text::ASCIITable; +use Text::SimpleTable; use Path::Class; use Time::HiRes qw/gettimeofday tv_interval/; use URI; @@ -348,12 +348,8 @@ sub setup { } if (@plugins) { - my $t = Text::ASCIITable->new; - $t->setOptions( 'hide_HeadRow', 1 ); - $t->setOptions( 'hide_HeadLine', 1 ); - $t->setCols('Class'); - $t->setColWidth( 'Class', 75, 1 ); - $t->addRow($_) for @plugins; + my $t = Text::SimpleTable->new(76); + $t->row($_) for @plugins; $class->log->debug( "Loaded plugins:\n" . $t->draw ); } @@ -384,14 +380,10 @@ sub setup { $class->setup_components; if ( $class->debug ) { - my $t = Text::ASCIITable->new; - $t->setOptions( 'hide_HeadRow', 1 ); - $t->setOptions( 'hide_HeadLine', 1 ); - $t->setCols('Class'); - $t->setColWidth( 'Class', 75, 1 ); - $t->addRow($_) for sort keys %{ $class->components }; + my $t = Text::SimpleTable->new(76); + $t->row($_) for sort keys %{ $class->components }; $class->log->debug( "Loaded components:\n" . $t->draw ) - if ( @{ $t->{tbl_rows} } ); + if ( keys %{ $class->components } ); } # Add our self to components, since we are also a component @@ -984,12 +976,9 @@ sub handle_request { $elapsed = sprintf '%f', $elapsed; my $av = sprintf '%.3f', ( $elapsed == 0 ? '??' : ( 1 / $elapsed ) ); - my $t = Text::ASCIITable->new; - $t->setCols( 'Action', 'Time' ); - $t->setColWidth( 'Action', 64, 1 ); - $t->setColWidth( 'Time', 9, 1 ); + my $t = Text::SimpleTable->new( [ 64, 'Action' ], [ 9, 'Time' ] ); - for my $stat (@stats) { $t->addRow( $stat->[0], $stat->[1] ) } + for my $stat (@stats) { $t->row( $stat->[0], $stat->[1] ) } $class->log->info( "Request took ${elapsed}s ($av/s)\n" . $t->draw ); } @@ -1107,15 +1096,11 @@ sub prepare_body { $c->prepare_uploads; if ( $c->debug && keys %{ $c->req->body_parameters } ) { - my $t = Text::ASCIITable->new; - $t->setCols( 'Key', 'Value' ); - $t->setColWidth( 'Key', 37, 1 ); - $t->setColWidth( 'Value', 36, 1 ); - $t->alignCol( 'Value', 'right' ); + my $t = Text::SimpleTable->new( [ 37, 'Key' ], [ 36, 'Value' ] ); for my $key ( sort keys %{ $c->req->body_parameters } ) { my $param = $c->req->body_parameters->{$key}; my $value = defined($param) ? $param : ''; - $t->addRow( $key, + $t->row( $key, ref $value eq 'ARRAY' ? ( join ', ', @$value ) : $value ); } $c->log->debug( "Body Parameters are:\n" . $t->draw ); @@ -1203,15 +1188,11 @@ sub prepare_query_parameters { $c->engine->prepare_query_parameters( $c, @_ ); if ( $c->debug && keys %{ $c->request->query_parameters } ) { - my $t = Text::ASCIITable->new; - $t->setCols( 'Key', 'Value' ); - $t->setColWidth( 'Key', 37, 1 ); - $t->setColWidth( 'Value', 36, 1 ); - $t->alignCol( 'Value', 'right' ); + my $t = Text::SimpleTable->new( [ 37, 'Key' ], [ 36, 'Value' ] ); for my $key ( sort keys %{ $c->req->query_parameters } ) { my $param = $c->req->query_parameters->{$key}; my $value = defined($param) ? $param : ''; - $t->addRow( $key, + $t->row( $key, ref $value eq 'ARRAY' ? ( join ', ', @$value ) : $value ); } $c->log->debug( "Query Parameters are:\n" . $t->draw ); @@ -1246,17 +1227,16 @@ sub prepare_uploads { $c->engine->prepare_uploads( $c, @_ ); if ( $c->debug && keys %{ $c->request->uploads } ) { - my $t = Text::ASCIITable->new; - $t->setCols( 'Key', 'Filename', 'Type', 'Size' ); - $t->setColWidth( 'Key', 12, 1 ); - $t->setColWidth( 'Filename', 28, 1 ); - $t->setColWidth( 'Type', 18, 1 ); - $t->setColWidth( 'Size', 9, 1 ); - $t->alignCol( 'Size', 'left' ); + my $t = Text::SimpleTable->new( + [ 12, 'Key' ], + [ 28, 'Filename' ], + [ 18, 'Type' ], + [ 9, 'Size' ] + ); for my $key ( sort keys %{ $c->request->uploads } ) { my $upload = $c->request->uploads->{$key}; for my $u ( ref $upload eq 'ARRAY' ? @{$upload} : ($upload) ) { - $t->addRow( $key, $u->filename, $u->type, $u->size ); + $t->row( $key, $u->filename, $u->type, $u->size ); } } $c->log->debug( "File Uploads are:\n" . $t->draw ); diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index e9ed811..31f37b3 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -2,7 +2,7 @@ package Catalyst::DispatchType::Path; use strict; use base qw/Catalyst::DispatchType/; -use Text::ASCIITable; +use Text::SimpleTable; =head1 NAME @@ -24,16 +24,13 @@ See L. sub list { my ( $self, $c ) = @_; - my $paths = Text::ASCIITable->new; - $paths->setCols( 'Path', 'Private' ); - $paths->setColWidth( 'Path', 36, 1 ); - $paths->setColWidth( 'Private', 37, 1 ); + my $paths = Text::SimpleTable->new( [ 36, 'Path' ], [ 37, 'Private' ] ); for my $path ( sort keys %{ $self->{paths} } ) { my $action = $self->{paths}->{$path}; - $paths->addRow( "/$path", "/$action" ); + $paths->row( "/$path", "/$action" ); } $c->log->debug( "Loaded Path actions:\n" . $paths->draw ) - if ( @{ $paths->{tbl_rows} } ); + if ( keys %{ $self->{paths} } ); } =item $self->match( $c, $path ) @@ -65,10 +62,7 @@ sub register { my @register; foreach my $r ( @{ $attrs->{Path} || [] } ) { - unless ( $r ) { - $r = $action->namespace; - } - elsif ( $r !~ m!^/! ) { # It's a relative path + unless ( $r =~ m!^/! ) { # It's a relative path $r = $action->namespace . "/$r"; } push( @register, $r ); diff --git a/lib/Catalyst/DispatchType/Regex.pm b/lib/Catalyst/DispatchType/Regex.pm index b906f69..313a5c3 100644 --- a/lib/Catalyst/DispatchType/Regex.pm +++ b/lib/Catalyst/DispatchType/Regex.pm @@ -2,7 +2,7 @@ package Catalyst::DispatchType::Regex; use strict; use base qw/Catalyst::DispatchType::Path/; -use Text::ASCIITable; +use Text::SimpleTable; =head1 NAME @@ -24,17 +24,14 @@ See L. sub list { my ( $self, $c ) = @_; - my $re = Text::ASCIITable->new; - $re->setCols( 'Regex', 'Private' ); - $re->setColWidth( 'Regex', 36, 1 ); - $re->setColWidth( 'Private', 37, 1 ); + my $re = Text::SimpleTable->new( [ 36, 'Regex' ], [ 37, 'Private' ] ); for my $regex ( @{ $self->{compiled} } ) { my $compiled = $regex->{re}; my $action = $regex->{action}; - $re->addRow( $compiled, "/$action" ); + $re->row( $compiled, "/$action" ); } $c->log->debug( "Loaded Regex actions:\n" . $re->draw ) - if ( @{ $re->{tbl_rows} } ); + if ( @{ $self->{compiled} } ); } =item $self->match( $c, $path ) @@ -71,8 +68,8 @@ sub register { my $attrs = $action->attributes; my @register = map { @{ $_ || [] } } @{$attrs}{ 'Regex', 'Regexp' }; foreach my $r (@register) { - unless ($r =~ /^\^/) { # Relative regex - $r = '^'.$action->namespace.'/'.$r; + unless ( $r =~ /^\^/ ) { # Relative regex + $r = '^' . $action->namespace . '/' . $r; } $self->{paths}{$r} = $action; # Register path for superclass push(