ipinfodb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -1
- data/Gemfile +1 -1
- data/LICENSE +22 -0
- data/README.md +39 -0
- data/Rakefile +9 -2
- data/ipinfodb.gemspec +19 -17
- data/lib/ipinfodb.rb +2 -27
- data/lib/ipinfodb/lookup.rb +27 -0
- data/lib/ipinfodb/version.rb +3 -0
- data/test/ipinfodb_test.rb +13 -5
- data/test/test_helper.rb +1 -3
- metadata +54 -61
- data/README +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0de6a6cf73b499bbeef0278070857a65ff7d63aa
|
4
|
+
data.tar.gz: e14ec2ed5f83430817c191b4878eae5f09c481e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 531375d8c8ef74c70d38725b2c983e3988e1e7d3f7f1e57cf14edd573fe4b61b6a6a06ba7e98b8a4107b9fc255ad7b2fd21a150bf13df5257d36cacbb6529b8b
|
7
|
+
data.tar.gz: 0367734fdf94602c8f8cdcb5456df1975847d6f3556ea1f959f42c46655143b9412a67ca2c5365b3e0dfba86d6e91880b234fd26cde6008a0d2f73e41be30025
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright © 2011-2013 Tomasz Mazur
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# ipinfodb
|
2
|
+
|
3
|
+
Ruby gem for IP address geolocation via API calls to [IPInfoDB.com](http://ipinfodb.com/).
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```
|
9
|
+
gem install ipinfodb
|
10
|
+
```
|
11
|
+
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Ipinfodb.api_key = "your_api_key_here"
|
17
|
+
Ipinfodb.lookup('153.19.48.1')
|
18
|
+
```
|
19
|
+
|
20
|
+
You will receive the following `Hash` as a response (for successful lookups):
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
{
|
24
|
+
"statusCode" : "OK",
|
25
|
+
"statusMessage" : "",
|
26
|
+
"ipAddress" : "153.19.48.1",
|
27
|
+
"countryCode" : "PL",
|
28
|
+
"countryName" : "POLAND"
|
29
|
+
}
|
30
|
+
```
|
31
|
+
|
32
|
+
|
33
|
+
## Running tests
|
34
|
+
|
35
|
+
```
|
36
|
+
IPINFODB_API_KEY=<apikey> rake test
|
37
|
+
```
|
38
|
+
|
39
|
+
Copyright © 2011-2013 Tomasz Mazur, released under the MIT license
|
data/Rakefile
CHANGED
data/ipinfodb.gemspec
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require
|
3
|
+
require 'ipinfodb/version'
|
4
4
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "ipinfodb"
|
7
|
+
gem.version = Ipinfodb::VERSION
|
8
|
+
gem.platform = Gem::Platform::RUBY
|
9
|
+
gem.authors = ["Tomasz Mazur", "Paweł Gościcki"]
|
10
|
+
gem.email = ["defkode@gmail.com", "pawel.goscicki@gmail.com"]
|
11
|
+
gem.homepage = "http://ipinfodb.com"
|
12
|
+
gem.summary = %q{Free IP address geolocation tools}
|
13
|
+
gem.description = %q{Free IP address geolocation tools}
|
14
14
|
|
15
|
-
|
15
|
+
gem.rubyforge_project = "ipinfodb"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
gem.files = `git ls-files`.split("\n")
|
18
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
|
22
|
+
gem.add_dependency('httparty', '~> 0.6')
|
23
|
+
|
24
|
+
gem.add_development_dependency('rake')
|
23
25
|
end
|
data/lib/ipinfodb.rb
CHANGED
@@ -1,28 +1,3 @@
|
|
1
1
|
require 'httparty'
|
2
|
-
|
3
|
-
|
4
|
-
VERSION = '0.0.1'
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_accessor :api_key
|
8
|
-
end
|
9
|
-
|
10
|
-
include HTTParty
|
11
|
-
|
12
|
-
base_uri "api.ipinfodb.com"
|
13
|
-
|
14
|
-
def self.lookup(ip)
|
15
|
-
params = {
|
16
|
-
:output => "json",
|
17
|
-
:key => api_key,
|
18
|
-
:ip => ip
|
19
|
-
}
|
20
|
-
|
21
|
-
body = get("/v2/ip_query_country.php", :query => params).parsed_response
|
22
|
-
if body["Status"] == "OK"
|
23
|
-
body
|
24
|
-
else
|
25
|
-
raise ArgumentError, body["Status"]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
2
|
+
require 'ipinfodb/version'
|
3
|
+
require 'ipinfodb/lookup'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ipinfodb
|
2
|
+
|
3
|
+
class << self
|
4
|
+
attr_accessor :api_key
|
5
|
+
end
|
6
|
+
|
7
|
+
include HTTParty
|
8
|
+
|
9
|
+
base_uri 'api.ipinfodb.com'
|
10
|
+
|
11
|
+
def self.lookup(ip)
|
12
|
+
params = {
|
13
|
+
:format => 'json',
|
14
|
+
:key => api_key,
|
15
|
+
:ip => ip
|
16
|
+
}
|
17
|
+
|
18
|
+
body = get('/v3/ip-country/', :query => params).parsed_response
|
19
|
+
|
20
|
+
if body['statusCode'] == 'OK'
|
21
|
+
body
|
22
|
+
else
|
23
|
+
raise ArgumentError, body['statusMessage']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/test/ipinfodb_test.rb
CHANGED
@@ -2,10 +2,6 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class IpinfodbTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
# def setup
|
6
|
-
# Ipinfodb.api_key = nil
|
7
|
-
# end
|
8
|
-
|
9
5
|
def test_invalid_api_key
|
10
6
|
assert_raise ArgumentError, "INVALID API KEY" do
|
11
7
|
Ipinfodb.api_key = "xxx"
|
@@ -21,10 +17,22 @@ class IpinfodbTest < Test::Unit::TestCase
|
|
21
17
|
|
22
18
|
def test_valid_api_key
|
23
19
|
puts "IPINFODB_API_KEY=<your_api_key> required to run this test" unless ENV["IPINFODB_API_KEY"]
|
20
|
+
|
24
21
|
assert_nothing_raised do
|
25
22
|
Ipinfodb.api_key = ENV["IPINFODB_API_KEY"]
|
26
23
|
Ipinfodb.lookup("127.0.0.1")
|
27
24
|
end
|
28
25
|
end
|
29
|
-
|
26
|
+
|
27
|
+
def test_geolocation
|
28
|
+
puts "IPINFODB_API_KEY=<your_api_key> required to run this test" unless ENV["IPINFODB_API_KEY"]
|
29
|
+
|
30
|
+
Ipinfodb.api_key = ENV['IPINFODB_API_KEY']
|
31
|
+
response = Ipinfodb.lookup('153.19.48.1')
|
32
|
+
|
33
|
+
assert_equal 'OK', response['statusCode']
|
34
|
+
assert_equal 'POLAND', response['countryName']
|
35
|
+
assert_equal 'PL', response['countryCode']
|
36
|
+
end
|
37
|
+
|
30
38
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,91 +1,84 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipinfodb
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Tomasz Mazur
|
8
|
+
- Paweł Gościcki
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: httparty
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
27
18
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 6
|
33
|
-
version: "0.6"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.6'
|
34
21
|
type: :runtime
|
35
|
-
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.6'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
36
42
|
description: Free IP address geolocation tools
|
37
|
-
email:
|
43
|
+
email:
|
38
44
|
- defkode@gmail.com
|
45
|
+
- pawel.goscicki@gmail.com
|
39
46
|
executables: []
|
40
|
-
|
41
47
|
extensions: []
|
42
|
-
|
43
48
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
49
|
+
files:
|
46
50
|
- .gitignore
|
47
51
|
- Gemfile
|
48
|
-
-
|
49
|
-
- README
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
50
54
|
- Rakefile
|
51
55
|
- ipinfodb.gemspec
|
52
56
|
- lib/ipinfodb.rb
|
57
|
+
- lib/ipinfodb/lookup.rb
|
58
|
+
- lib/ipinfodb/version.rb
|
53
59
|
- test/ipinfodb_test.rb
|
54
60
|
- test/test_helper.rb
|
55
|
-
has_rdoc: true
|
56
61
|
homepage: http://ipinfodb.com
|
57
62
|
licenses: []
|
58
|
-
|
63
|
+
metadata: {}
|
59
64
|
post_install_message:
|
60
65
|
rdoc_options: []
|
61
|
-
|
62
|
-
require_paths:
|
66
|
+
require_paths:
|
63
67
|
- lib
|
64
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ">="
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
hash: 3
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
version: "0"
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
82
78
|
requirements: []
|
83
|
-
|
84
79
|
rubyforge_project: ipinfodb
|
85
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 2.1.5
|
86
81
|
signing_key:
|
87
|
-
specification_version:
|
82
|
+
specification_version: 4
|
88
83
|
summary: Free IP address geolocation tools
|
89
|
-
test_files:
|
90
|
-
- test/ipinfodb_test.rb
|
91
|
-
- test/test_helper.rb
|
84
|
+
test_files: []
|
data/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
IPINFODB_API_KEY=<apikey> rake test
|