simple_geoip 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -1
- data/lib/simple_geoip.rb +3 -4
- data/simple_geoip.gemspec +1 -1
- data/test/test_basics.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Simple Geo IP
|
2
2
|
Find the geo info by ip address. Dead simple. Uses [nokogiri][nokogiri] against [http://whatismyipaddress.com][whatsmyip]
|
3
3
|
|
4
|
+
# Usage
|
5
|
+
require 'simple_geoip'
|
6
|
+
lat, long = SimpleGeoIP::find_geo '173.61.39.60' # find by ip
|
7
|
+
puts lat, long # prints latitude and longitude
|
4
8
|
|
5
9
|
# Installing
|
6
10
|
|
@@ -19,6 +23,5 @@ Find the geo info by ip address. Dead simple. Uses [nokogiri][nokogiri] against
|
|
19
23
|
# TODO
|
20
24
|
Make an executable so you can run in the command line freely.
|
21
25
|
|
22
|
-
|
23
26
|
[whatsmyip]:http://whatismyipaddress.com
|
24
27
|
[nokogiri]:https://github.com/tenderlove/nokogiri
|
data/lib/simple_geoip.rb
CHANGED
@@ -13,10 +13,9 @@ module SimpleGeoIP
|
|
13
13
|
row = table.content
|
14
14
|
starts = row.index 'Latitude'
|
15
15
|
geo_str = row[starts..-1]
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
geo_str = geo_str.gsub("Postal Code", "")
|
16
|
+
["Latitude:", "Longitude", "Area Code", "Postal Code"].each do |str|
|
17
|
+
geo_str = geo_str.gsub(str, "")
|
18
|
+
end
|
20
19
|
lat, log = geo_str.split(":")
|
21
20
|
[lat, log]
|
22
21
|
end
|
data/simple_geoip.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
## If your rubyforge_project name is different, then edit it and comment out
|
9
9
|
## the sub! line in the Rakefile
|
10
10
|
s.name = 'simple_geoip'
|
11
|
-
s.version = '0.0.
|
11
|
+
s.version = '0.0.2'
|
12
12
|
s.date = '2011-05-30'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
data/test/test_basics.rb
CHANGED