line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Router::Simple::Reversible; |
2
|
2
|
|
|
2
|
|
1678
|
use 5.008001; |
|
2
|
|
|
|
|
8
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
5
|
2
|
|
|
2
|
|
1005
|
use parent 'Router::Simple'; |
|
2
|
|
|
|
|
704
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub path_for { |
10
|
6
|
|
|
6
|
0
|
1127
|
my ($self, $dest, $args) = @_; |
11
|
|
|
|
|
|
|
|
12
|
6
|
|
50
|
|
|
18
|
$dest ||= {}; |
13
|
6
|
|
100
|
|
|
39
|
$args ||= {}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
ROUTE: |
16
|
6
|
|
|
|
|
10
|
foreach my $route (@{ $self->routes }) { |
|
6
|
|
|
|
|
23
|
|
17
|
16
|
|
|
|
|
69
|
foreach my $key (keys %$dest) { |
18
|
23
|
100
|
|
|
|
139
|
if ($route->dest->{$key} ne $dest->{$key}) { |
19
|
11
|
|
|
|
|
58
|
next ROUTE; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
5
|
|
|
|
|
26
|
my $splat_index = 0; |
24
|
5
|
|
|
|
|
11
|
my $path = $route->pattern; |
25
|
5
|
|
|
|
|
48
|
$path =~ s! |
26
|
|
|
|
|
|
|
\{((?:\{[0-9,]+\}|[^{}]+)+)\} | # /blog/{year:\d{4}} |
27
|
|
|
|
|
|
|
:([A-Za-z0-9_]+) | # /blog/:year |
28
|
|
|
|
|
|
|
(\*) | # /blog/*/* |
29
|
|
|
|
|
|
|
([^{:*]+) # normal string |
30
|
|
|
|
|
|
|
! |
31
|
15
|
100
|
|
|
|
59
|
if ($1) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
4
|
|
|
|
|
21
|
my ($name) = split /:/, $1, 2; |
33
|
4
|
100
|
|
|
|
21
|
defined $args->{$name} ? $args->{$name} : ''; |
34
|
|
|
|
|
|
|
} elsif ($2) { |
35
|
1
|
|
|
|
|
4
|
$args->{$2}; |
36
|
|
|
|
|
|
|
} elsif ($3) { |
37
|
2
|
|
|
|
|
9
|
$args->{splat}->[$splat_index++]; |
38
|
|
|
|
|
|
|
} else { |
39
|
8
|
|
|
|
|
34
|
$4; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
!gex; |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
32
|
return $path; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
19
|
return undef; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
__END__ |