IP/Record.pm

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