StreetMapLink/MapQuest.pm

filter: Statementstmt 100% 33 / 33 Branchbran 58.3% 7 / 12 Conditioncond 45.4% 5 / 11 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 77.9% 53 / 68 CC 14 SCAR 26.3
CC
14
Cov
80%
new
17.5
BEGIN
1.0
BEGIN
1.0
CRAP 13.8
↑ Summary StreetMapLink/Google.pm »
1 package WebService::StreetMapLink::MapQuest;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Geography::States;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use base 'WebService::StreetMapLink';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 __PACKAGE__->RegisterSubclass();
9  
10  
11 5 my %Query = ( usa => { countryid => 'US',
12 country => 'US',
13 },
14 canada => { countryid => 41,
15 country => 'CA',
16 },
17 );
18  
19 5 my @Accents = ( [ qr/[\xE0-\xE2]/ => 'a' ],
20 [ qr/[\xE8-\xEA]/ => 'e' ],
21 [ qr/\xE7/ => 'c' ],
22 [ qr/\xF4/ => 'o' ],
23 );
24  
25 5 ▶sub Countries { keys %Query }
Subroutine Countries: called CC=1 SCAR=0.0
Pod documented
26  
27 sub new
28 5 ▶{
Subroutine new: called CC=14 SCAR=28.6
Pod documented
29 5 my $class = shift;
30 5 my %p = @_;
31  
32 5 local $_;
33 # remove accents from state names like Quebec or mapquest gets upset
34 5 for ( grep { defined } values %p )
35 {
36 26 foreach my $p (@Accents)
37 {
38 104 s/$p->[0]/$p->[1]/g;
39 }
40 }
41  
42 5 ▶ if ( defined $p{state} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p{"state"}) 5 0 5
43 {
44 5 ▶ if ( length $p{state} > 2 )
Branch: 1 branch
BranchTrueFalseTotal
if (length $p{"state"} > 2) 2 3 5
45 {
46 2 $p{state} = Geography::States->new( $p{country} )->state( $p{state} );
47 }
48 }
49  
50 return
51 unless ( defined $p{address}
52 &&
53 ( ( defined $p{city} && defined $p{state} )
54 ||
55 defined $p{postal_code}
56 )
57 5 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p{"address"} and defined $p{"city"} && defined $p{"state"} || defined $p{"postal_code"} 0 5 5
Condition33%3/9
defined $p{"address"} and defined $p{"city"} && defined $p{"state"} || defined $p{"postal_code"}
!ll&&!rl&&r
005
defined $p{"city"} and defined $p{"state"} or defined $p{"postal_code"}
l!l&&r!l&&!r
500
defined $p{"city"} and defined $p{"state"}
!ll&&!rl&&r
005
MC/DC0%0/4
defined $p{"address"} and defined $p{"city"} && defined $p{"state"} || defined $p{"postal_code"}
defined $p{"address"} defined $p{"city"} defined $p{"state"} defined $p{"postal_code"}
Truth table16%1/6
A and B and C or D
A= defined $p{"address"}B= defined $p{"city"}C= defined $p{"state"}D= defined $p{"postal_code"}
ABCDresult
0XXX0
10X00
11000
111X1
10X11
11011
58  
59 5 ▶ return if $p{address} =~ /p\.?o\.\s+box/i;
Branch: 1 branch
BranchTrueFalseTotal
if $p{"address"} =~ /p\.?o\.\s+box/i 0 5 5
60  
61 5 my %query = %{ $Query{ $p{country} } };
62  
63 5 foreach my $k ( qw( address city state ) )
64 {
65 $query{$k} = $p{$k}
66 15 ▶ if defined $p{$k};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p{$k} 15 0 15
67 }
68  
69 $query{zip} = $p{postal_code}
70 5 ▶ if defined $p{postal_code};
Branch: 1 branch
BranchTrueFalseTotal
if defined $p{"postal_code"} 5 0 5
71  
72 5 ▶ $query{zoom} = $p{zoom} || 8;
Condition100%2/2
$p{'zoom'} || 8
l!l
14
MC/DC100%1/1
$p{'zoom'} || 8
$p{'zoom'}
Truth table100%2/2
A
A= $p{'zoom'}
Aresult
11
00
73  
74 5 return bless { host => 'www.mapquest.com',
75 path => '/maps/map.adp',
76 query => \%query,
77 }, $class;
78 }
79  
80  
81 5 1;
82  
83 __END__
↑ Summary StreetMapLink/Google.pm »