Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rename to Geolocator

  • Loading branch information...
commit 7ffb9b04c9aec87ba686e82079ea12522089b7a9 1 parent a8846fc
@jhsu jhsu authored
View
2  Gemfile
@@ -1,4 +1,4 @@
source "http://rubygems.org"
-# Specify your gem's dependencies in geolocater.gemspec
+# Specify your gem's dependencies in geolocator.gemspec
gemspec
View
2  HISTORY.md
@@ -3,7 +3,7 @@ HISTORY
0.0.1 - January 11th 2012
--------------------------
-* Refactored the core 'geolocater.rb' lib into 2 methods
+* Refactored the core 'geolocator.rb' lib into 2 methods
* Changed core from Module to Class
* Wrote simple unit tests - PASSING
View
10 README.md
@@ -1,15 +1,15 @@
-Geolocater
+Geolocator
==========
Yet Another IP Geolocation Gem for Fun and Profit!
--------------------------------------------------
### Installation
-`gem install geolocater`
+`gem install geolocator`
### Usage
-Pass any properly formatted IPv4 address string to a new instance of Geolocater like so.
+Pass any properly formatted IPv4 address string to a new instance of Geolocator like so.
-`Geolocater.ip_lookup(IP_ADDRESS_STRING)`
+`Geolocator.ip_lookup(IP_ADDRESS_STRING)`
and get back a JSON Hash of the results
@@ -22,7 +22,7 @@ and get back a JSON Hash of the results
* This library uses the free (and very good) [freegeoip.net](http://freegeoip.net) REST API.
* Results are returned in JSON format. For friendlier Ruby object-like results (and better nil handling), pipe the result hash into a new [Hashie::Mash](https://github.com/intridea/hashie) like so:
-`Hashie::Mash.new(Geolocater.ip_lookup(IP_ADDRESS_STRING))`
+`Hashie::Mash.new(Geolocator.ip_lookup(IP_ADDRESS_STRING))`
### Future Features
* Add multiple geolocation services in the event the freegeoip service goes down
View
10 geolocater.gemspec → geolocator.gemspec
@@ -1,18 +1,18 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
-require "geolocater/version"
+require "geolocator/version"
Gem::Specification.new do |s|
- s.name = "geolocater"
+ s.name = "geolocator"
s.license = 'MIT'
- s.version = Geolocater::VERSION
+ s.version = Geolocator::VERSION
s.authors = ["Dan Barrett"]
s.email = ["dbarrett83@gmail.com"]
s.homepage = "http://www.about.me/thoughtpunch"
s.summary = "Yet Another IP Geolocation Gem"
- s.description = "geolocater is a simple ruby wrapper for the freegeoip.net API"
+ s.description = "geolocator is a simple ruby wrapper for the freegeoip.net API"
- s.rubyforge_project = "geolocater"
+ s.rubyforge_project = "geolocator"
s.required_ruby_version = '>= 1.9.0'
s.files = `git ls-files`.split("\n")
View
4 lib/geolocater.rb → lib/geolocator.rb
@@ -1,8 +1,8 @@
-require "geolocater/version"
+require "geolocator/version"
require 'faraday'
require 'json'
-class Geolocater
+class Geolocator
class << self
View
2  lib/geolocater/version.rb → lib/geolocator/version.rb
@@ -1,3 +1,3 @@
-class Geolocater
+class Geolocator
VERSION = "0.0.1"
end
View
22 spec/geolocater_spec.rb → spec/geolocator_spec.rb
@@ -1,42 +1,42 @@
require 'spec_helper'
-require 'geolocater'
+require 'geolocator'
-describe Geolocater do
+describe Geolocator do
describe "#ip_lookup" do
it "throws an ArgumentError error if no parameters passed" do
- expect {Geolocater.ip_lookup}.to raise_error(ArgumentError)
+ expect {Geolocator.ip_lookup}.to raise_error(ArgumentError)
end
it "throws an ArgumentError error if more than one parameter passed" do
- expect {Geolocater.ip_lookup("sdfsdf","sdfsadf")}.to raise_error(ArgumentError)
+ expect {Geolocator.ip_lookup("sdfsdf","sdfsadf")}.to raise_error(ArgumentError)
end
it "only accepts input that passes a basic IP regex" do
- expect {Geolocater.ip_lookup("sdfsadfsdf")}.to raise_error(RuntimeError,"Not a valid IPv4 address")
+ expect {Geolocator.ip_lookup("sdfsadfsdf")}.to raise_error(RuntimeError,"Not a valid IPv4 address")
end
it "should not accept localhost/loopback address" do
- expect {Geolocater.ip_lookup("127.0.0.1")}.to raise_error(RuntimeError,"Can't lookup localhost address. Please use an external IP address!")
+ expect {Geolocator.ip_lookup("127.0.0.1")}.to raise_error(RuntimeError,"Can't lookup localhost address. Please use an external IP address!")
end
end
describe "#geolocate_ip" do
it "successfully makes a HTTP request" do
- expect{Geolocater.ip_lookup("231.4.8.6").success?}.to be_true
+ expect{Geolocator.ip_lookup("231.4.8.6").success?}.to be_true
end
it "throws an error for HTTP statuses other than 200" do
- expect {Geolocater.ip_lookup("0.0.0.0")}.to raise_error(RuntimeError,"IP address not found")
+ expect {Geolocator.ip_lookup("0.0.0.0")}.to raise_error(RuntimeError,"IP address not found")
end
it "parses the HTTP body with JSON" do
- Geolocater.ip_lookup("123.45.6.28").should be_an_instance_of Hash
+ Geolocator.ip_lookup("123.45.6.28").should be_an_instance_of Hash
end
it "has a value for city" do
- @result = Geolocater.ip_lookup("123.45.6.28")["city"].should_not be_empty
- expect {Geolocater.ip_lookup("240.0.0.0")}.to raise_error(RuntimeError,"Incomplete record. Please try another address")
+ @result = Geolocator.ip_lookup("123.45.6.28")["city"].should_not be_empty
+ expect {Geolocator.ip_lookup("240.0.0.0")}.to raise_error(RuntimeError,"Incomplete record. Please try another address")
end
end
View
2  spec/spec_helper.rb
@@ -1,3 +1,3 @@
require 'rubygems'
-require 'geolocater'
+require 'geolocator'
Please sign in to comment.
Something went wrong with that request. Please try again.