« blib/lib/Catalyst/Plugin/Server/XMLRPC/DispatchType/XMLRPCPath.pm
↑ Summary
lib/Catalyst/Plugin/Server.pm »
| 1 | package Catalyst::Plugin::Server::XMLRPC::DispatchType::XMLRPCRegex; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base qw/Catalyst::DispatchType::Regex/; | ||
| 5 | use Text::SimpleTable; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Catalyst::Plugin::Server::XMLRPC::DispatchType::XMLRPCRegex - XMLRPCRegex DispatchType | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | See L<Catalyst>. | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | =head1 METHODS | ||
| 18 | |||
| 19 | =head2 $self->list($c) | ||
| 20 | |||
| 21 | Generates a nice debug-table containing the XMLRPCRegex methods. | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | sub list { | ||
| 26 | my ( $self, $c ) = @_; | ||
| 27 | my $re = Text::SimpleTable->new( [ 36, 'XMLRPCRegex' ], [ 37, 'Private' ] ); | ||
| 28 | for my $regex ( @{ $self->{_compiled} } ) { | ||
| 29 | my $action = $regex->{action}; | ||
| 30 | $re->row( $regex->{path}, "/$action" ); | ||
| 31 | } | ||
| 32 | $c->log->debug( "Loaded XMLRPCRegex actions:\n" . $re->draw ) | ||
| 33 | if ( @{ $self->{_compiled} } ); | ||
| 34 | } | ||
| 35 | |||
| 36 | =head2 $self->register( $c, $action ) | ||
| 37 | |||
| 38 | Registers the XMLRPCPath actions into the dispatcher | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | sub register { | ||
| 43 | my ( $self, $c, $action ) = @_; | ||
| 44 | my $attrs = $action->attributes; | ||
| 45 | my @register = map { @{ $_ || [] } } @{$attrs}{ | ||
| 46 | 'XMLRPCRegex', | ||
| 47 | 'XMLRPCRegexp' | ||
| 48 | }; | ||
| 49 | foreach | ||
| 50 | my $r ( map { @{ $_ || [] } } @{$attrs}{ | ||
| 51 | 'XMLRPCLocalRegex', | ||
| 52 | 'XMLRPCLocalRegexp' | ||
| 53 | } | ||
| 54 | ) | ||
| 55 | { | ||
| 56 | unless ( $r =~ s/^\^// ) { $r = "(?:.*?)$r"; } | ||
| 57 | push( @register, '^' . $action->namespace . '/' . $r ); | ||
| 58 | } | ||
| 59 | |||
| 60 | foreach my $r (@register) { | ||
| 61 | $self->register_path( $c, $r, $action ); | ||
| 62 | $self->register_regex( $c, $r, $action ); | ||
| 63 | } | ||
| 64 | return 1 if @register; | ||
| 65 | return 0; | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | =head1 AUTHOR | ||
| 71 | |||
| 72 | Michiel Ootjers C<michiel@cpan.org> | ||
| 73 | Jos Boumans, C<kane@cpan.org> | ||
| 74 | |||
| 75 | =head1 COPYRIGHT | ||
| 76 | |||
| 77 | This program is free software, you can redistribute it and/or modify it under | ||
| 78 | the same terms as Perl itself. | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | 1; |