File Coverage

blib/lib/Catalyst/Controller/VersionedURI.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Catalyst::Controller::VersionedURI;
2             our $AUTHORITY = 'cpan:YANICK';
3             # ABSTRACT: Revert Catalyst::Plugin::VersionedURI's munging
4             $Catalyst::Controller::VersionedURI::VERSION = '1.1.2';
5              
6 1     1   300868 use strict;
  1         2  
  1         25  
7 1     1   6 use warnings;
  1         2  
  1         25  
8              
9 1     1   5 use Moose;
  1         2  
  1         9  
10              
11 1     1   7606 use Catalyst::DispatchType::Regex;
  1         55771  
  1         66  
12              
13 1     1   6 BEGIN { extends 'Catalyst::Controller' }
14              
15             after BUILDALL => sub {
16             my $self = shift;
17             my $app = $self->_app;
18              
19             my $regex = $app->versioned_uri_regex;
20              
21             # we catch the old versions too
22 1     1 0 11 eval <<"END";
  1     2   2  
  1         6  
  2         69609  
  2         7  
  2         183  
  2         96  
23             sub versioned :Regex('(${regex})v') {
24             my ( \$self, \$c ) = \@_;
25              
26             my \$uri = \$c->req->uri;
27              
28             \$uri =~ s#(${regex})v.*?/#\$1#;
29              
30             \$c->res->redirect( \$uri );
31              
32             }
33             END
34              
35             };
36              
37             1;
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             Catalyst::Controller::VersionedURI - Revert Catalyst::Plugin::VersionedURI's munging
48              
49             =head1 VERSION
50              
51             version 1.1.2
52              
53             =head1 SYNOPSIS
54              
55             package MyApp::Controller::VersionedURI;
56              
57             use parent 'Catalyst::Controller::VersionedURI';
58              
59             1;
60              
61             =head1 DESCRIPTION
62              
63             This controller creates actions to catch the
64             versioned uris created by C<Catalyst::Plugin::VersionedURI>
65             with the I<in_path> parameter set to I<true>.
66              
67             =head1 SEE ALSO
68              
69             L<Catalyst::Plugin::VersionedURI>
70              
71             =head1 AUTHOR
72              
73             Yanick Champoux <yanick@babyl.dyndns.org>
74              
75             =head1 COPYRIGHT AND LICENSE
76              
77             This software is copyright (c) 2011 by Yanick Champoux.
78              
79             This is free software; you can redistribute it and/or modify it under
80             the same terms as the Perl 5 programming language system itself.
81              
82             =cut