DDG/Test/Location.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 85.7% 36 / 42 SCAR 11.1
CC
3
Cov
85%
__ANON__
6.0
__ANON__
2.0
import
1.0
CRAP 3.0
« DDG/Test/Language.pm ↑ Summary DDG/ZeroClickInfo/Spice/Data.pm »
1 package DDG::Test::Location;
2 8 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Gives functions for getting test L<DDG::Location> objects.
4 8 $DDG::Test::Location::VERSION = '1016';
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use DDG::Location;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 8 our %locations = (
13 'us' => {
14 country_code => 'US',
15 country_code3 => 'USA',
16 country_name => 'United States',
17 region => 'PA',
18 region_name => 'Pennsylvania',
19 city => 'Phoenixville',
20 postal_code => '19460',
21 latitude => '40.1246',
22 longitude => '-75.5385',
23 time_zone => 'America/New_York',
24 area_code => '610',
25 continent_code => 'NA',
26 metro_code => '504',
27 loc_str => '19460'
28 },
29 'de' => {
30 country_code => 'DE',
31 country_code3 => 'DEU',
32 country_name => 'Germany',
33 region => '07',
34 region_name => 'Nordrhein-Westfalen',
35 city => 'Mönchengladbach',
36 latitude => '51.2000',
37 longitude => '6.4333',
38 time_zone => 'Europe/Berlin',
39 area_code => 0,
40 continent_code => 'EU',
41 metro_code => 0,
42 loc_str => 'Mönchengladbach, Germany',
43 },
44 'my' => {
45 country_code => 'MY',
46 country_code3 => 'MYS',
47 country_name => 'Malaysia',
48 region => '14',
49 region_name => 'Kuala Lumpur',
50 city => 'Kuala Lumpur',
51 latitude => '3.1667',
52 longitude => '101.7000',
53 time_zone => 'Asia/Kuala_Lumpur',
54 area_code => 0,
55 continent_code => 'AS',
56 metro_code => 0,
57 loc_str => 'Kuala Lumpur, Malaysia',
58 },
59 'in' => {
60 country_code => 'IN',
61 country_code3 => 'IND',
62 country_name => 'India',
63 region => '07',
64 region_name => 'Delhi',
65 city => 'New Delhi',
66 latitude => '28.6000',
67 longitude => '77.2000',
68 time_zone => 'Asia/Calcutta',
69 area_code => 0,
70 continent_code => 'AS',
71 metro_code => 0,
72 loc_str => 'New Delhi, India',
73 },
74 'au' => {
75 country_code => 'AU',
76 country_code3 => 'AUS',
77 country_name => 'Australia',
78 region => 'SA',
79 region_name => 'South Australia',
80 city => 'Adelaide',
81 latitude => '-34.5544',
82 longitude => '138.3636',
83 time_zone => 'Australia/Adelaide',
84 area_code => 0,
85 continent_code => 'AU',
86 metro_code => 0,
87 },
88 );
89  
90 sub import {
91 9 ▶ my ( $class, %params ) = @_;
Subroutine import: called CC=1 SCAR=0.4
92 9 my $target = caller;
93 9 my $stash = Package::Stash->new($target);
94  
95  
96 $stash->add_symbol('&test_location', sub {
97 17 ▶ my $location_key = shift;
Subroutine __ANON__: called CC=2 SCAR=7.0
98 17 ▶ die "Unknown location_key \"".$location_key."\"" unless defined $locations{$location_key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $DDG::Test::Location::locations{$location_key} 0 17 17
99 17 return DDG::Location->new( %{$locations{$location_key}} );
100 9 });
101  
102  
103 $stash->add_symbol('&test_location_by_env', sub {
104 0 ▶ my $location_key = defined $ENV{DDG_TEST_LOCATION} ? $ENV{DDG_TEST_LOCATION} : 'us';
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'DDG_TEST_LOCATION'} ? : 0 0 0
105 0 $stash->get_symbol('&test_location')->($location_key);
106 9 });
107  
108 }
109  
110 8 1;
111  
112 __END__
« DDG/Test/Language.pm ↑ Summary DDG/ZeroClickInfo/Spice/Data.pm »