geokit-geoip-provider 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/geokit-geoip-provider.rb +17 -11
- metadata +4 -4
@@ -4,7 +4,7 @@ require 'geoip'
|
|
4
4
|
module Geokit
|
5
5
|
module Geocoders
|
6
6
|
|
7
|
-
# Should be overriden as Geokit::Geocoders::
|
7
|
+
# Should be overriden as Geokit::Geocoders::geo_ip_database in your configuration file
|
8
8
|
@@geo_ip_database = 'REPLACE_WITH_GEOCITY_LOCATION'
|
9
9
|
__define_accessors
|
10
10
|
|
@@ -15,17 +15,23 @@ module Geokit
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.do_geocode(address, options = {})
|
18
|
-
|
18
|
+
city = db.city(address)
|
19
|
+
return GeoLoc.new if not city
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
GeoLoc.new.tap do |gl|
|
22
|
+
gl.provider = 'geoip'
|
23
|
+
gl.city = city.city_name
|
24
|
+
gl.state = city.region_name
|
25
|
+
gl.zip = city.postal_code
|
26
|
+
gl.country_code = city.country_code2
|
27
|
+
gl.lng = city.longitude.to_f
|
28
|
+
gl.lat = city.latitude.to_f
|
29
|
+
gl.success = !!gl.city && !gl.city.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
rescue
|
33
|
+
logger.error "Caught an error during GeoIp geocoding call: "+$!
|
34
|
+
return GeoLoc.new
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jan De Poorter
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-09-
|
19
|
+
date: 2011-09-22 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|