Fixed public action lists
Sebastian Riedel [Sat, 22 Oct 2005 08:57:24 +0000 (08:57 +0000)]
lib/Catalyst/DispatchType.pm
lib/Catalyst/DispatchType/Path.pm
lib/Catalyst/DispatchType/Regex.pm
lib/Catalyst/Dispatcher.pm

index f8df391..dc12b57 100644 (file)
@@ -17,6 +17,12 @@ See L<Catalyst>.
 
 =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
 
index 454f87c..bec5b1c 100644 (file)
@@ -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<Catalyst>.
 
 =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
index c373d2f..975aebb 100644 (file)
@@ -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<Catalyst>.
 
 =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
index 96793fa..7bad0f6 100644 (file)
@@ -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