line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DDG::Test::Location; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:DDG'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Gives functions for getting test L objects. |
4
|
|
|
|
|
|
|
$DDG::Test::Location::VERSION = '1017'; |
5
|
8
|
|
|
8
|
|
47
|
use strict; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
187
|
|
6
|
8
|
|
|
8
|
|
33
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
164
|
|
7
|
8
|
|
|
8
|
|
2555
|
use DDG::Location; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
294
|
|
8
|
8
|
|
|
8
|
|
55
|
use Package::Stash; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
157
|
|
9
|
8
|
|
|
8
|
|
33
|
use utf8; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
60
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
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
|
|
|
9
|
|
34
|
my ( $class, %params ) = @_; |
92
|
9
|
|
|
|
|
20
|
my $target = caller; |
93
|
9
|
|
|
|
|
148
|
my $stash = Package::Stash->new($target); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$stash->add_symbol('&test_location', sub { |
97
|
17
|
|
|
17
|
|
12679
|
my $location_key = shift; |
98
|
17
|
50
|
|
|
|
61
|
die "Unknown location_key \"".$location_key."\"" unless defined $locations{$location_key}; |
99
|
17
|
|
|
|
|
33
|
return DDG::Location->new( %{$locations{$location_key}} ); |
|
17
|
|
|
|
|
389
|
|
100
|
9
|
|
|
|
|
156
|
}); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$stash->add_symbol('&test_location_by_env', sub { |
104
|
0
|
0
|
|
0
|
|
|
my $location_key = defined $ENV{DDG_TEST_LOCATION} ? $ENV{DDG_TEST_LOCATION} : 'us'; |
105
|
0
|
|
|
|
|
|
$stash->get_symbol('&test_location')->($location_key); |
106
|
9
|
|
|
|
|
251
|
}); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |