X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FRegex.pm;h=1ffa932da1d4887a2d8c806ed64627d8134eb917;hb=4fbc0e853c0b29d1f6082909b0cb54595ea32787;hp=af9a11a17a05e7927409f744e6f112954fe039f8;hpb=3c0186f29e8864c86aca75f03f8d8ac1afd5507d;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/DispatchType/Regex.pm b/lib/Catalyst/DispatchType/Regex.pm index af9a11a..1ffa932 100644 --- a/lib/Catalyst/DispatchType/Regex.pm +++ b/lib/Catalyst/DispatchType/Regex.pm @@ -2,10 +2,19 @@ package Catalyst::DispatchType::Regex; use Moose; extends 'Catalyst::DispatchType::Path'; + use Text::SimpleTable; +use Catalyst::Utils; use Text::Balanced (); -has _compiled => (is => 'rw', isa => 'ArrayRef', required => 1, default => sub{[]}); +has _compiled => ( + is => 'rw', + isa => 'ArrayRef', + required => 1, + default => sub{ [] }, + ); + +no Moose; =head1 NAME @@ -27,14 +36,14 @@ Output a table of all regex actions, and their private equivalent. sub list { my ( $self, $c ) = @_; - my @regexes = @{ $self->_compiled }; - return unless @regexes; - my $re = Text::SimpleTable->new( [ 35, 'Regex' ], [ 36, 'Private' ] ); - for my $regex ( @regexes ) { + my $column_width = Catalyst::Utils::term_width() - 35 - 9; + my $re = Text::SimpleTable->new( [ 35, 'Regex' ], [ $column_width, 'Private' ] ); + for my $regex ( @{ $self->_compiled } ) { my $action = $regex->{action}; $re->row( $regex->{path}, "/$action" ); } - $c->log->debug( "Loaded Regex actions:\n" . $re->draw . "\n" ); + $c->log->debug( "Loaded Regex actions:\n" . $re->draw . "\n" ) + if ( @{ $self->_compiled } ); } =head2 $self->match( $c, $path ) @@ -46,10 +55,10 @@ altering $c. =cut -override match => sub { +sub match { my ( $self, $c, $path ) = @_; - return if super(); + return if $self->SUPER::match( $c, $path ); # Check path against plain text first @@ -142,10 +151,9 @@ sub uri_for_action { return undef; } -=head1 AUTHOR +=head1 AUTHORS -Matt S Trout -Sebastian Riedel, C +Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT @@ -154,4 +162,6 @@ the same terms as Perl itself. =cut +__PACKAGE__->meta->make_immutable; + 1;