blib/lib/Catalyst/TraitFor/Request/GeoIP.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 26 CC 2 SCAR 12.8
CC
2
Cov
0%
_build_geoip_by_addr
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.6
1 package Catalyst::TraitFor::Request::GeoIP;
2 our $VERSION = '0.01';
3  
4 # ABSTRACT: Geo lookups for Catalyst::Requests via Geo::IP
5  
6 use Moose::Role;
7 use Geo::IP;
8 use namespace::autoclean;
9  
10 has geoip_by_addr => (is => 'ro', isa => 'Maybe[Geo::IP::Record]', lazy => 1, builder => '_build_geoip_by_addr');
11  
12 has geoip => (
13 is => 'ro',
14 isa => 'Geo::IP',
15 lazy => 1,
16 default => sub { Geo::IP->open("/usr/local/share/GeoIP/GeoIPCity.dat", GEOIP_MEMORY_CACHE) },
17 );
18  
19 requires 'address';
20  
21 sub _build_geoip_by_addr {
22 my ($self) = @_;
23 my $r = $self->geoip->record_by_addr($self->address);
24 return unless $r;
25 return $r;
26 }
27  
28 1;
29  
30  
31 __END__