line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::WWW::Stub::Intercepter; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
16
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
818
|
use Test::WWW::Stub::Handler; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
556
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
2
|
|
|
2
|
0
|
9
|
my ($class) = @_; |
10
|
2
|
|
|
|
|
24
|
return bless { registry => {} }, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub intercept { |
14
|
22
|
|
|
22
|
0
|
62
|
my ($self, $uri, $env, $req) = @_; |
15
|
22
|
|
|
|
|
38
|
for my $pattern (sort { length $a <=> length $b } keys %{ $self->{registry} }) { |
|
11
|
|
|
|
|
39
|
|
|
22
|
|
|
|
|
108
|
|
16
|
25
|
|
|
|
|
58
|
my $handler = $self->{registry}->{$pattern}; |
17
|
25
|
|
|
|
|
87
|
my $maybe_res = $handler->try_call($uri, $env, $req); |
18
|
25
|
100
|
|
|
|
582
|
return $maybe_res if $maybe_res; |
19
|
|
|
|
|
|
|
} |
20
|
4
|
|
|
|
|
14
|
return undef; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get_handler { |
24
|
12
|
|
|
12
|
0
|
33
|
my ($self, $uri_or_re) = @_; |
25
|
12
|
|
|
|
|
43
|
return $self->{registry}->{$uri_or_re}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub register { |
29
|
14
|
|
|
14
|
0
|
37
|
my ($self, $uri_or_re, $app_or_res) = @_; |
30
|
14
|
|
|
|
|
76
|
my $handler = Test::WWW::Stub::Handler->factory($uri_or_re, $app_or_res); |
31
|
14
|
|
|
|
|
62
|
$self->{registry}->{$uri_or_re} = $handler; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub unregister { |
35
|
9
|
|
|
9
|
0
|
26
|
my ($self, $uri_or_re) = @_; |
36
|
9
|
50
|
|
|
|
126
|
delete $self->{registry}->{$uri_or_re} if exists $self->{registry}->{$uri_or_re}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |