geolocater 0.0.1.alpha → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +13 -0
- data/LICENSE.md +7 -0
- data/README.md +14 -2
- data/lib/geolocater/version.rb +1 -1
- data/spec/geolocater_spec.rb +6 -7
- metadata +14 -12
data/HISTORY.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
HISTORY
|
2
|
+
=======
|
3
|
+
|
4
|
+
0.0.1 - January 11th 2012
|
5
|
+
--------------------------
|
6
|
+
* Refactored the core 'geolocater.rb' lib into 2 methods
|
7
|
+
* Changed core from Module to Class
|
8
|
+
* Wrote simple unit tests - PASSING
|
9
|
+
|
10
|
+
0.0.1.alpha - January 11th 2012
|
11
|
+
--------------------------
|
12
|
+
* Extract code from Rails project
|
13
|
+
* Wrote simple functionality tests - PASSED
|
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2011 Dan Barrett
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -11,6 +11,18 @@ Pass any properly formatted IPv4 address string to a new instance of Geolocater
|
|
11
11
|
|
12
12
|
`Geolocater.ip_lookup(IP_ADDRESS_STRING)`
|
13
13
|
|
14
|
-
###
|
15
|
-
*
|
14
|
+
### Details
|
15
|
+
* This library uses the free (and very good) [freegeoip.net](http://freegeoip.net) REST API.
|
16
|
+
* 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:
|
17
|
+
** `Hashie::Mash.new(Geolocater.ip_lookup(IP_ADDRESS_STRING))`
|
18
|
+
|
19
|
+
### Future Features
|
20
|
+
* Add multiple geolocation services in the event the freegeoip service goes down
|
21
|
+
|
22
|
+
### How You Can Help
|
23
|
+
* Suggest additional tests/refactoring
|
24
|
+
* Submit a pull request
|
25
|
+
|
26
|
+
### Thanks!
|
27
|
+
* <dbarrett83@gmail.com>
|
16
28
|
* [Twitter](http://www.twitter.com/thoughtpunch)
|
data/lib/geolocater/version.rb
CHANGED
data/spec/geolocater_spec.rb
CHANGED
@@ -3,10 +3,6 @@ require 'geolocater'
|
|
3
3
|
|
4
4
|
describe Geolocater do
|
5
5
|
|
6
|
-
before :each do
|
7
|
-
@geolocater = Geolocater.new
|
8
|
-
end
|
9
|
-
|
10
6
|
describe "#ip_lookup" do
|
11
7
|
it "throws an ArgumentError error if no parameters passed" do
|
12
8
|
expect {Geolocater.ip_lookup}.to raise_error(ArgumentError)
|
@@ -23,7 +19,9 @@ describe Geolocater do
|
|
23
19
|
it "should not accept localhost/loopback address" do
|
24
20
|
expect {Geolocater.ip_lookup("127.0.0.1")}.to raise_error(RuntimeError,"Can't lookup localhost address. Please use an external IP address!")
|
25
21
|
end
|
26
|
-
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#geolocate_ip" do
|
27
25
|
it "successfully makes a HTTP request" do
|
28
26
|
expect{Geolocater.ip_lookup("231.4.8.6").success?}.to be_true
|
29
27
|
end
|
@@ -39,7 +37,8 @@ describe Geolocater do
|
|
39
37
|
it "has a value for city" do
|
40
38
|
@result = Geolocater.ip_lookup("123.45.6.28")["city"].should_not be_empty
|
41
39
|
expect {Geolocater.ip_lookup("240.0.0.0")}.to raise_error(RuntimeError,"Incomplete record. Please try another address")
|
42
|
-
end
|
43
|
-
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
44
43
|
end
|
45
44
|
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geolocater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dan Barrett
|
@@ -13,7 +13,7 @@ date: 2012-01-11 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &18430620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *18430620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard
|
27
|
-
requirement: &
|
27
|
+
requirement: &18430160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *18430160
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: faraday
|
38
|
-
requirement: &
|
38
|
+
requirement: &18429680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *18429680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: json
|
49
|
-
requirement: &
|
49
|
+
requirement: &18429220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *18429220
|
58
58
|
description: geolocater is a simple ruby wrapper for the freegeoip.net API
|
59
59
|
email:
|
60
60
|
- dbarrett83@gmail.com
|
@@ -65,6 +65,8 @@ files:
|
|
65
65
|
- .gitignore
|
66
66
|
- .rspec
|
67
67
|
- Gemfile
|
68
|
+
- HISTORY.md
|
69
|
+
- LICENSE.md
|
68
70
|
- README.md
|
69
71
|
- Rakefile
|
70
72
|
- geolocater.gemspec
|
@@ -88,9 +90,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
91
|
none: false
|
90
92
|
requirements:
|
91
|
-
- - ! '
|
93
|
+
- - ! '>='
|
92
94
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
95
|
+
version: '0'
|
94
96
|
requirements: []
|
95
97
|
rubyforge_project: geolocater
|
96
98
|
rubygems_version: 1.8.10
|