blib/lib/WWW/Mechanize/Plugin/FollowMetaRedirect.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 80.0% 16 / 20 Conditioncond 75.0% 18 / 24 MC/DCmcdc 62.5% 10 / 16 Subroutinesub 87.5% 7 / 8 Podpod 50.0% 1 / 2 totaltotal 81.4% 88 / 108 CC 19 SCAR 21.3
CC
19
Cov
85%
follow_meta_redirect
11.2
_extract
9.9
init
1.1
CRAP 8.4
↑ Summary
1 #
2  
3 package WWW::Mechanize::Plugin::FollowMetaRedirect;
4  
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use HTML::TokeParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 $VERSION = '0.03';
11  
12 0 ▶sub init {
Subroutine init: not called CC=1 SCAR=0.6
Pod undocumented
13 3 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
14 0 *{caller() . '::follow_meta_redirect'} = \&follow_meta_redirect;
15 }
16  
17 19 ▶sub follow_meta_redirect {
Subroutine follow_meta_redirect: called CC=11 SCAR=24.1
Pod documented
18 19 my ($mech, %args) = @_;
19 19 ▶ my $waiting = ( defined $args{ignore_wait} and $args{ignore_wait} ) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'ignore_wait'} && $args{'ignore_wait'} ? : 17 2 19
Condition100%3/3
defined $args{"ignore_wait"} and $args{"ignore_wait"}
!ll&&!rl&&r
1117
MC/DC100%2/2
defined $args{"ignore_wait"} and $args{"ignore_wait"}
defined $args{"ignore_wait"} $args{"ignore_wait"}
Truth table100%3/3
A and B
A= defined $args{"ignore_wait"}B= $args{"ignore_wait"}
ABresult
0X0
100
111
20  
21 19 ▶ my $p = HTML::TokeParser->new( \ $mech->content )
Branch: 1 branch
BranchTrueFalseTotal
my $p = "HTML::TokeParser"->new(\$mech->content) or return 19 0 19
22 or return;
23  
24 19 ▶ while( my $token = $p->get_token ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $p->get_token) 163 0 163
25 # the line should emerge before </head>
26 163 ▶ last if $token->[0] eq 'E' && $token->[1] eq 'head';
Branch: 1 branch
BranchTrueFalseTotal
if $token->[0] eq "E" and $token->[1] eq "head" 2 161 163
Condition100%3/3
$token->[0] eq "E" and $token->[1] eq "head"
!ll&&!rl&&r
15922
MC/DC100%2/2
$token->[0] eq "E" and $token->[1] eq "head"
$token->[0] eq "E" $token->[1] eq "head"
Truth table100%3/3
A and B
A= $token->[0] eq "E"B= $token->[1] eq "head"
ABresult
0X0
100
111
27
28 161 my ($url, $sec) = &_extract( $token );
29 161 ▶ next if ! defined $url || $url eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $url or $url eq "" 144 17 161
Condition66%2/3
not defined $url or $url eq ""
l!l&&r!l&&!r
144017
MC/DC50%1/2
not defined $url or $url eq ""
not defined $url $url eq ""
Truth table66%2/3
not(A) or B
A= not defined $urlB= $url eq ""
ABresult
1X1
011
000
30
31 17 ▶ if( $waiting and defined $sec ){
Branch: 1 branch
BranchTrueFalseTotal
if ($waiting and defined $sec) 2 15 17
Condition66%2/3
$waiting and defined $sec
!ll&&!rl&&r
1502
MC/DC50%1/2
$waiting and defined $sec
$waiting defined $sec
Truth table66%2/3
A and B
A= $waitingB= defined $sec
ABresult
0X0
100
111
32 2 sleep int $sec;
33 }
34
35 17 return $mech->get( $url );
36 }
37  
38 2 return;
39 }
40  
41 3 *WWW::Mechanize::follow_meta_redirect = \&follow_meta_redirect;
42  
43 161 ▶sub _extract {
Subroutine _extract: called CC=9 SCAR=22.9
44 161 my $token = shift;
45  
46 161 ▶ if( $token->[0] eq 'S' and $token->[1] eq 'meta' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[0] eq "S" and $token->[1] eq "meta") 26 135 161
Condition100%3/3
$token->[0] eq "S" and $token->[1] eq "meta"
!ll&&!rl&&r
884726
MC/DC100%2/2
$token->[0] eq "S" and $token->[1] eq "meta"
$token->[0] eq "S" $token->[1] eq "meta"
Truth table100%3/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "meta"
ABresult
0X0
100
111
47 26 ▶ if( defined $token->[2] and ref $token->[2] eq 'HASH' ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->[2] and ref $token->[2] eq "HASH") 26 0 26
Condition33%1/3
defined $token->[2] and ref $token->[2] eq "HASH"
!ll&&!rl&&r
0026
MC/DC0%0/2
defined $token->[2] and ref $token->[2] eq "HASH"
defined $token->[2] ref $token->[2] eq "HASH"
Truth table33%1/3
A and B
A= defined $token->[2]B= ref $token->[2] eq "HASH"
ABresult
0X0
100
111
48 26 ▶ if( defined $token->[2]->{'http-equiv'} and $token->[2]->{'http-equiv'} =~ /^refresh$/io ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->[2]{"http-equiv"} and $token->[2]{"http-equiv"} =~ /^refresh$/io) 17 9 26
Condition100%3/3
defined $token->[2]{"http-equiv"} and $token->[2]{"http-equiv"} =~ /^refresh$/io
!ll&&!rl&&r
2717
MC/DC100%2/2
defined $token->[2]{"http-equiv"} and $token->[2]{"http-equiv"} =~ /^refresh$/io
defined $token->[2]{"http-equiv"} $token->[2]{"http-equiv"} =~ /^refresh$/io
Truth table100%3/3
A and B
A= defined $token->[2]{"http-equiv"}B= $token->[2]{"http-equiv"} =~ /^refresh$/io
ABresult
0X0
100
111
49 17 ▶ if( defined $token->[2]->{'content'} and $token->[2]->{'content'} =~ m|^(([0-9]+)\s*;\s*)*url\='?([^']+)'?$|io ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->[2]{"content"} and $token->[2]{"content"} =~ /^(([0-9]+)\s*;\s*)*url\='?([^']+)'?$/io) 17 0 17
Condition33%1/3
defined $token->[2]{"content"} and $token->[2]{"content"} =~ /^(([0-9]+)\s*;\s*)*url\='?([^']+)'?$/io
!ll&&!rl&&r
0017
MC/DC0%0/2
defined $token->[2]{"content"} and $token->[2]{"content"} =~ /^(([0-9]+)\s*;\s*)*url\='?([^']+)'?$/io
defined $token->[2]{"content"} $token->[2]{"content"} =~ /^(([0-9]+)\s*;\s*)*url\='?([^']+)'?$/io
Truth table33%1/3
A and B
A= defined $token->[2]{"content"}B= $token->[2]{"content"} =~ /^(([0-9]+)\s*;\s*)*url\='?([^']+)'?$/io
ABresult
0X0
100
111
50 17 return ($3, $2);
51 }
52 }
53 }
54 }
55  
56 144 return;
57 }
58  
59 3 1;
60  
61 __END__
↑ Summary