Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

rename to Geolocator

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

0 comments on commit 7ffb9b0

Please sign in to comment.
Something went wrong with that request. Please try again.