blib/lib/URI/Match.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 87.5% 14 / 16 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 90.6% 58 / 64 CC 11 SCAR 16.9
CC
11
Cov
93%
_match
8.3
match_parts
4.0
BEGIN
1.0
CRAP 5.4
↑ Summary
1 # $Id: /mirror/perl/URI-Match/trunk/lib/URI/Match.pm 8767 2007-11-08T01:41:57.358392Z daisuke $
2 #
3 # Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
4 # All rights reserved.
5  
6 package URI::Match;
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use URI();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use vars ('$VERSION');
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 $VERSION = '0.00001';
12  
13 sub URI::match_parts
14 12 ▶{
Subroutine match_parts: called CC=4 SCAR=13.9
Pod undocumented
15 12 my $self = shift;
16  
17 12 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 2 10 12
18 2 return $self->_match( undef, $_[0] );
19 }
20  
21 10 my $matched = 0;
22 10 my $count = 0;
23 10 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 12 10 22
24 12 my($part, $cond) = splice(@_, 0, 2);
25 12 $count++;
26  
27 12 ▶ $matched++ if $self->_match( $part, $cond );
Branch: 1 branch
BranchTrueFalseTotal
if $self->_match($part, $cond) 7 5 12
28 }
29 10 return $matched == $count;
30 }
31  
32 sub URI::_match
33 14 ▶{
Subroutine _match: called CC=8 SCAR=21.2
34 14 my ($self, $part, $cond) = @_;
35  
36 14 ▶ my $target =
Branch: 2 branches
BranchTrueFalseTotal
!defined($part) ? : 2 12 14
$self->can($part) ? : 12 0 12
Condition50%1/2
$self->$part or ""
l!l
120
MC/DC0%0/1
$self->$part or ""
$self->$part
Truth table50%1/2
A
A= $self->$part
Aresult
11
00
37 ! defined $part ? $self :
38 $self->can($part) ? ( $self->$part || '' ) : ''
39 ;
40  
41 14 my $ref = ref $cond ;
42 14 ▶ if (! $ref || $ref eq 'Regexp') {
Branch: 3 branches
BranchTrueFalseTotal
if (not $ref or $ref eq 'Regexp') { } 10 4 14
elsif ($ref eq 'CODE') { } 2 2 4
elsif (my $code = eval { do { $cond->can('match') } }) { } 2 0 2
Condition100%3/3
not $ref or $ref eq "Regexp"
l!l&&r!l&&!r
824
MC/DC100%2/2
not $ref or $ref eq "Regexp"
not $ref $ref eq "Regexp"
Truth table100%3/3
not(A) or B
A= not $refB= $ref eq "Regexp"
ABresult
1X1
011
000
43 10 return $target =~ /$cond/;
44 } elsif ($ref eq 'CODE') {
45 2 return $cond->($target, $self);
46 2 } elsif ( my $code = eval { $cond->can('match') } ) {
47 2 return $code->( $cond, $target, $self );
48 }
49  
50 0 return ();
51 }
52  
53 2 1;
54  
55 __END__
↑ Summary