geo_location 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +20 -14
- data/VERSION +1 -1
- data/geo_location.gemspec +4 -2
- data/lib/geo_location.rb +3 -2
- data/lib/geo_location/geo_location.rb +39 -18
- data/lib/geo_location/timezones.rb +43 -0
- data/lib/geo_location/timezones.txt +675 -0
- data/lib/geo_location/variables.rb +6 -3
- data/lib/geo_location/version.rb +3 -1
- data/test/test_geo_location.rb +115 -12
- metadata +6 -4
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Geo Location
|
2
2
|
|
3
|
-
|
3
|
+
Easily geo-locate your users using their IP address via hostip.info or maxmind.com. Super simple to setup, super simple to use. I've found that the data from HostIP and Max Mind differ slightly. Max Mind (paid) has a more complete and accurate database at the moment, but HostIP is growing. For more information about Max Mind visit http://www.maxmind.com/app/city and for more information about HostIP visit http://hostip.info
|
4
4
|
|
5
5
|
|
6
6
|
== Installation
|
@@ -20,13 +20,15 @@ config/initializers/geo_location_config.rb:
|
|
20
20
|
|
21
21
|
== HostIP Example
|
22
22
|
|
23
|
-
|
23
|
+
location = GeoLocation.find('24.24.24.24') # => {:ip=>"24.24.24.24", :city=>"Liverpool", :region=>"NY", :country=>"US", :latitude=>"43.1059", :longitude=>"-76.2099", :timezone=>"America/New_York"}
|
24
24
|
|
25
|
-
puts
|
26
|
-
puts
|
27
|
-
puts
|
28
|
-
puts
|
29
|
-
puts
|
25
|
+
puts location[:ip] # => 24.24.24.24
|
26
|
+
puts location[:city] # => Liverpool
|
27
|
+
puts location[:region] # => NY
|
28
|
+
puts location[:country] # => US
|
29
|
+
puts location[:latitude] # => 43.1059
|
30
|
+
puts location[:longitude] # => -76.2099
|
31
|
+
puts location[:timezone] # => America/New_York
|
30
32
|
|
31
33
|
|
32
34
|
== Max Mind Configuration
|
@@ -40,6 +42,8 @@ config/initializers/geo_location_config.rb:
|
|
40
42
|
GeoLocation::key = 'YOUR MaxMind.COM LICENSE KEY'
|
41
43
|
# This location will be used while you develop rather than hitting the maxmind.com api
|
42
44
|
# GeoLocation::dev = 'US,NY,Jamaica,40.676300,-73.775200' # IP: 24.24.24.24
|
45
|
+
# Use this IP in development mode (development and testing will give you 127.0.0.1)
|
46
|
+
# GeoLocation::dev_ip = '24.24.24.24'
|
43
47
|
end
|
44
48
|
|
45
49
|
|
@@ -47,13 +51,15 @@ config/initializers/geo_location_config.rb:
|
|
47
51
|
|
48
52
|
GeoLocation::use = :maxmind
|
49
53
|
GeoLocation::key = 'YOUR MaxMind.COM LICENSE KEY'
|
50
|
-
|
51
|
-
|
52
|
-
puts
|
53
|
-
puts
|
54
|
-
puts
|
55
|
-
puts
|
56
|
-
puts
|
54
|
+
location = GeoLocation.find('24.24.24.24') # => {:ip=>"24.24.24.24", :city=>"Jamaica", :region=>"NY", :country=>"US", :latitude=>"40.676300", :longitude=>"-73.775200", :timezone=>"America/New_York"}
|
55
|
+
|
56
|
+
puts location[:ip] # => 24.24.24.24
|
57
|
+
puts location[:city] # => Jamaica
|
58
|
+
puts location[:region] # => NY
|
59
|
+
puts location[:country] # => US
|
60
|
+
puts location[:latitude] # => 40.676300
|
61
|
+
puts location[:longitude] # => -73.775200
|
62
|
+
puts location[:timezone] # => America/New_York
|
57
63
|
|
58
64
|
|
59
65
|
== Copyright
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/geo_location.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{geo_location}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chris Your"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-26}
|
13
13
|
s.description = %q{Geo-locate your users using their IP address via hostip.info or maxmind.com.}
|
14
14
|
s.email = %q{chris@ignitionindustries.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,6 +26,8 @@ Gem::Specification.new do |s|
|
|
26
26
|
"geo_location.gemspec",
|
27
27
|
"lib/geo_location.rb",
|
28
28
|
"lib/geo_location/geo_location.rb",
|
29
|
+
"lib/geo_location/timezones.rb",
|
30
|
+
"lib/geo_location/timezones.txt",
|
29
31
|
"lib/geo_location/variables.rb",
|
30
32
|
"lib/geo_location/version.rb",
|
31
33
|
"test/helper.rb",
|
data/lib/geo_location.rb
CHANGED
@@ -6,11 +6,14 @@ module GeoLocation
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
|
9
|
-
def find(ip)
|
9
|
+
def find(ip=nil)
|
10
|
+
ip = GeoLocation::dev_ip unless GeoLocation::dev_ip.nil?
|
10
11
|
return nil unless valid_ip(ip)
|
11
12
|
return (GeoLocation::use == :maxmind) ? maxmind(ip) : hostip(ip)
|
12
13
|
end
|
13
14
|
|
15
|
+
private
|
16
|
+
|
14
17
|
def valid_ip(ip)
|
15
18
|
ip =~ /(([2]([0-4][0-9]|[5][0-5])|[0-1]?[0-9]?[0-9])[.]){3}(([2]([0-4][0-9]|[5][0-5])|[0-1]?[0-9]?[0-9]))/i
|
16
19
|
end
|
@@ -19,23 +22,13 @@ module GeoLocation
|
|
19
22
|
# US,NY,Jamaica,40.676300,-73.775200
|
20
23
|
|
21
24
|
def maxmind(ip)
|
22
|
-
|
23
|
-
puts "WARNING: GeoLocation is using the dev location: #{GeoLocation::dev}"
|
24
|
-
location = GeoLocation::dev.split(',')
|
25
|
-
else
|
25
|
+
if GeoLocation::dev.nil? || GeoLocation::dev.empty?
|
26
26
|
url = "http://geoip3.maxmind.com/b?l=#{GeoLocation::key}&i=#{ip}"
|
27
27
|
uri = URI.parse(url)
|
28
|
-
|
28
|
+
data_from_maxmind_http_response(ip, Net::HTTP.get_response(uri).body)
|
29
|
+
else
|
30
|
+
data_from_maxmind_http_response(ip, GeoLocation::dev)
|
29
31
|
end
|
30
|
-
|
31
|
-
data = {}
|
32
|
-
data[:country] = location[0]
|
33
|
-
data[:region] = location[1]
|
34
|
-
data[:city] = location[2]
|
35
|
-
data[:latitude] = location[3]
|
36
|
-
data[:longitude] = location[4]
|
37
|
-
|
38
|
-
data
|
39
32
|
end
|
40
33
|
|
41
34
|
# == Sample XML output from hostip.info (http://api.hostip.info/?ip=12.215.42.19)
|
@@ -65,9 +58,34 @@ module GeoLocation
|
|
65
58
|
# </HostipLookupResultSet>
|
66
59
|
|
67
60
|
def hostip(ip)
|
68
|
-
|
69
|
-
|
70
|
-
|
61
|
+
if GeoLocation::dev.nil? || GeoLocation::dev.empty?
|
62
|
+
url = "http://api.hostip.info/?ip=#{ip}"
|
63
|
+
uri = URI.parse(url)
|
64
|
+
data_from_hostip_http_response(ip, Net::HTTP.get_response(uri).body)
|
65
|
+
else
|
66
|
+
data_from_maxmind_http_response(ip, GeoLocation::dev)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# == Handle http response data from Max Mind
|
71
|
+
# string formatted body
|
72
|
+
def data_from_maxmind_http_response(ip, body)
|
73
|
+
location = body.split(',')
|
74
|
+
data = {}
|
75
|
+
data[:country] = location[0]
|
76
|
+
data[:region] = location[1]
|
77
|
+
data[:city] = location[2]
|
78
|
+
data[:latitude] = location[3]
|
79
|
+
data[:longitude] = location[4]
|
80
|
+
data[:ip] = ip
|
81
|
+
data[:timezone] = timezone(data[:country], data[:region])
|
82
|
+
data
|
83
|
+
end
|
84
|
+
|
85
|
+
# == Handle http response data from HostIP
|
86
|
+
# xml formatted body
|
87
|
+
def data_from_hostip_http_response(ip, body)
|
88
|
+
xml = body
|
71
89
|
location = REXML::Document.new(xml)
|
72
90
|
|
73
91
|
data = {}
|
@@ -95,6 +113,9 @@ module GeoLocation
|
|
95
113
|
end
|
96
114
|
end
|
97
115
|
|
116
|
+
data[:ip] = ip
|
117
|
+
data[:timezone] = timezone(data[:country], data[:region])
|
118
|
+
|
98
119
|
data
|
99
120
|
end
|
100
121
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module GeoLocation
|
2
|
+
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def timezone(country, region=nil)
|
6
|
+
build_timezones
|
7
|
+
return nil if GeoLocation::timezones.empty?
|
8
|
+
(region.nil? || region.empty?) ? GeoLocation::timezones[country.to_sym] : GeoLocation::timezones[country.to_sym][region.to_sym]
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def build_timezones
|
14
|
+
if GeoLocation::timezones.empty?
|
15
|
+
data = {}
|
16
|
+
|
17
|
+
File.open("lib/geo_location/timezones.txt", "r") do |infile|
|
18
|
+
while (line = infile.gets)
|
19
|
+
zones = line.split("\n")
|
20
|
+
zones.each do |z|
|
21
|
+
zone = z.split(" ")
|
22
|
+
country = zone[0].to_sym
|
23
|
+
region = zone[1].to_sym
|
24
|
+
value = zone[2]
|
25
|
+
|
26
|
+
data[country] = {} if data[country].nil?
|
27
|
+
if region.to_s.empty?
|
28
|
+
data[country] = value
|
29
|
+
else
|
30
|
+
data[country][region] = value
|
31
|
+
end
|
32
|
+
|
33
|
+
end # end zones.each
|
34
|
+
end # end while
|
35
|
+
end # end file.open
|
36
|
+
|
37
|
+
GeoLocation::timezones = data
|
38
|
+
end # end unless
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,675 @@
|
|
1
|
+
US AL America/Chicago
|
2
|
+
US AK America/Anchorage
|
3
|
+
US AZ America/Phoenix
|
4
|
+
US AR America/Chicago
|
5
|
+
US CA America/Los_Angeles
|
6
|
+
US CO America/Denver
|
7
|
+
US CT America/New_York
|
8
|
+
US DE America/New_York
|
9
|
+
US DC America/New_York
|
10
|
+
US FL America/New_York
|
11
|
+
US GA America/New_York
|
12
|
+
US HI Pacific/Honolulu
|
13
|
+
US ID America/Denver
|
14
|
+
US IL America/Chicago
|
15
|
+
US IN America/Indianapolis
|
16
|
+
US IA America/Chicago
|
17
|
+
US KS America/Chicago
|
18
|
+
US KY America/New_York
|
19
|
+
US LA America/Chicago
|
20
|
+
US ME America/New_York
|
21
|
+
US MD America/New_York
|
22
|
+
US MA America/New_York
|
23
|
+
US MI America/New_York
|
24
|
+
US MN America/Chicago
|
25
|
+
US MS America/Chicago
|
26
|
+
US MO America/Chicago
|
27
|
+
US MT America/Denver
|
28
|
+
US NE America/Chicago
|
29
|
+
US NV America/Los_Angeles
|
30
|
+
US NH America/New_York
|
31
|
+
US NJ America/New_York
|
32
|
+
US NM America/Denver
|
33
|
+
US NY America/New_York
|
34
|
+
US NC America/New_York
|
35
|
+
US ND America/Chicago
|
36
|
+
US OH America/New_York
|
37
|
+
US OK America/Chicago
|
38
|
+
US OR America/Los_Angeles
|
39
|
+
US PA America/New_York
|
40
|
+
US RI America/New_York
|
41
|
+
US SC America/New_York
|
42
|
+
US SD America/Chicago
|
43
|
+
US TN America/Chicago
|
44
|
+
US TX America/Chicago
|
45
|
+
US UT America/Denver
|
46
|
+
US VT America/New_York
|
47
|
+
US VA America/New_York
|
48
|
+
US WA America/Los_Angeles
|
49
|
+
US WV America/New_York
|
50
|
+
US WI America/Chicago
|
51
|
+
US WY America/Denver
|
52
|
+
CA AB America/Edmonton
|
53
|
+
CA BC America/Vancouver
|
54
|
+
CA MB America/Winnipeg
|
55
|
+
CA NB America/Halifax
|
56
|
+
CA NL America/St_Johns
|
57
|
+
CA NT America/Yellowknife
|
58
|
+
CA NS America/Halifax
|
59
|
+
CA NU America/Rankin_Inlet
|
60
|
+
CA ON America/Rainy_River
|
61
|
+
CA PE America/Halifax
|
62
|
+
CA QC America/Montreal
|
63
|
+
CA SK America/Regina
|
64
|
+
CA YT America/Whitehorse
|
65
|
+
AU 01 Australia/Canberra
|
66
|
+
AU 02 Australia/NSW
|
67
|
+
AU 03 Australia/North
|
68
|
+
AU 04 Australia/Queensland
|
69
|
+
AU 05 Australia/South
|
70
|
+
AU 06 Australia/Tasmania
|
71
|
+
AU 07 Australia/Victoria
|
72
|
+
AU 08 Australia/West
|
73
|
+
AS US/Samoa
|
74
|
+
CI Africa/Abidjan
|
75
|
+
GH Africa/Accra
|
76
|
+
DZ Africa/Algiers
|
77
|
+
ER Africa/Asmera
|
78
|
+
ML Africa/Bamako
|
79
|
+
CF Africa/Bangui
|
80
|
+
GM Africa/Banjul
|
81
|
+
GW Africa/Bissau
|
82
|
+
CG Africa/Brazzaville
|
83
|
+
BI Africa/Bujumbura
|
84
|
+
EG Africa/Cairo
|
85
|
+
MA Africa/Casablanca
|
86
|
+
GN Africa/Conakry
|
87
|
+
SN Africa/Dakar
|
88
|
+
DJ Africa/Djibouti
|
89
|
+
SL Africa/Freetown
|
90
|
+
BW Africa/Gaborone
|
91
|
+
ZW Africa/Harare
|
92
|
+
ZA Africa/Johannesburg
|
93
|
+
UG Africa/Kampala
|
94
|
+
SD Africa/Khartoum
|
95
|
+
RW Africa/Kigali
|
96
|
+
NG Africa/Lagos
|
97
|
+
GA Africa/Libreville
|
98
|
+
TG Africa/Lome
|
99
|
+
AO Africa/Luanda
|
100
|
+
ZM Africa/Lusaka
|
101
|
+
GQ Africa/Malabo
|
102
|
+
MZ Africa/Maputo
|
103
|
+
LS Africa/Maseru
|
104
|
+
SZ Africa/Mbabane
|
105
|
+
SO Africa/Mogadishu
|
106
|
+
LR Africa/Monrovia
|
107
|
+
KE Africa/Nairobi
|
108
|
+
TD Africa/Ndjamena
|
109
|
+
NE Africa/Niamey
|
110
|
+
MR Africa/Nouakchott
|
111
|
+
BF Africa/Ouagadougou
|
112
|
+
ST Africa/Sao_Tome
|
113
|
+
LY Africa/Tripoli
|
114
|
+
TN Africa/Tunis
|
115
|
+
AI America/Anguilla
|
116
|
+
AG America/Antigua
|
117
|
+
AW America/Aruba
|
118
|
+
BB America/Barbados
|
119
|
+
BZ America/Belize
|
120
|
+
CO America/Bogota
|
121
|
+
VE America/Caracas
|
122
|
+
KY America/Cayman
|
123
|
+
CR America/Costa_Rica
|
124
|
+
DM America/Dominica
|
125
|
+
SV America/El_Salvador
|
126
|
+
GD America/Grenada
|
127
|
+
FR Europe/Paris
|
128
|
+
GP America/Guadeloupe
|
129
|
+
GT America/Guatemala
|
130
|
+
GY America/Guyana
|
131
|
+
CU America/Havana
|
132
|
+
JM America/Jamaica
|
133
|
+
BO America/La_Paz
|
134
|
+
PE America/Lima
|
135
|
+
NI America/Managua
|
136
|
+
MQ America/Martinique
|
137
|
+
UY America/Montevideo
|
138
|
+
MS America/Montserrat
|
139
|
+
BS America/Nassau
|
140
|
+
PA America/Panama
|
141
|
+
SR America/Paramaribo
|
142
|
+
PR America/Puerto_Rico
|
143
|
+
KN America/St_Kitts
|
144
|
+
LC America/St_Lucia
|
145
|
+
VC America/St_Vincent
|
146
|
+
HN America/Tegucigalpa
|
147
|
+
YE Asia/Aden
|
148
|
+
JO Asia/Amman
|
149
|
+
TM Asia/Ashgabat
|
150
|
+
IQ Asia/Baghdad
|
151
|
+
BH Asia/Bahrain
|
152
|
+
AZ Asia/Baku
|
153
|
+
TH Asia/Bangkok
|
154
|
+
LB Asia/Beirut
|
155
|
+
KG Asia/Bishkek
|
156
|
+
BN Asia/Brunei
|
157
|
+
IN Asia/Calcutta
|
158
|
+
MN Asia/Choibalsan
|
159
|
+
LK Asia/Colombo
|
160
|
+
BD Asia/Dhaka
|
161
|
+
AE Asia/Dubai
|
162
|
+
TJ Asia/Dushanbe
|
163
|
+
HK Asia/Hong_Kong
|
164
|
+
TR Asia/Istanbul
|
165
|
+
IL Asia/Jerusalem
|
166
|
+
AF Asia/Kabul
|
167
|
+
PK Asia/Karachi
|
168
|
+
NP Asia/Katmandu
|
169
|
+
KW Asia/Kuwait
|
170
|
+
MO Asia/Macao
|
171
|
+
PH Asia/Manila
|
172
|
+
OM Asia/Muscat
|
173
|
+
CY Asia/Nicosia
|
174
|
+
KP Asia/Pyongyang
|
175
|
+
QA Asia/Qatar
|
176
|
+
MM Asia/Rangoon
|
177
|
+
SA Asia/Riyadh
|
178
|
+
KR Asia/Seoul
|
179
|
+
SG Asia/Singapore
|
180
|
+
TW Asia/Taipei
|
181
|
+
GE Asia/Tbilisi
|
182
|
+
BT Asia/Thimphu
|
183
|
+
JP Asia/Tokyo
|
184
|
+
LA Asia/Vientiane
|
185
|
+
AM Asia/Yerevan
|
186
|
+
BM Atlantic/Bermuda
|
187
|
+
CV Atlantic/Cape_Verde
|
188
|
+
FO Atlantic/Faeroe
|
189
|
+
IS Atlantic/Reykjavik
|
190
|
+
GS Atlantic/South_Georgia
|
191
|
+
SH Atlantic/St_Helena
|
192
|
+
CL Chile/Continental
|
193
|
+
NL Europe/Amsterdam
|
194
|
+
AD Europe/Andorra
|
195
|
+
GR Europe/Athens
|
196
|
+
YU Europe/Belgrade
|
197
|
+
DE Europe/Berlin
|
198
|
+
SK Europe/Bratislava
|
199
|
+
BE Europe/Brussels
|
200
|
+
RO Europe/Bucharest
|
201
|
+
HU Europe/Budapest
|
202
|
+
DK Europe/Copenhagen
|
203
|
+
IE Europe/Dublin
|
204
|
+
GI Europe/Gibraltar
|
205
|
+
FI Europe/Helsinki
|
206
|
+
SI Europe/Ljubljana
|
207
|
+
GB Europe/London
|
208
|
+
LU Europe/Luxembourg
|
209
|
+
MT Europe/Malta
|
210
|
+
BY Europe/Minsk
|
211
|
+
MC Europe/Monaco
|
212
|
+
NO Europe/Oslo
|
213
|
+
CZ Europe/Prague
|
214
|
+
LV Europe/Riga
|
215
|
+
IT Europe/Rome
|
216
|
+
SM Europe/San_Marino
|
217
|
+
BA Europe/Sarajevo
|
218
|
+
MK Europe/Skopje
|
219
|
+
BG Europe/Sofia
|
220
|
+
SE Europe/Stockholm
|
221
|
+
EE Europe/Tallinn
|
222
|
+
AL Europe/Tirane
|
223
|
+
LI Europe/Vaduz
|
224
|
+
VA Europe/Vatican
|
225
|
+
AT Europe/Vienna
|
226
|
+
LT Europe/Vilnius
|
227
|
+
PL Europe/Warsaw
|
228
|
+
HR Europe/Zagreb
|
229
|
+
IR Asia/Tehran
|
230
|
+
MG Indian/Antananarivo
|
231
|
+
CX Indian/Christmas
|
232
|
+
CC Indian/Cocos
|
233
|
+
KM Indian/Comoro
|
234
|
+
MV Indian/Maldives
|
235
|
+
MU Indian/Mauritius
|
236
|
+
YT Indian/Mayotte
|
237
|
+
RE Indian/Reunion
|
238
|
+
FJ Pacific/Fiji
|
239
|
+
TV Pacific/Funafuti
|
240
|
+
GU Pacific/Guam
|
241
|
+
NR Pacific/Nauru
|
242
|
+
NU Pacific/Niue
|
243
|
+
NF Pacific/Norfolk
|
244
|
+
PW Pacific/Palau
|
245
|
+
PN Pacific/Pitcairn
|
246
|
+
CK Pacific/Rarotonga
|
247
|
+
WS Pacific/Samoa
|
248
|
+
KI Pacific/Tarawa
|
249
|
+
TO Pacific/Tongatapu
|
250
|
+
WF Pacific/Wallis
|
251
|
+
TZ Africa/Dar_es_Salaam
|
252
|
+
VN Asia/Phnom_Penh
|
253
|
+
KH Asia/Phnom_Penh
|
254
|
+
CM Africa/Lagos
|
255
|
+
DO America/Santo_Domingo
|
256
|
+
ET Africa/Addis_Ababa
|
257
|
+
FX Europe/Paris
|
258
|
+
HT America/Port-au-Prince
|
259
|
+
CH Europe/Zurich
|
260
|
+
AN America/Curacao
|
261
|
+
BJ Africa/Porto-Novo
|
262
|
+
EH Africa/El_Aaiun
|
263
|
+
FK Atlantic/Stanley
|
264
|
+
GF America/Cayenne
|
265
|
+
IO Indian/Chagos
|
266
|
+
MD Europe/Chisinau
|
267
|
+
MP Pacific/Saipan
|
268
|
+
MW Africa/Blantyre
|
269
|
+
NA Africa/Windhoek
|
270
|
+
NC Pacific/Noumea
|
271
|
+
PG Pacific/Port_Moresby
|
272
|
+
PM America/Miquelon
|
273
|
+
PS Asia/Gaza
|
274
|
+
PY America/Asuncion
|
275
|
+
SB Pacific/Guadalcanal
|
276
|
+
SC Indian/Mahe
|
277
|
+
SJ Arctic/Longyearbyen
|
278
|
+
SY Asia/Damascus
|
279
|
+
TC America/Grand_Turk
|
280
|
+
TF Indian/Kerguelen
|
281
|
+
TK Pacific/Fakaofo
|
282
|
+
TT America/Port_of_Spain
|
283
|
+
VG America/Tortola
|
284
|
+
VI America/St_Thomas
|
285
|
+
VU Pacific/Efate
|
286
|
+
RS Europe/Belgrade
|
287
|
+
ME Europe/Podgorica
|
288
|
+
AX Europe/Mariehamn
|
289
|
+
GG Europe/Guernsey
|
290
|
+
IM Europe/Isle_of_Man
|
291
|
+
JE Europe/Jersey
|
292
|
+
BL America/St_Barthelemy
|
293
|
+
MF America/Marigot
|
294
|
+
AR 01 America/Argentina/Buenos_Aires
|
295
|
+
AR 02 America/Argentina/Catamarca
|
296
|
+
AR 03 America/Argentina/Tucuman
|
297
|
+
AR 04 America/Argentina/Rio_Gallegos
|
298
|
+
AR 05 America/Argentina/Cordoba
|
299
|
+
AR 06 America/Argentina/Tucuman
|
300
|
+
AR 07 America/Argentina/Buenos_Aires
|
301
|
+
AR 08 America/Argentina/Buenos_Aires
|
302
|
+
AR 09 America/Argentina/Tucuman
|
303
|
+
AR 10 America/Argentina/Jujuy
|
304
|
+
AR 11 America/Argentina/San_Luis
|
305
|
+
AR 12 America/Argentina/La_Rioja
|
306
|
+
AR 13 America/Argentina/Mendoza
|
307
|
+
AR 14 America/Argentina/Buenos_Aires
|
308
|
+
AR 15 America/Argentina/San_Luis
|
309
|
+
AR 16 America/Argentina/Buenos_Aires
|
310
|
+
AR 17 America/Argentina/Salta
|
311
|
+
AR 18 America/Argentina/San_Juan
|
312
|
+
AR 19 America/Argentina/San_Luis
|
313
|
+
AR 20 America/Argentina/Rio_Gallegos
|
314
|
+
AR 21 America/Argentina/Buenos_Aires
|
315
|
+
AR 22 America/Argentina/Catamarca
|
316
|
+
AR 23 America/Argentina/Ushuaia
|
317
|
+
AR 24 America/Argentina/Tucuman
|
318
|
+
BR 01 America/Rio_Branco
|
319
|
+
BR 02 America/Maceio
|
320
|
+
BR 03 America/Sao_Paulo
|
321
|
+
BR 04 America/Manaus
|
322
|
+
BR 05 America/Bahia
|
323
|
+
BR 06 America/Fortaleza
|
324
|
+
BR 07 America/Sao_Paulo
|
325
|
+
BR 08 America/Sao_Paulo
|
326
|
+
BR 11 America/Campo_Grande
|
327
|
+
BR 13 America/Belem
|
328
|
+
BR 14 America/Cuiaba
|
329
|
+
BR 15 America/Sao_Paulo
|
330
|
+
BR 16 America/Belem
|
331
|
+
BR 17 America/Recife
|
332
|
+
BR 18 America/Sao_Paulo
|
333
|
+
BR 20 America/Fortaleza
|
334
|
+
BR 21 America/Sao_Paulo
|
335
|
+
BR 22 America/Recife
|
336
|
+
BR 23 America/Sao_Paulo
|
337
|
+
BR 24 America/Porto_Velho
|
338
|
+
BR 25 America/Boa_Vista
|
339
|
+
BR 26 America/Sao_Paulo
|
340
|
+
BR 27 America/Sao_Paulo
|
341
|
+
BR 28 America/Maceio
|
342
|
+
BR 29 America/Sao_Paulo
|
343
|
+
BR 30 America/Recife
|
344
|
+
BR 31 America/Araguaina
|
345
|
+
CD 02 Africa/Kinshasa
|
346
|
+
CD 05 Africa/Lubumbashi
|
347
|
+
CD 06 Africa/Kinshasa
|
348
|
+
CD 08 Africa/Kinshasa
|
349
|
+
CD 10 Africa/Lubumbashi
|
350
|
+
CD 11 Africa/Lubumbashi
|
351
|
+
CD 12 Africa/Lubumbashi
|
352
|
+
CN 01 Asia/Shanghai
|
353
|
+
CN 02 Asia/Shanghai
|
354
|
+
CN 03 Asia/Shanghai
|
355
|
+
CN 04 Asia/Shanghai
|
356
|
+
CN 05 Asia/Harbin
|
357
|
+
CN 06 Asia/Chongqing
|
358
|
+
CN 07 Asia/Shanghai
|
359
|
+
CN 08 Asia/Harbin
|
360
|
+
CN 09 Asia/Shanghai
|
361
|
+
CN 10 Asia/Shanghai
|
362
|
+
CN 11 Asia/Chongqing
|
363
|
+
CN 12 Asia/Shanghai
|
364
|
+
CN 13 Asia/Urumqi
|
365
|
+
CN 14 Asia/Chongqing
|
366
|
+
CN 15 Asia/Chongqing
|
367
|
+
CN 16 Asia/Chongqing
|
368
|
+
CN 18 Asia/Chongqing
|
369
|
+
CN 19 Asia/Harbin
|
370
|
+
CN 20 Asia/Harbin
|
371
|
+
CN 21 Asia/Chongqing
|
372
|
+
CN 22 Asia/Harbin
|
373
|
+
CN 23 Asia/Shanghai
|
374
|
+
CN 24 Asia/Chongqing
|
375
|
+
CN 25 Asia/Shanghai
|
376
|
+
CN 26 Asia/Chongqing
|
377
|
+
CN 28 Asia/Shanghai
|
378
|
+
CN 29 Asia/Chongqing
|
379
|
+
CN 30 Asia/Chongqing
|
380
|
+
CN 31 Asia/Chongqing
|
381
|
+
CN 32 Asia/Chongqing
|
382
|
+
CN 33 Asia/Chongqing
|
383
|
+
EC 01 Pacific/Galapagos
|
384
|
+
EC 02 America/Guayaquil
|
385
|
+
EC 03 America/Guayaquil
|
386
|
+
EC 04 America/Guayaquil
|
387
|
+
EC 05 America/Guayaquil
|
388
|
+
EC 06 America/Guayaquil
|
389
|
+
EC 07 America/Guayaquil
|
390
|
+
EC 08 America/Guayaquil
|
391
|
+
EC 09 America/Guayaquil
|
392
|
+
EC 10 America/Guayaquil
|
393
|
+
EC 11 America/Guayaquil
|
394
|
+
EC 12 America/Guayaquil
|
395
|
+
EC 13 America/Guayaquil
|
396
|
+
EC 14 America/Guayaquil
|
397
|
+
EC 15 America/Guayaquil
|
398
|
+
EC 17 America/Guayaquil
|
399
|
+
EC 18 America/Guayaquil
|
400
|
+
EC 19 America/Guayaquil
|
401
|
+
EC 20 America/Guayaquil
|
402
|
+
EC 22 America/Guayaquil
|
403
|
+
ES 07 Europe/Madrid
|
404
|
+
ES 27 Europe/Madrid
|
405
|
+
ES 29 Europe/Madrid
|
406
|
+
ES 31 Europe/Madrid
|
407
|
+
ES 32 Europe/Madrid
|
408
|
+
ES 34 Europe/Madrid
|
409
|
+
ES 39 Europe/Madrid
|
410
|
+
ES 51 Africa/Ceuta
|
411
|
+
ES 52 Europe/Madrid
|
412
|
+
ES 53 Atlantic/Canary
|
413
|
+
ES 54 Europe/Madrid
|
414
|
+
ES 55 Europe/Madrid
|
415
|
+
ES 56 Europe/Madrid
|
416
|
+
ES 57 Europe/Madrid
|
417
|
+
ES 58 Europe/Madrid
|
418
|
+
ES 59 Europe/Madrid
|
419
|
+
ES 60 Europe/Madrid
|
420
|
+
GL 01 America/Thule
|
421
|
+
GL 02 America/Godthab
|
422
|
+
GL 03 America/Godthab
|
423
|
+
ID 01 Asia/Pontianak
|
424
|
+
ID 02 Asia/Makassar
|
425
|
+
ID 03 Asia/Jakarta
|
426
|
+
ID 04 Asia/Jakarta
|
427
|
+
ID 05 Asia/Jakarta
|
428
|
+
ID 06 Asia/Jakarta
|
429
|
+
ID 07 Asia/Jakarta
|
430
|
+
ID 08 Asia/Jakarta
|
431
|
+
ID 09 Asia/Jayapura
|
432
|
+
ID 10 Asia/Jakarta
|
433
|
+
ID 11 Asia/Pontianak
|
434
|
+
ID 12 Asia/Makassar
|
435
|
+
ID 13 Asia/Makassar
|
436
|
+
ID 14 Asia/Makassar
|
437
|
+
ID 15 Asia/Jakarta
|
438
|
+
ID 16 Asia/Makassar
|
439
|
+
ID 17 Asia/Makassar
|
440
|
+
ID 18 Asia/Makassar
|
441
|
+
ID 19 Asia/Pontianak
|
442
|
+
ID 20 Asia/Makassar
|
443
|
+
ID 21 Asia/Makassar
|
444
|
+
ID 22 Asia/Makassar
|
445
|
+
ID 23 Asia/Makassar
|
446
|
+
ID 24 Asia/Jakarta
|
447
|
+
ID 25 Asia/Pontianak
|
448
|
+
ID 26 Asia/Pontianak
|
449
|
+
ID 30 Asia/Jakarta
|
450
|
+
ID 31 Asia/Makassar
|
451
|
+
ID 33 Asia/Jakarta
|
452
|
+
KZ 01 Asia/Almaty
|
453
|
+
KZ 02 Asia/Almaty
|
454
|
+
KZ 03 Asia/Qyzylorda
|
455
|
+
KZ 04 Asia/Aqtobe
|
456
|
+
KZ 05 Asia/Qyzylorda
|
457
|
+
KZ 06 Asia/Aqtau
|
458
|
+
KZ 07 Asia/Oral
|
459
|
+
KZ 08 Asia/Qyzylorda
|
460
|
+
KZ 09 Asia/Aqtau
|
461
|
+
KZ 10 Asia/Qyzylorda
|
462
|
+
KZ 11 Asia/Almaty
|
463
|
+
KZ 12 Asia/Qyzylorda
|
464
|
+
KZ 13 Asia/Aqtobe
|
465
|
+
KZ 14 Asia/Qyzylorda
|
466
|
+
KZ 15 Asia/Almaty
|
467
|
+
KZ 16 Asia/Aqtobe
|
468
|
+
KZ 17 Asia/Almaty
|
469
|
+
MX 01 America/Mexico_City
|
470
|
+
MX 02 America/Tijuana
|
471
|
+
MX 03 America/Hermosillo
|
472
|
+
MX 04 America/Merida
|
473
|
+
MX 05 America/Mexico_City
|
474
|
+
MX 06 America/Chihuahua
|
475
|
+
MX 07 America/Monterrey
|
476
|
+
MX 08 America/Mexico_City
|
477
|
+
MX 09 America/Mexico_City
|
478
|
+
MX 10 America/Mazatlan
|
479
|
+
MX 11 America/Mexico_City
|
480
|
+
MX 12 America/Mexico_City
|
481
|
+
MX 13 America/Mexico_City
|
482
|
+
MX 14 America/Mazatlan
|
483
|
+
MX 15 America/Chihuahua
|
484
|
+
MX 16 America/Mexico_City
|
485
|
+
MX 17 America/Mexico_City
|
486
|
+
MX 18 America/Mazatlan
|
487
|
+
MX 19 America/Monterrey
|
488
|
+
MX 20 America/Mexico_City
|
489
|
+
MX 21 America/Mexico_City
|
490
|
+
MX 22 America/Mexico_City
|
491
|
+
MX 23 America/Cancun
|
492
|
+
MX 24 America/Mexico_City
|
493
|
+
MX 25 America/Mazatlan
|
494
|
+
MX 26 America/Hermosillo
|
495
|
+
MX 27 America/Merida
|
496
|
+
MX 28 America/Monterrey
|
497
|
+
MX 29 America/Mexico_City
|
498
|
+
MX 30 America/Mexico_City
|
499
|
+
MX 31 America/Merida
|
500
|
+
MX 32 America/Monterrey
|
501
|
+
MY 01 Asia/Kuala_Lumpur
|
502
|
+
MY 02 Asia/Kuala_Lumpur
|
503
|
+
MY 03 Asia/Kuala_Lumpur
|
504
|
+
MY 04 Asia/Kuala_Lumpur
|
505
|
+
MY 05 Asia/Kuala_Lumpur
|
506
|
+
MY 06 Asia/Kuala_Lumpur
|
507
|
+
MY 07 Asia/Kuala_Lumpur
|
508
|
+
MY 08 Asia/Kuala_Lumpur
|
509
|
+
MY 09 Asia/Kuala_Lumpur
|
510
|
+
MY 11 Asia/Kuching
|
511
|
+
MY 12 Asia/Kuala_Lumpur
|
512
|
+
MY 13 Asia/Kuala_Lumpur
|
513
|
+
MY 14 Asia/Kuala_Lumpur
|
514
|
+
MY 15 Asia/Kuching
|
515
|
+
MY 16 Asia/Kuching
|
516
|
+
NZ 85 Pacific/Auckland
|
517
|
+
NZ E7 Pacific/Auckland
|
518
|
+
NZ E8 Pacific/Auckland
|
519
|
+
NZ E9 Pacific/Auckland
|
520
|
+
NZ F1 Pacific/Auckland
|
521
|
+
NZ F2 Pacific/Auckland
|
522
|
+
NZ F3 Pacific/Auckland
|
523
|
+
NZ F4 Pacific/Auckland
|
524
|
+
NZ F5 Pacific/Auckland
|
525
|
+
NZ F7 Pacific/Chatham
|
526
|
+
NZ F8 Pacific/Auckland
|
527
|
+
NZ F9 Pacific/Auckland
|
528
|
+
NZ G1 Pacific/Auckland
|
529
|
+
NZ G2 Pacific/Auckland
|
530
|
+
NZ G3 Pacific/Auckland
|
531
|
+
PT 02 Europe/Lisbon
|
532
|
+
PT 03 Europe/Lisbon
|
533
|
+
PT 04 Europe/Lisbon
|
534
|
+
PT 05 Europe/Lisbon
|
535
|
+
PT 06 Europe/Lisbon
|
536
|
+
PT 07 Europe/Lisbon
|
537
|
+
PT 08 Europe/Lisbon
|
538
|
+
PT 09 Europe/Lisbon
|
539
|
+
PT 10 Atlantic/Madeira
|
540
|
+
PT 11 Europe/Lisbon
|
541
|
+
PT 13 Europe/Lisbon
|
542
|
+
PT 14 Europe/Lisbon
|
543
|
+
PT 16 Europe/Lisbon
|
544
|
+
PT 17 Europe/Lisbon
|
545
|
+
PT 18 Europe/Lisbon
|
546
|
+
PT 19 Europe/Lisbon
|
547
|
+
PT 20 Europe/Lisbon
|
548
|
+
PT 21 Europe/Lisbon
|
549
|
+
PT 22 Europe/Lisbon
|
550
|
+
RU 01 Europe/Volgograd
|
551
|
+
RU 02 Asia/Irkutsk
|
552
|
+
RU 03 Asia/Novokuznetsk
|
553
|
+
RU 04 Asia/Novosibirsk
|
554
|
+
RU 05 Asia/Vladivostok
|
555
|
+
RU 06 Europe/Moscow
|
556
|
+
RU 07 Europe/Volgograd
|
557
|
+
RU 08 Europe/Samara
|
558
|
+
RU 09 Europe/Moscow
|
559
|
+
RU 10 Europe/Moscow
|
560
|
+
RU 11 Asia/Irkutsk
|
561
|
+
RU 13 Asia/Yekaterinburg
|
562
|
+
RU 14 Asia/Irkutsk
|
563
|
+
RU 15 Asia/Anadyr
|
564
|
+
RU 16 Europe/Samara
|
565
|
+
RU 17 Europe/Volgograd
|
566
|
+
RU 18 Asia/Krasnoyarsk
|
567
|
+
RU 20 Asia/Irkutsk
|
568
|
+
RU 21 Europe/Moscow
|
569
|
+
RU 22 Europe/Volgograd
|
570
|
+
RU 23 Europe/Kaliningrad
|
571
|
+
RU 24 Europe/Volgograd
|
572
|
+
RU 25 Europe/Moscow
|
573
|
+
RU 26 Asia/Kamchatka
|
574
|
+
RU 27 Europe/Volgograd
|
575
|
+
RU 28 Europe/Moscow
|
576
|
+
RU 29 Asia/Novokuznetsk
|
577
|
+
RU 30 Asia/Vladivostok
|
578
|
+
RU 31 Asia/Krasnoyarsk
|
579
|
+
RU 32 Asia/Omsk
|
580
|
+
RU 33 Asia/Yekaterinburg
|
581
|
+
RU 34 Asia/Yekaterinburg
|
582
|
+
RU 35 Asia/Yekaterinburg
|
583
|
+
RU 36 Asia/Anadyr
|
584
|
+
RU 37 Europe/Moscow
|
585
|
+
RU 38 Europe/Volgograd
|
586
|
+
RU 39 Asia/Krasnoyarsk
|
587
|
+
RU 40 Asia/Yekaterinburg
|
588
|
+
RU 41 Europe/Moscow
|
589
|
+
RU 42 Europe/Moscow
|
590
|
+
RU 43 Europe/Moscow
|
591
|
+
RU 44 Asia/Magadan
|
592
|
+
RU 45 Europe/Samara
|
593
|
+
RU 46 Europe/Samara
|
594
|
+
RU 47 Europe/Moscow
|
595
|
+
RU 48 Europe/Moscow
|
596
|
+
RU 49 Europe/Moscow
|
597
|
+
RU 50 Asia/Yekaterinburg
|
598
|
+
RU 51 Europe/Moscow
|
599
|
+
RU 52 Europe/Moscow
|
600
|
+
RU 53 Asia/Novosibirsk
|
601
|
+
RU 54 Asia/Omsk
|
602
|
+
RU 55 Europe/Samara
|
603
|
+
RU 56 Europe/Moscow
|
604
|
+
RU 57 Europe/Samara
|
605
|
+
RU 58 Asia/Yekaterinburg
|
606
|
+
RU 59 Asia/Vladivostok
|
607
|
+
RU 60 Europe/Kaliningrad
|
608
|
+
RU 61 Europe/Volgograd
|
609
|
+
RU 62 Europe/Moscow
|
610
|
+
RU 63 Asia/Yakutsk
|
611
|
+
RU 64 Asia/Sakhalin
|
612
|
+
RU 65 Europe/Samara
|
613
|
+
RU 66 Europe/Moscow
|
614
|
+
RU 67 Europe/Samara
|
615
|
+
RU 68 Europe/Volgograd
|
616
|
+
RU 69 Europe/Moscow
|
617
|
+
RU 70 Europe/Volgograd
|
618
|
+
RU 71 Asia/Yekaterinburg
|
619
|
+
RU 72 Europe/Moscow
|
620
|
+
RU 73 Europe/Samara
|
621
|
+
RU 74 Asia/Krasnoyarsk
|
622
|
+
RU 75 Asia/Novosibirsk
|
623
|
+
RU 76 Europe/Moscow
|
624
|
+
RU 77 Europe/Moscow
|
625
|
+
RU 78 Asia/Yekaterinburg
|
626
|
+
RU 79 Asia/Irkutsk
|
627
|
+
RU 80 Asia/Yekaterinburg
|
628
|
+
RU 81 Europe/Samara
|
629
|
+
RU 82 Asia/Irkutsk
|
630
|
+
RU 83 Europe/Moscow
|
631
|
+
RU 84 Europe/Volgograd
|
632
|
+
RU 85 Europe/Moscow
|
633
|
+
RU 86 Europe/Moscow
|
634
|
+
RU 87 Asia/Novosibirsk
|
635
|
+
RU 88 Europe/Moscow
|
636
|
+
RU 89 Asia/Vladivostok
|
637
|
+
UA 01 Europe/Kiev
|
638
|
+
UA 02 Europe/Kiev
|
639
|
+
UA 03 Europe/Uzhgorod
|
640
|
+
UA 04 Europe/Zaporozhye
|
641
|
+
UA 05 Europe/Zaporozhye
|
642
|
+
UA 06 Europe/Uzhgorod
|
643
|
+
UA 07 Europe/Zaporozhye
|
644
|
+
UA 08 Europe/Simferopol
|
645
|
+
UA 09 Europe/Kiev
|
646
|
+
UA 10 Europe/Zaporozhye
|
647
|
+
UA 11 Europe/Simferopol
|
648
|
+
UA 13 Europe/Kiev
|
649
|
+
UA 14 Europe/Zaporozhye
|
650
|
+
UA 15 Europe/Uzhgorod
|
651
|
+
UA 16 Europe/Zaporozhye
|
652
|
+
UA 17 Europe/Simferopol
|
653
|
+
UA 18 Europe/Zaporozhye
|
654
|
+
UA 19 Europe/Kiev
|
655
|
+
UA 20 Europe/Simferopol
|
656
|
+
UA 21 Europe/Kiev
|
657
|
+
UA 22 Europe/Uzhgorod
|
658
|
+
UA 23 Europe/Kiev
|
659
|
+
UA 24 Europe/Uzhgorod
|
660
|
+
UA 25 Europe/Uzhgorod
|
661
|
+
UA 26 Europe/Zaporozhye
|
662
|
+
UA 27 Europe/Kiev
|
663
|
+
UZ 01 Asia/Tashkent
|
664
|
+
UZ 02 Asia/Samarkand
|
665
|
+
UZ 03 Asia/Tashkent
|
666
|
+
UZ 06 Asia/Tashkent
|
667
|
+
UZ 07 Asia/Samarkand
|
668
|
+
UZ 08 Asia/Samarkand
|
669
|
+
UZ 09 Asia/Samarkand
|
670
|
+
UZ 10 Asia/Samarkand
|
671
|
+
UZ 12 Asia/Samarkand
|
672
|
+
UZ 13 Asia/Tashkent
|
673
|
+
UZ 14 Asia/Tashkent
|
674
|
+
TL Asia/Dili
|
675
|
+
PF Pacific/Marquesas
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module GeoLocation
|
2
2
|
@@use = :hostip
|
3
|
-
@@key =
|
4
|
-
@@dev =
|
3
|
+
@@key = nil
|
4
|
+
@@dev = nil
|
5
|
+
@@dev_ip = nil
|
6
|
+
@@timezones = {}
|
5
7
|
|
6
|
-
[:use, :key, :dev].each do |sym|
|
8
|
+
[:use, :key, :dev, :dev_ip, :timezones].each do |sym|
|
7
9
|
class_eval <<-EOS, __FILE__, __LINE__
|
8
10
|
def self.#{sym}
|
9
11
|
if defined?(#{sym.to_s.upcase})
|
@@ -18,4 +20,5 @@ module GeoLocation
|
|
18
20
|
end
|
19
21
|
EOS
|
20
22
|
end
|
23
|
+
|
21
24
|
end
|
data/lib/geo_location/version.rb
CHANGED
data/test/test_geo_location.rb
CHANGED
@@ -1,21 +1,124 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestGeoLocation < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
|
5
|
+
context "on Max Mind" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
GeoLocation::use = :maxmind
|
9
|
+
GeoLocation::dev = 'US,NY,Jamaica,40.676300,-73.775200'
|
10
|
+
GeoLocation::dev_ip = '24.24.24.24'
|
11
|
+
|
12
|
+
@location = GeoLocation.find()
|
13
|
+
end
|
14
|
+
|
15
|
+
should "use Max Mind" do
|
16
|
+
assert_equal :maxmind, GeoLocation::use
|
17
|
+
end
|
18
|
+
|
19
|
+
should "find ip 24.24.24.24" do
|
20
|
+
assert_equal '24.24.24.24', @location[:ip]
|
21
|
+
end
|
22
|
+
|
23
|
+
should "find US country" do
|
24
|
+
assert_equal 'US', @location[:country]
|
25
|
+
end
|
26
|
+
|
27
|
+
should "find NY region" do
|
28
|
+
assert_equal 'NY', @location[:region]
|
29
|
+
end
|
30
|
+
|
31
|
+
should "find Jamaica city" do
|
32
|
+
assert_equal 'Jamaica', @location[:city]
|
33
|
+
end
|
34
|
+
|
35
|
+
should "find latitude 40.676300" do
|
36
|
+
assert_equal '40.676300', @location[:latitude]
|
37
|
+
end
|
38
|
+
|
39
|
+
should "find longitude -73.775200" do
|
40
|
+
assert_equal '-73.775200', @location[:longitude]
|
41
|
+
end
|
42
|
+
|
43
|
+
should "find timezone America/New_York" do
|
44
|
+
assert_equal 'America/New_York', @location[:timezone]
|
45
|
+
end
|
46
|
+
|
8
47
|
end
|
9
48
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
49
|
+
context "on HostIP" do
|
50
|
+
|
51
|
+
setup do
|
52
|
+
GeoLocation::use = :hostip
|
53
|
+
GeoLocation::dev = 'US,NY,Liverpool,43.1059,-76.2099'
|
54
|
+
GeoLocation::dev_ip = '24.24.24.24'
|
55
|
+
|
56
|
+
@location = GeoLocation.find()
|
57
|
+
end
|
58
|
+
|
59
|
+
should "use HostIP" do
|
60
|
+
assert_equal :hostip, GeoLocation::use
|
61
|
+
end
|
62
|
+
|
63
|
+
should "find ip 24.24.24.24" do
|
64
|
+
assert_equal '24.24.24.24', @location[:ip]
|
65
|
+
end
|
66
|
+
|
67
|
+
should "find US country" do
|
68
|
+
assert_equal 'US', @location[:country]
|
69
|
+
end
|
70
|
+
|
71
|
+
should "find NY region" do
|
72
|
+
assert_equal 'NY', @location[:region]
|
73
|
+
end
|
74
|
+
|
75
|
+
should "find Liverpool city" do
|
76
|
+
assert_equal 'Liverpool', @location[:city]
|
77
|
+
end
|
78
|
+
|
79
|
+
should "find latitude 43.1059" do
|
80
|
+
assert_equal '43.1059', @location[:latitude]
|
81
|
+
end
|
82
|
+
|
83
|
+
should "find longitude -76.2099" do
|
84
|
+
assert_equal '-76.2099', @location[:longitude]
|
85
|
+
end
|
86
|
+
|
87
|
+
should "find timezone America/New_York" do
|
88
|
+
assert_equal 'America/New_York', @location[:timezone]
|
89
|
+
end
|
90
|
+
|
14
91
|
end
|
15
92
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
93
|
+
context 'on timezones' do
|
94
|
+
|
95
|
+
setup do
|
96
|
+
GeoLocation::use = :maxmind
|
97
|
+
GeoLocation::dev = 'US,NY,Jamaica,40.676300,-73.775200'
|
98
|
+
GeoLocation::dev_ip = '24.24.24.24'
|
99
|
+
end
|
100
|
+
|
101
|
+
should "find America/Edmonton timezone" do
|
102
|
+
assert_equal 'America/Edmonton', GeoLocation.timezone('CA', 'AB')
|
103
|
+
end
|
104
|
+
|
105
|
+
should "find Europe/London timezone" do
|
106
|
+
assert_equal 'Europe/London', GeoLocation.timezone('GB')
|
107
|
+
end
|
108
|
+
|
109
|
+
should "find Europe/London timezone" do
|
110
|
+
assert_equal 'Europe/London', GeoLocation.timezone('GB')
|
111
|
+
end
|
112
|
+
|
113
|
+
should "find Europe/London timezone" do
|
114
|
+
assert_equal 'Europe/London', GeoLocation.timezone('GB', nil)
|
115
|
+
end
|
116
|
+
|
117
|
+
should "have defined timezones" do
|
118
|
+
GeoLocation.timezone('CA', 'AB')
|
119
|
+
assert_equal false, GeoLocation::timezones.empty?
|
120
|
+
end
|
121
|
+
|
20
122
|
end
|
123
|
+
|
21
124
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Chris Your
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-26 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -49,6 +49,8 @@ files:
|
|
49
49
|
- geo_location.gemspec
|
50
50
|
- lib/geo_location.rb
|
51
51
|
- lib/geo_location/geo_location.rb
|
52
|
+
- lib/geo_location/timezones.rb
|
53
|
+
- lib/geo_location/timezones.txt
|
52
54
|
- lib/geo_location/variables.rb
|
53
55
|
- lib/geo_location/version.rb
|
54
56
|
- test/helper.rb
|