ipligence 0.0.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/ipligence.gemspec +1 -1
- data/lib/ipligence.rb +1 -1
- data/lib/ipligence/client.rb +3 -3
- data/lib/ipligence/db_connection.rb +1 -1
- data/lib/ipligence/utils.rb +1 -1
- data/lib/ipligence/version.rb +2 -2
- data/test/client_test.rb +2 -2
- data/test/utils_test.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e72a6ad6568bffabce2bb9f43793dcd5abaee4df
|
4
|
+
data.tar.gz: 35ba8850a67ac1c5022173c9b39e1064244f7b8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9b87319aa917dca86db468590526cfa08d88228376a342974ce6d7686fe3d7100fa61ecc6749df227c5aace15f12f85b886e97444d5b3b337858719d37edbcb
|
7
|
+
data.tar.gz: 6774ac060d74f77971baeb5919517e2193262f6f1ec071aae9fe803c69080d5d135130c2f1defcc26239bc67e308d86e60380d9c5ddd849b258bfaef6d4aaa15
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# IPligence
|
2
2
|
|
3
3
|
A ruby gem to integrate the [IPligence database](http://ipligence.com/)
|
4
4
|
|
@@ -24,10 +24,10 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
|
27
|
+
After you create the DB you can configure the `IPligence::Client`:
|
28
28
|
|
29
29
|
client =
|
30
|
-
|
30
|
+
IPligence::Client.new(
|
31
31
|
:adapter => "adapter",
|
32
32
|
:host => "host.it.com"
|
33
33
|
:database => "database",
|
@@ -43,13 +43,13 @@ For example, querying for `195.130.124.1` returns the following hash:
|
|
43
43
|
|
44
44
|
=> {:ip_from=>"3280108544", :ip_to=>"3280109567", :country_code=>"GR", :country_name=>"GREECE",
|
45
45
|
:continent_code=>"EU", :continent_name=>"EUROPE", :time_zone=>"GMT+2", :region_code=>"",
|
46
|
-
:region_name=>"", :owner=>"IONIAN UNIVERSITY", :city_name=>"CORFU", :
|
46
|
+
:region_name=>"", :owner=>"IONIAN UNIVERSITY", :city_name=>"CORFU", :county_name=>"",
|
47
47
|
:post_code=>"", :area_code=>"", :metro_code=>"", :latitude=>"39.62", :longitude=>"19.9197"}
|
48
48
|
|
49
49
|
## Contributing
|
50
50
|
|
51
|
-
1. Fork it (https://github.com/DaliaResearch/
|
51
|
+
1. Fork it (https://github.com/DaliaResearch/IPligence/fork)
|
52
52
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
53
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
54
|
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
-
5. Issue a new pull request (https://github.com/DaliaResearch/
|
55
|
+
5. Issue a new pull request (https://github.com/DaliaResearch/IPligence/pulls)
|
data/ipligence.gemspec
CHANGED
@@ -5,7 +5,7 @@ require "ipligence/version"
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "ipligence"
|
8
|
-
spec.version =
|
8
|
+
spec.version = IPligence::VERSION
|
9
9
|
spec.authors = ["Sebastian Komianos, Fernando Guillen"]
|
10
10
|
spec.email = ["sebastian.komianos@daliaresearch.com"]
|
11
11
|
spec.summary = "A ruby gem for the IPligence database"
|
data/lib/ipligence.rb
CHANGED
data/lib/ipligence/client.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require "active_record"
|
2
2
|
|
3
|
-
class
|
3
|
+
class IPligence::Client
|
4
4
|
|
5
5
|
attr_reader :connection
|
6
6
|
|
7
7
|
def initialize(opts)
|
8
|
-
@connection =
|
8
|
+
@connection = IPligence::DBConnection.establish_connection(opts).connection
|
9
9
|
end
|
10
10
|
|
11
11
|
def data(ip)
|
@@ -34,7 +34,7 @@ class Ipligence::Client
|
|
34
34
|
|
35
35
|
private
|
36
36
|
def query(ip)
|
37
|
-
long_ip =
|
37
|
+
long_ip = IPligence::Utils.convert_dotted_to_long(ip).to_s
|
38
38
|
data_fields = "ip_from, ip_to, country_code, country_name, continent_code, continent_name, time_zone, region_code, region_name, owner, city_name, county_name, post_code, area_code, metro_code, latitude, longitude"
|
39
39
|
sql_query = "select #{data_fields} from ipligence2 where ip_from <= '#{long_ip}' and '#{long_ip}' <= ip_to"
|
40
40
|
connection.exec_query(sql_query).first
|
data/lib/ipligence/utils.rb
CHANGED
data/lib/ipligence/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.
|
1
|
+
module IPligence
|
2
|
+
VERSION = "0.1.1"
|
3
3
|
end
|
data/test/client_test.rb
CHANGED
@@ -8,13 +8,13 @@ class ClientTest < MiniTest::Test
|
|
8
8
|
adapter_mock = mock(:connection => "CONNECTION")
|
9
9
|
|
10
10
|
ActiveRecord::Base.expects(:establish_connection).with("OPTS").returns(adapter_mock)
|
11
|
-
client =
|
11
|
+
client = IPligence::Client.new("OPTS")
|
12
12
|
|
13
13
|
assert_equal("CONNECTION", client.connection)
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_data
|
17
|
-
client =
|
17
|
+
client = IPligence::Client.new(:adapter => "sqlite3", :database => "#{File.dirname(__FILE__)}/db/ipligence.sqlite")
|
18
18
|
|
19
19
|
data = client.data("2.84.170.255")
|
20
20
|
assert_equal(39102976, data[:ip_from])
|
data/test/utils_test.rb
CHANGED
@@ -3,10 +3,10 @@ require_relative "test_helper"
|
|
3
3
|
class UtilsTest < MiniTest::Test
|
4
4
|
|
5
5
|
def test_convert_dotted_to_long
|
6
|
-
assert_equal(3232235521,
|
7
|
-
assert_equal(514,
|
8
|
-
assert_equal(0,
|
9
|
-
assert_equal(4294967295,
|
6
|
+
assert_equal(3232235521, IPligence::Utils.convert_dotted_to_long("192.168.0.1"))
|
7
|
+
assert_equal(514, IPligence::Utils.convert_dotted_to_long("0.0.2.2"))
|
8
|
+
assert_equal(0, IPligence::Utils.convert_dotted_to_long("0.0.0.0"))
|
9
|
+
assert_equal(4294967295, IPligence::Utils.convert_dotted_to_long("255.255.255.255"))
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|