geo_location 0.1.3 → 0.1.4

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/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
- # Max Mind (paid)
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
- # GeoLocation::use = :maxmind
22
- # GeoLocation::key = 'YOUR MaxMind.COM LICENSE KEY'
23
- # GeoLocation::test = 'US,NY,Jamaica,40.676300,-73.775200' # Use this location while you test
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] # => Sugar Grove
32
- puts ip[:region] # => IL
33
- puts ip[:country] # => UNITED STATES
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.3
1
+ 0.1.4
data/geo_location.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{geo_location}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
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"]
@@ -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::test.nil? || GeoLocation::test.empty?
23
- puts "WARNING: GeoLocation is using the test location: #{GeoLocation::test}"
24
- location = GeoLocation::test.split(',')
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)
@@ -1,9 +1,9 @@
1
1
  module GeoLocation
2
2
  @@use = :hostip
3
3
  @@key = ''
4
- @@test = ''
4
+ @@dev = ''
5
5
 
6
- [:use, :key, :test].each do |sym|
6
+ [:use, :key, :dev].each do |sym|
7
7
  class_eval <<-EOS, __FILE__, __LINE__
8
8
  def self.#{sym}
9
9
  if defined?(#{sym.to_s.upcase})
@@ -1,3 +1,3 @@
1
1
  module GeoLocation
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Chris Your