From: Sebastian Riedel Date: Sat, 22 Oct 2005 08:57:24 +0000 (+0000) Subject: Fixed public action lists X-Git-Tag: 5.7099_04~1136 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=a9cbd748a5bef5badba4a3f012e5df75cccd60ca Fixed public action lists --- diff --git a/lib/Catalyst/DispatchType.pm b/lib/Catalyst/DispatchType.pm index f8df391..dc12b57 100644 --- a/lib/Catalyst/DispatchType.pm +++ b/lib/Catalyst/DispatchType.pm @@ -17,6 +17,12 @@ See L. =over 4 +=item $self->list($c) + +=cut + +sub list { } + =item $self->match( $c, $path ) =cut @@ -27,7 +33,7 @@ sub match { die "Abstract method!" } =cut -sub register { return } +sub register { } =back diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 454f87c..bec5b1c 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -2,6 +2,7 @@ package Catalyst::DispatchType::Path; use strict; use base qw/Catalyst::DispatchType/; +use Text::ASCIITable; =head1 NAME @@ -17,6 +18,24 @@ See L. =over 4 +=item $self->list($c) + +=cut + +sub list { + my ( $self, $c ) = @_; + my $paths = Text::ASCIITable->new; + $paths->setCols( 'Public', 'Private' ); + $paths->setColWidth( 'Public', 36, 1 ); + $paths->setColWidth( 'Private', 37, 1 ); + for my $path ( sort keys %{ $self->{paths} } ) { + my $action = $self->{paths}->{$path}; + $paths->addRow( "/$path", "/$action" ); + } + $c->log->debug( "Loaded Path actions:\n" . $paths->draw ) + if ( @{ $paths->{tbl_rows} } ); +} + =item $self->match( $c, $path ) =cut diff --git a/lib/Catalyst/DispatchType/Regex.pm b/lib/Catalyst/DispatchType/Regex.pm index c373d2f..975aebb 100644 --- a/lib/Catalyst/DispatchType/Regex.pm +++ b/lib/Catalyst/DispatchType/Regex.pm @@ -2,6 +2,7 @@ package Catalyst::DispatchType::Regex; use strict; use base qw/Catalyst::DispatchType::Path/; +use Text::ASCIITable; =head1 NAME @@ -17,6 +18,25 @@ See L. =over 4 +=item $self->list($c) + +=cut + +sub list { + my ( $self, $c ) = @_; + my $re = Text::ASCIITable->new; + $re->setCols( 'Regex', 'Private' ); + $re->setColWidth( 'Regex', 36, 1 ); + $re->setColWidth( 'Private', 37, 1 ); + for my $regex ( @{ $self->{compiled} } ) { + my $compiled = $regex->{re}; + my $action = $regex->{action}; + $re->addRow( $compiled, "/$action" ); + } + $c->log->debug( "Loaded Regex actions:\n" . $re->draw ) + if ( @{ $re->{tbl_rows} } ); +} + =item $self->match( $c, $path ) =cut diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 96793fa..7bad0f6 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -474,34 +474,11 @@ sub setup_actions { }; $walker->( $walker, $self->tree, '' ); - $class->log->debug( "Loaded private actions:\n" . $privates->draw ) + $class->log->debug( "Loaded Private actions:\n" . $privates->draw ) if ( @{ $privates->{tbl_rows} } ); - my $publics = Text::ASCIITable->new; - $publics->setCols( 'Public', 'Private' ); - $publics->setColWidth( 'Public', 36, 1 ); - $publics->setColWidth( 'Private', 37, 1 ); - - for my $plain ( sort keys %{ $actions->{plain} } ) { - my $action = $actions->{plain}->{$plain}; - $publics->addRow( "/$plain", "/$action" ); - } - - $class->log->debug( "Loaded public actions:\n" . $publics->draw ) - if ( @{ $publics->{tbl_rows} } ); - - my $regexes = Text::ASCIITable->new; - $regexes->setCols( 'Regex', 'Private' ); - $regexes->setColWidth( 'Regex', 36, 1 ); - $regexes->setColWidth( 'Private', 37, 1 ); - - for my $regex ( sort keys %{ $actions->{regex} } ) { - my $action = $actions->{regex}->{$regex}; - $regexes->addRow( $regex, "/$action" ); - } - - $class->log->debug( "Loaded regex actions:\n" . $regexes->draw ) - if ( @{ $regexes->{tbl_rows} } ); + # List all public actions + $_->list($class) for @{ $self->dispatch_types }; } =back