ip2location_io_ruby 1.0.1 → 1.1.0
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/LICENSE.txt +1 -1
- data/README.md +6 -1
- data/example.rb +9 -1
- data/ip2location_io_ruby.gemspec +10 -0
- data/lib/ip2location_io_ruby/api/hosteddomain.rb +31 -0
- data/lib/ip2location_io_ruby/version.rb +1 -1
- data/lib/ip2location_io_ruby.rb +1 -0
- data/spec/ip2location_io_ruby_domainwhois_spec.rb +3 -3
- data/spec/ip2location_io_ruby_hosteddomain_spec.rb +45 -0
- data/spec/ip2location_io_ruby_ipgeolocation_spec.rb +2 -2
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e28d60000d9d54118d8ef7b325d9edd1bfd7995755587a551c0195e66705bb1e
|
4
|
+
data.tar.gz: 64bc99214843ec4ce09a899ccdec25bfe5c9fffcb73996e0f58d86dad6b2b012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '099a6263fdf55ec3bb463820a139e394140373cc6bde9caa687be4053293ebc19f908d60a8ec3c3be73e887abef6ca743d485d88cdb2f1ce0595521bd899692a'
|
7
|
+
data.tar.gz: 2f4844aae8588f1ab2c526b770b4488c8dca491be597bf2b1207a7dd5b343b562beb582a86da13219eb1be6680b4d9d5c3998f4a706d0d2a9136ab3d2ad82f18
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
[](https://rubygems.org/gems/ip2location_io_ruby)
|
2
|
+
[](https://rubygems.org/gems/ip2location_io_ruby)
|
3
|
+
|
1
4
|
IP2Location.io Ruby SDK
|
2
5
|
========================
|
3
6
|
This Ruby module enables user to query for an enriched data set, such as country, region, district, city, latitude & longitude, ZIP code, time zone, ASN, ISP, domain, net speed, IDD code, area code, weather station data, MNC, MCC, mobile brand, elevation, usage type, address type, advertisement category and proxy data with an IP address. It supports both IPv4 and IPv6 address lookup.
|
4
7
|
|
5
|
-
In addition, this module provides WHOIS lookup
|
8
|
+
In addition, this module provides WHOIS lookup API that helps users to obtain domain information, WHOIS record, by using a domain name. The WHOIS API returns a comprehensive WHOIS data such as creation date, updated date, expiration date, domain age, the contact information of the registrant, mailing address, phone number, email address, nameservers the domain is using and much more.
|
9
|
+
|
10
|
+
There is also a Hosted Domain API that allowing users to get the list of hosted domain names by IP address in real time. The REST API supports both IPv4 and IPv6 address lookup.
|
6
11
|
|
7
12
|
This module requires API key to function. You may sign up for a free API key at https://www.ip2location.io/pricing.
|
8
13
|
|
data/example.rb
CHANGED
@@ -20,4 +20,12 @@ end
|
|
20
20
|
puts IP2LocationIORuby::Api::DomainWhois.get_punycode('täst.de')
|
21
21
|
puts IP2LocationIORuby::Api::DomainWhois.get_normal_text('xn--tst-qla.de')
|
22
22
|
puts IP2LocationIORuby::Api::DomainWhois.get_domain_name('https://www.example.com/exe')
|
23
|
-
puts IP2LocationIORuby::Api::DomainWhois.get_domain_extension('example.com')
|
23
|
+
puts IP2LocationIORuby::Api::DomainWhois.get_domain_extension('example.com')
|
24
|
+
|
25
|
+
begin
|
26
|
+
result = IP2LocationIORuby::Api::HostedDomain.lookup('8.8.8.8')
|
27
|
+
rescue Exception => e
|
28
|
+
puts e.message
|
29
|
+
else
|
30
|
+
puts result.body
|
31
|
+
end
|
data/ip2location_io_ruby.gemspec
CHANGED
@@ -29,12 +29,22 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/ip2location_io_ruby.rb",
|
30
30
|
"lib/ip2location_io_ruby/api.rb",
|
31
31
|
"lib/ip2location_io_ruby/api/domainwhois.rb",
|
32
|
+
"lib/ip2location_io_ruby/api/hosteddomain.rb",
|
32
33
|
"lib/ip2location_io_ruby/api/ipgeolocation.rb",
|
33
34
|
"lib/ip2location_io_ruby/configuration.rb",
|
34
35
|
"lib/ip2location_io_ruby/version.rb",
|
35
36
|
"spec/spec_helper.rb",
|
36
37
|
"spec/ip2location_io_ruby_domainwhois_spec.rb",
|
38
|
+
"spec/ip2location_io_ruby_hosteddomain_spec.rb",
|
37
39
|
"spec/ip2location_io_ruby_ipgeolocation_spec.rb"
|
38
40
|
]
|
41
|
+
if s.respond_to?(:metadata=)
|
42
|
+
s.metadata = {
|
43
|
+
"bug_tracker_uri" => "https://github.com/ip2location/ip2location-io-ruby/issues",
|
44
|
+
"documentation_uri" => "https://www.rubydoc.info/gems/ip2location_io_ruby",
|
45
|
+
"homepage_uri" => "https://www.ip2location.io",
|
46
|
+
"source_code_uri" => "https://github.com/ip2location/ip2location-io-ruby",
|
47
|
+
}
|
48
|
+
end
|
39
49
|
s.add_runtime_dependency "simpleidn", "~> 0.2"
|
40
50
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
require "ip2location_io_ruby/configuration"
|
5
|
+
require "ip2location_io_ruby/version"
|
6
|
+
|
7
|
+
module IP2LocationIORuby
|
8
|
+
module Api
|
9
|
+
class HostedDomain
|
10
|
+
|
11
|
+
# Lookup hosted domains information.
|
12
|
+
def self.lookup(ip, page = 1)
|
13
|
+
uri = URI.parse("https://domains.ip2whois.com/domains?key=" + IP2LocationIORuby::Configuration.api_key + "&format=json&ip=" + ip + "&page=" + page.to_s + "source=sdk-ruby-iplio&source_version=" + IP2LocationIORuby::VERSION)
|
14
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
15
|
+
http.use_ssl = true
|
16
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
17
|
+
|
18
|
+
response = http.request(request)
|
19
|
+
|
20
|
+
if response == nil
|
21
|
+
raise Exception.new "HostedDomain lookup error."
|
22
|
+
elsif JSON[response.body]['error']
|
23
|
+
raise Exception.new JSON[response.body]['error']['error_message']
|
24
|
+
else
|
25
|
+
return response
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/ip2location_io_ruby.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "ip2location_io_ruby/api"
|
2
2
|
require "ip2location_io_ruby/api/ipgeolocation"
|
3
3
|
require "ip2location_io_ruby/api/domainwhois"
|
4
|
+
require "ip2location_io_ruby/api/hosteddomain"
|
4
5
|
require "ip2location_io_ruby/configuration"
|
5
6
|
require "ip2location_io_ruby/version"
|
6
7
|
|
@@ -6,17 +6,17 @@ describe "IP2LocationIORuby" do
|
|
6
6
|
begin
|
7
7
|
IP2LocationIORuby::Api::DomainWhois.lookup('example.c')
|
8
8
|
rescue Exception => e
|
9
|
-
expect(e.message).to eq '
|
9
|
+
expect(e.message).to eq 'API key not found.'
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
it "work correctly with Api Key exist" do
|
14
14
|
if $test_api_key == 'YOUR_API_KEY'
|
15
15
|
print "/*
|
16
|
-
* You could enter a
|
16
|
+
* You could enter a IP2Location.io API Key in spec/spec_helper.rb
|
17
17
|
* for real web service calling test.
|
18
18
|
*
|
19
|
-
* You could sign up for a free API key at https://www.
|
19
|
+
* You could sign up for a free API key at https://www.ip2location.io/pricing
|
20
20
|
* if you do not have one.
|
21
21
|
*/"
|
22
22
|
expect($test_api_key).to eq 'YOUR_API_KEY'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "IP2LocationIORuby" do
|
4
|
+
it "work correctly with invalid Api Key" do
|
5
|
+
IP2LocationIORuby::Configuration.api_key = ''
|
6
|
+
begin
|
7
|
+
IP2LocationIORuby::Api::HostedDomain.lookup('1.1.1')
|
8
|
+
rescue Exception => e
|
9
|
+
expect(e.message).to eq 'Missing parameter.'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "work correctly with Api Key exist" do
|
14
|
+
if $test_api_key == 'YOUR_API_KEY'
|
15
|
+
print "/*
|
16
|
+
* You could enter a IP2Location.io API Key in spec/spec_helper.rb
|
17
|
+
* for real web service calling test.
|
18
|
+
*
|
19
|
+
* You could sign up for a free API key at https://www.ip2location.io/pricing
|
20
|
+
* if you do not have one.
|
21
|
+
*/"
|
22
|
+
expect($test_api_key).to eq 'YOUR_API_KEY'
|
23
|
+
else
|
24
|
+
expect($test_api_key).to_not eq 'YOUR_API_KEY'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "work correctly with lookup hosted domains" do
|
29
|
+
IP2LocationIORuby::Configuration.api_key = $test_api_key
|
30
|
+
if $test_api_key == 'YOUR_API_KEY'
|
31
|
+
begin
|
32
|
+
IP2LocationIORuby::Api::HostedDomain.lookup('1.1.1')
|
33
|
+
rescue Exception => e
|
34
|
+
expect(e.message).to eq 'API key not found.'
|
35
|
+
end
|
36
|
+
else
|
37
|
+
begin
|
38
|
+
result = IP2LocationIORuby::Api::HostedDomain.lookup('1.1.1')
|
39
|
+
rescue Exception => e
|
40
|
+
expect(e.message).to eq 'Invalid IP address.'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -13,10 +13,10 @@ describe "IP2LocationIORuby" do
|
|
13
13
|
it "work correctly with Api Key exist" do
|
14
14
|
if $test_api_key == 'YOUR_API_KEY'
|
15
15
|
print "/*
|
16
|
-
* You could enter a
|
16
|
+
* You could enter a IP2Location.io API Key in spec/spec_helper.rb
|
17
17
|
* for real web service calling test.
|
18
18
|
*
|
19
|
-
* You could sign up for a free API key at https://www.
|
19
|
+
* You could sign up for a free API key at https://www.ip2location.io/pricing
|
20
20
|
* if you do not have one.
|
21
21
|
*/"
|
22
22
|
expect($test_api_key).to eq 'YOUR_API_KEY'
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ip2location_io_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IP2Location
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: simpleidn
|
@@ -45,17 +44,22 @@ files:
|
|
45
44
|
- lib/ip2location_io_ruby.rb
|
46
45
|
- lib/ip2location_io_ruby/api.rb
|
47
46
|
- lib/ip2location_io_ruby/api/domainwhois.rb
|
47
|
+
- lib/ip2location_io_ruby/api/hosteddomain.rb
|
48
48
|
- lib/ip2location_io_ruby/api/ipgeolocation.rb
|
49
49
|
- lib/ip2location_io_ruby/configuration.rb
|
50
50
|
- lib/ip2location_io_ruby/version.rb
|
51
51
|
- spec/ip2location_io_ruby_domainwhois_spec.rb
|
52
|
+
- spec/ip2location_io_ruby_hosteddomain_spec.rb
|
52
53
|
- spec/ip2location_io_ruby_ipgeolocation_spec.rb
|
53
54
|
- spec/spec_helper.rb
|
54
55
|
homepage: https://github.com/ip2location/ip2location-io-ruby
|
55
56
|
licenses:
|
56
57
|
- MIT
|
57
|
-
metadata:
|
58
|
-
|
58
|
+
metadata:
|
59
|
+
bug_tracker_uri: https://github.com/ip2location/ip2location-io-ruby/issues
|
60
|
+
documentation_uri: https://www.rubydoc.info/gems/ip2location_io_ruby
|
61
|
+
homepage_uri: https://www.ip2location.io
|
62
|
+
source_code_uri: https://github.com/ip2location/ip2location-io-ruby
|
59
63
|
rdoc_options: []
|
60
64
|
require_paths:
|
61
65
|
- lib
|
@@ -70,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
74
|
- !ruby/object:Gem::Version
|
71
75
|
version: '0'
|
72
76
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
74
|
-
signing_key:
|
77
|
+
rubygems_version: 3.6.4
|
75
78
|
specification_version: 4
|
76
79
|
summary: IP2Location IO Ruby SDK
|
77
80
|
test_files: []
|