line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Path::AttrRouter::DispatchType::Regex; |
2
|
7
|
|
|
7
|
|
4427
|
use Mouse; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
39
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
extends 'Path::AttrRouter::DispatchType::Path'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has '+name' => ( |
7
|
|
|
|
|
|
|
default => 'Regex', |
8
|
|
|
|
|
|
|
); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has compiled => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => 'ArrayRef', |
13
|
|
|
|
|
|
|
lazy => 1, |
14
|
|
|
|
|
|
|
default => sub { [] }, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
7
|
|
|
7
|
|
2344
|
no Mouse; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
85
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub match { |
20
|
72
|
|
|
72
|
0
|
106
|
my ($self, $condition) = @_; |
21
|
|
|
|
|
|
|
|
22
|
72
|
|
|
|
|
77
|
for my $compiled (@{ $self->compiled }) { |
|
72
|
|
|
|
|
305
|
|
23
|
51
|
100
|
|
|
|
319
|
if (my @captures = ($condition->{path} =~ $compiled->{re})) { |
24
|
9
|
|
|
|
|
18
|
@{$condition->{captures}} = @captures; |
|
9
|
|
|
|
|
23
|
|
25
|
9
|
50
|
|
|
|
49
|
return $compiled->{action} if $compiled->{action}->match($condition); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
63
|
|
|
|
|
689
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub register { |
33
|
52
|
|
|
52
|
0
|
73
|
my ($self, $action) = @_; |
34
|
|
|
|
|
|
|
|
35
|
52
|
100
|
|
|
|
60
|
my @register_regex = @{ $action->attributes->{Regex} || [] } |
|
52
|
100
|
|
|
|
454
|
|
36
|
|
|
|
|
|
|
or return; |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
15
|
for my $regex (@register_regex) { |
39
|
5
|
|
|
|
|
16
|
$self->register_regex( $regex, $action ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub register_regex { |
44
|
5
|
|
|
5
|
0
|
10
|
my ($self, $re, $action) = @_; |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
8
|
push @{ $self->compiled }, { |
|
5
|
|
|
|
|
48
|
|
47
|
|
|
|
|
|
|
re => qr/$re/, |
48
|
|
|
|
|
|
|
action => $action, |
49
|
|
|
|
|
|
|
path => $re, |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub used { |
54
|
2
|
|
|
2
|
0
|
4
|
my ($self) = @_; |
55
|
2
|
|
|
|
|
3
|
scalar @{ $self->compiled }; |
|
2
|
|
|
|
|
17
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub list { |
59
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
60
|
0
|
0
|
|
|
|
|
return unless $self->used; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my @rows = [[ 1, 'Regex' ], [ 1, 'Private' ]]; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
for my $re (@{ $self->compiled }) { |
|
0
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
push @rows, [ $re->{path}, '/' . $re->{action}->reverse ]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
\@rows; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |