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 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
- geo_str = geo_str.gsub("Latitude:", "")
17
- geo_str = geo_str.gsub("Longitude", "")
18
- geo_str = geo_str.gsub("Area Code", "")
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.1'
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
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class TestSimpleGeoIP < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @random_ip = '173.61.39.60'
6
+ @test_ip = '173.61.39.60'
7
7
  @geo_from_test_ip = ["39.8506", "-74.9099"]
8
8
  end
9
9
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: simple_geoip
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chris Ledet