| 1 | package Mojolicious::Plugin::IP2Location; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.001002'; # VERSION | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Geo::IP2Location::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | my %Province_Map = ( | |||||||||||||||||||||||||||
| 9 | 'Alberta' => 'AB', | ||||||||||||||||||||||||||||
| 10 | 'British Columbia' => 'BC', | ||||||||||||||||||||||||||||
| 11 | 'Manitoba' => 'MB', | ||||||||||||||||||||||||||||
| 12 | 'New Brunswick' => 'NB', | ||||||||||||||||||||||||||||
| 13 | 'Newfoundland and Labrador' => 'NL', | ||||||||||||||||||||||||||||
| 14 | 'Northwest Territories' => 'NT', | ||||||||||||||||||||||||||||
| 15 | 'Nova Scotia' => 'NS', | ||||||||||||||||||||||||||||
| 16 | 'Nunavut' => 'NU', | ||||||||||||||||||||||||||||
| 17 | 'Ontario' => 'ON', | ||||||||||||||||||||||||||||
| 18 | 'Prince Edward Island' => 'PE', | ||||||||||||||||||||||||||||
| 19 | 'Quebec' => 'QC', | ||||||||||||||||||||||||||||
| 20 | 'Saskatchewan' => 'SK', | ||||||||||||||||||||||||||||
| 21 | 'Yukon Territory' => 'YT', | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub register { | ||||||||||||||||||||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 0 | my ($self, $app) = @_; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | state $geo_ip = Geo::IP2Location::Lite->open( | |||||||||||||||||||||||||||
| 28 | $app->config('ip2location') | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | $app->helper( | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | geoip_region=> sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 33 | 0 | my $c = shift; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $is_debug_ip | ||||||||||||||||||||||||||
|
Condition0%0/3
$c->app->mode eq 'development' && $c->param('DEBUG_GEOIP')
MC/DC0%0/2
$c->app->mode eq 'development' && $c->param('DEBUG_GEOIP')
$c->app->mode eq 'development'
$c->param('DEBUG_GEOIP')
Truth table0%0/3
A && B
A= $c->app->mode eq 'development'B= $c->param('DEBUG_GEOIP')
| |||||||||||||||||||||||||||||
| 36 | = $c->app->mode eq 'development' && $c->param('DEBUG_GEOIP'); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return $c->session('gip_r') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $is_debug_ip and length $c->session("gip_r")
MC/DC0%0/2
not $is_debug_ip and length $c->session("gip_r")
not $is_debug_ip
length $c->session("gip_r")
Truth table0%0/3
not(A) and B
A= not $is_debug_ipB= length $c->session("gip_r")
| |||||||||||||||||||||||||||||
| 39 | if not $is_debug_ip and length $c->session('gip_r'); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $ip = $is_debug_ip | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | ? $c->param('DEBUG_GEOIP') : $c->tx->remote_address; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | $c->session( | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | gip_r => $Province_Map{ $geo_ip->get_region( $ip ) } // '00' | ||||||||||||||||||||||||||
|
Condition0%0/2
$Province_Map{$geo_ip->get_region($ip)} // "00"
MC/DC0%0/1
$Province_Map{$geo_ip->get_region($ip)} // "00"
$Province_Map{$geo_ip->get_region($ip)}
Truth table0%0/2
A
A= $Province_Map{$geo_ip->get_region($ip)}
| |||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | 0 | return $c->session('gip_r'); | |||||||||||||||||||||||||||
| 48 | }, | ||||||||||||||||||||||||||||
| 49 | 0 | ); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 1 | 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||