geo_location 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +32 -12
- data/VERSION +1 -1
- data/geo_location.gemspec +1 -1
- data/lib/geo_location/geo_location.rb +3 -3
- data/lib/geo_location/variables.rb +2 -2
- data/lib/geo_location/version.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -8,30 +8,50 @@ Geo Locate your users using their IP address via hostip.info or maxmind.com.
|
|
8
8
|
gem install geo_location
|
9
9
|
|
10
10
|
|
11
|
-
== Configuration
|
11
|
+
== HostIP Configuration
|
12
12
|
|
13
13
|
config/initializers/geo_location_config.rb:
|
14
14
|
|
15
15
|
unless GeoLocation == nil
|
16
|
-
# Hostip (free)
|
16
|
+
# Use Hostip (free)
|
17
17
|
GeoLocation::use = :hostip
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
== HostIP Example
|
22
|
+
|
23
|
+
ip = GeoLocation.find('24.24.24.24') # => {:city=>"Liverpool", :region=>"NY", :country=>"US", :latitude=>"43.1059", :longitude=>"-76.2099"}
|
24
|
+
|
25
|
+
puts ip[:city] # => Liverpool
|
26
|
+
puts ip[:region] # => NY
|
27
|
+
puts ip[:country] # => US
|
28
|
+
puts ip[:latitude] # => 43.1059
|
29
|
+
puts ip[:longitude] # => -76.2099
|
30
|
+
|
18
31
|
|
19
|
-
|
32
|
+
== Max Mind Configuration
|
33
|
+
|
34
|
+
config/initializers/geo_location_config.rb:
|
35
|
+
|
36
|
+
unless GeoLocation == nil
|
37
|
+
# Use Max Mind (paid)
|
20
38
|
# For more information visit: http://www.maxmind.com/app/city
|
21
|
-
|
22
|
-
|
23
|
-
#
|
39
|
+
GeoLocation::use = :maxmind
|
40
|
+
GeoLocation::key = 'YOUR MaxMind.COM LICENSE KEY'
|
41
|
+
# This location will be used while you develop rather than hitting the maxmind.com api
|
42
|
+
# GeoLocation::dev = 'US,NY,Jamaica,40.676300,-73.775200' # IP: 24.24.24.24
|
24
43
|
end
|
25
44
|
|
26
45
|
|
27
|
-
== Example
|
46
|
+
== Max Mind Example
|
28
47
|
|
48
|
+
GeoLocation::use = :maxmind
|
49
|
+
GeoLocation::key = 'YOUR MaxMind.COM LICENSE KEY'
|
29
50
|
ip = GeoLocation.find('24.24.24.24') # => {:city=>"Jamaica", :region=>"NY", :country=>"US", :latitude=>"40.676300", :longitude=>"-73.775200"}
|
30
|
-
|
31
|
-
puts ip[:city] # =>
|
32
|
-
puts ip[:region] # =>
|
33
|
-
puts ip[:country] # =>
|
34
|
-
puts ip[:country_code] # => US
|
51
|
+
|
52
|
+
puts ip[:city] # => Jamaica
|
53
|
+
puts ip[:region] # => NY
|
54
|
+
puts ip[:country] # => US
|
35
55
|
puts ip[:latitude] # => 40.676300
|
36
56
|
puts ip[:longitude] # => -73.775200
|
37
57
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/geo_location.gemspec
CHANGED
@@ -19,9 +19,9 @@ module GeoLocation
|
|
19
19
|
# US,NY,Jamaica,40.676300,-73.775200
|
20
20
|
|
21
21
|
def maxmind(ip)
|
22
|
-
unless GeoLocation::
|
23
|
-
puts "WARNING: GeoLocation is using the
|
24
|
-
location = GeoLocation::
|
22
|
+
unless GeoLocation::dev.nil? || GeoLocation::dev.empty?
|
23
|
+
puts "WARNING: GeoLocation is using the dev location: #{GeoLocation::dev}"
|
24
|
+
location = GeoLocation::dev.split(',')
|
25
25
|
else
|
26
26
|
url = "http://geoip3.maxmind.com/b?l=#{GeoLocation::key}&i=#{ip}"
|
27
27
|
uri = URI.parse(url)
|
data/lib/geo_location/version.rb
CHANGED