X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FChained.pm;h=71a8fd3e979f22ee5736aa7e95051d6cddd73d20;hp=a7d08a35680bf9254dcdc13a31ce6a0b6e5be386;hb=39fc2ce1e456c4e2a272204aa8fe67896984b3a6;hpb=52f71256fa6baba38de781b3074884ff0d12769f diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index a7d08a3..71a8fd3 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -5,6 +5,7 @@ extends 'Catalyst::DispatchType'; use Text::SimpleTable; use Catalyst::ActionChain; +use Catalyst::Utils; use URI; has _endpoints => ( @@ -67,9 +68,15 @@ sub list { return unless $self->_endpoints; + my $column_width = Catalyst::Utils::term_width() - 35 - 9; my $paths = Text::SimpleTable->new( - [ 35, 'Path Spec' ], [ 36, 'Private' ] - ); + [ 35, 'Path Spec' ], [ 36, 'Private' ], [ $column_width, 'Private' ] + ); + + my $has_unattached_actions; + my $unattached_actions = Text::SimpleTable->new( + [ 35, 'Private' ], [ 36, 'Missing parent' ], + ); ENDPOINT: foreach my $endpoint ( sort { $a->reverse cmp $b->reverse } @@ -92,7 +99,11 @@ sub list { $curr = $self->_actions->{$parent}; unshift(@parents, $curr) if $curr; } - next ENDPOINT unless $parent eq '/'; # skip dangling action + if ($parent ne '/') { + $has_unattached_actions = 1; + $unattached_actions->row('/'.$parents[0]->reverse, $parent); + next ENDPOINT; + } my @rows; foreach my $p (@parents) { my $name = "/${p}"; @@ -110,6 +121,8 @@ sub list { } $c->log->debug( "Loaded Chained actions:\n" . $paths->draw . "\n" ); + $c->log->debug( "Unattached Chained actions:\n", $unattached_actions->draw . "\n" ) + if $has_unattached_actions; } =head2 $self->match( $c, $path ) @@ -319,6 +332,14 @@ sub uri_for_action { } +=head2 $c->expand_action($action) + +Return a list of actions that represents a chained action. See +L for more info. You probably want to +use the expand_action it provides rather than this directly. + +=cut + sub expand_action { my ($self, $action) = @_;