IP/Record.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 4 / 8 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 12 / 12 Podpod 100% 3 / 3 totaltotal 84.1% 53 / 63 SCAR 18.1
CC
6
Cov
84%
_time_zone
5.1
BEGIN
2.5
BEGIN
1.0
CRAP 6.1
« Mirror.pm ↑ Summary
1 package Geo::IP::Record;
2  
3 7 ▶use Geo::IP; #
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use vars qw/$pp/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # here are the missing functions if the C API is used
10 sub latitude {
11 my $gir = shift;
12 return sprintf( "%.4f", $gir->_latitude );
13 }
14  
15 sub longitude {
16 my $gir = shift;
17 return sprintf( "%.4f", $gir->_longitude );
18 }
19  
20 BEGIN {
21 7 ▶ $pp = !defined(&Geo::IP::Record::city)
Subroutine BEGIN: called CC=2 SCAR=9.2
Condition33%1/3
!defined(&Geo::IP::Record::city) || $Geo::IP::GEOIP_PP_ONLY
l!l&&r!l&&!r
700
MC/DC0%0/2
!defined(&Geo::IP::Record::city) || $Geo::IP::GEOIP_PP_ONLY
!defined(&Geo::IP::Record::city) $Geo::IP::GEOIP_PP_ONLY
Truth table33%1/3
not(A) || B
A= !defined(&Geo::IP::Record::city)B= $Geo::IP::GEOIP_PP_ONLY
ABresult
1X1
011
000
22 || $Geo::IP::GEOIP_PP_ONLY;
23 }
24  
25 7 ▶eval <<'__PP__' if $pp;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _time_zone: called CC=5 SCAR=16.3
Subroutine latitude: called CC=1 SCAR=0.0
Subroutine longitude: called CC=1 SCAR=0.0
Subroutine time_zone: called CC=1 SCAR=0.0
Pod documented
Pod documented
Pod documented
Branch: 4 branches
BranchTrueFalseTotal
unless $country 0 1 1
unless defined $TIME_ZONE->{$country} 0 1 1
defined $TIME_ZONE->{$country}{$region} ? : 1 0 1
if $Geo::IP::Record::pp 7 0 7
Condition50%1/2
$region ||= ""
l!l
10
MC/DC0%0/1
$region ||= ""
$region
Truth table50%1/2
A
A= $region
Aresult
11
00
26  
27 for ( qw: country_code country_code3 country_name
28 region region_name city
29 postal_code dma_code area_code
30 continent_code metro_code : ) {
31  
32 no strict qw/ refs /;
33 no warnings qw/ redefine /;
34 my $m = $_; # looks bogus, but it is not! it is a copy not a alias
35 *$_ = sub { $_[0]->{$m} };
36 }
37  
38 # for the case warnings are globaly enabled with perl -w and the CAPI is absent
39 no warnings qw/ redefine /;
40  
41 sub longitude {sprintf('%.4f', $_[0]->{longitude})}
42 sub latitude {sprintf('%.4f', $_[0]->{latitude})}
43  
44 {
45 my $TIME_ZONE;
46  
47 local $_ = <DATA>; # skip first line
48 while (<DATA>) {
49 chomp;
50 next if /^\s*$/;
51 my ( $country, $region, $timezone ) = split /,/, $_, 3;
52 $TIME_ZONE->{$country}->{ $region || '' } = $timezone;
53 }
54  
55 # called from Geo::IP
56 sub _time_zone {
57 my ( undef, $country, $region ) = @_;
58 return undef unless $country;
59 return undef unless defined $TIME_ZONE->{$country};
60 $region ||= '';
61 return
62 defined $TIME_ZONE->{$country}->{$region}
63 ? $TIME_ZONE->{$country}->{$region}
64 : $TIME_ZONE->{$country}->{''};
65 }
66 sub time_zone {
67 my ( $self ) = @_;
68 my ( $country, $region ) = ( $self->country_code, $self->region );
69 return $self->_time_zone( $country, $region );
70 }
71 }
72  
73 __PP__
74 7 1;
75 __DATA__
« Mirror.pm ↑ Summary