ip2whois_ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +2 -0
- data/ip2whois_ruby.gemspec +40 -0
- data/lib/ip2whois_ruby/api.rb +40 -0
- data/lib/ip2whois_ruby/configuration.rb +9 -0
- data/lib/ip2whois_ruby/version.rb +3 -0
- data/lib/ip2whois_ruby.rb +6 -0
- data/spec/ip2whois_ruby_spec.rb +31 -0
- data/spec/spec_helper.rb +15 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6061844b468091282141b0383b96823f3394d5286a706301e652f7710dde0b49
|
4
|
+
data.tar.gz: cb5d9bbeec072deca249277666adc7ddf4c1e6d35b255a9dcaa94b5f4377f0b7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61a6e510320ec0afc87df93864680251979d5a8f7257abcbd64d655a3d24534072750569c88041baf0c4c4467bfa94cdc8636fa33e2afcbbbe7fa0827d417067
|
7
|
+
data.tar.gz: 249e86df86b4ac295f50fd5e74d1f083de7974943bb4295106b909b13d3fe49a45cf78b9ba23ca0fb3564e83e67c750bead01747431990d828bd8ec654538fff
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 IP2WHOIS.com
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
IP2WHOIS Ruby SDK
|
2
|
+
========================
|
3
|
+
This Ruby module enables user to easily implement the checking of WHOIS information for a particular domain into their solution using the API from https://www.ip2whois.com. It is a 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. IP2WHOIS supports the query for [1113 TLDs and 634 ccTLDs](https://www.ip2whois.com/tld-cctld-supported).
|
4
|
+
|
5
|
+
This module requires API key to function. You may sign up for a free API key at https://www.ip2whois.com/register.
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
Usage Example
|
10
|
+
============
|
11
|
+
### Lookup Domain Information
|
12
|
+
|
13
|
+
#### Object Properties
|
14
|
+
|
15
|
+
| Property Name | Property Type | Description |
|
16
|
+
| ------------- | ------------- | ------------------------------------------------------------ |
|
17
|
+
| domain | string | Domain name. |
|
18
|
+
|
19
|
+
```
|
20
|
+
require 'ip2whois_ruby'
|
21
|
+
|
22
|
+
Ip2whoisRuby::Configuration.api_key = 'YOUR_API_KEY'
|
23
|
+
|
24
|
+
result = Ip2whoisRuby::Api.lookup(
|
25
|
+
domain: 'example.com'
|
26
|
+
)
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
### Convert Normal Text to Punycode
|
32
|
+
|
33
|
+
#### Object Properties
|
34
|
+
|
35
|
+
| Property Name | Property Type | Description |
|
36
|
+
| ------------- | :-----------: | ------------------------------------------------------------ |
|
37
|
+
| domain | string | Domain name. |
|
38
|
+
|
39
|
+
```
|
40
|
+
require 'ip2whois_ruby'
|
41
|
+
|
42
|
+
result = Ip2whoisRuby::Api.get_punycode(
|
43
|
+
domain: 'xn--tst-qla.de'
|
44
|
+
)
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
### Convert Punycode to Normal Text
|
50
|
+
|
51
|
+
#### Object Properties
|
52
|
+
|
53
|
+
| Property Name | Property Type | Description |
|
54
|
+
| ------------- | :-----------: | ------------------------------------------------------------ |
|
55
|
+
| domain | string | Domain name. |
|
56
|
+
|
57
|
+
```
|
58
|
+
require 'ip2whois_ruby'
|
59
|
+
|
60
|
+
result = Ip2whoisRuby::Api.get_normal_text(
|
61
|
+
domain: 'täst.de'
|
62
|
+
)
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
LICENCE
|
68
|
+
=====================
|
69
|
+
See the LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "ip2whois_ruby/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "ip2whois_ruby"
|
9
|
+
s.version = Ip2whoisRuby::VERSION
|
10
|
+
s.authors = ["ip2whois"]
|
11
|
+
s.email = ["support@ip2whois.com"]
|
12
|
+
s.summary = "IP2WHOIS Ruby SDK"
|
13
|
+
s.description = "A Ruby SDK enables user to easily implement the checking of WHOIS information for a particular domain into their solution using the API from www.ip2whois.com"
|
14
|
+
s.homepage = "https://github.com/ip2whois/ip2whois-ruby"
|
15
|
+
s.licenses = ["MIT"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"ip2whois_ruby.gemspec",
|
27
|
+
"lib/ip2whois_ruby.rb",
|
28
|
+
"lib/ip2whois_ruby/api.rb",
|
29
|
+
"lib/ip2whois_ruby/configuration.rb",
|
30
|
+
"lib/ip2whois_ruby/version.rb",
|
31
|
+
"spec/spec_helper.rb",
|
32
|
+
"spec/ip2whois_ruby_spec.rb"
|
33
|
+
]
|
34
|
+
|
35
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
36
|
+
s.add_runtime_dependency(%q<simpleidn>, [">= 0.2.1"])
|
37
|
+
else
|
38
|
+
s.add_dependency(%q<simpleidn>, [">= 0.2.1"])
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'simpleidn'
|
4
|
+
require_relative "configuration"
|
5
|
+
require_relative "version"
|
6
|
+
|
7
|
+
module Ip2whoisRuby
|
8
|
+
class Api
|
9
|
+
# Lookup domain WHOIS information.
|
10
|
+
def self.lookup(params = {})
|
11
|
+
if params[:format] == nil
|
12
|
+
params[:format] = 'json'
|
13
|
+
end
|
14
|
+
|
15
|
+
uri = URI.parse("https://api.ip2whois.com/v2?key=" + Ip2whoisRuby::Configuration.api_key + "&format=" + params[:format] + "&domain=" + params[:domain])
|
16
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
17
|
+
http.use_ssl = true
|
18
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
19
|
+
|
20
|
+
response = http.request(request)
|
21
|
+
|
22
|
+
if response == nil
|
23
|
+
return false
|
24
|
+
else
|
25
|
+
return response
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get Punycode.
|
30
|
+
def self.get_punycode(params = {})
|
31
|
+
return SimpleIDN.to_unicode(params[:domain])
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get Normal text.
|
35
|
+
def self.get_normal_text(params = {})
|
36
|
+
return SimpleIDN.to_ascii(params[:domain])
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Ip2whoisRuby" do
|
4
|
+
it "work correctly with domain lookup" do
|
5
|
+
Ip2whoisRuby::Configuration.api_key = $test_api_key
|
6
|
+
result = Ip2whoisRuby::Api.lookup(
|
7
|
+
domain: 'example.c'
|
8
|
+
)
|
9
|
+
data = JSON.parse(result.body)
|
10
|
+
if $test_api_key == 'YOUR_API_KEY'
|
11
|
+
expect(data['error']['error_message']).to eq 'API key not found.'
|
12
|
+
else
|
13
|
+
expect(data['error']['error_message']).to eq 'Invalid domain.'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "work correctly with get punycode" do
|
18
|
+
result = Ip2whoisRuby::Api.get_punycode(
|
19
|
+
domain: 'xn--tst-qla.de'
|
20
|
+
)
|
21
|
+
expect(result).to eq 'täst.de'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "work correctly with get normal text" do
|
25
|
+
result = Ip2whoisRuby::Api.get_normal_text(
|
26
|
+
domain: 'täst.de'
|
27
|
+
)
|
28
|
+
expect(result).to eq 'xn--tst-qla.de'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'ip2whois_ruby'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
$test_api_key = 'YOUR_API_KEY'
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ip2whois_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ip2whois
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: simpleidn
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.1
|
27
|
+
description: A Ruby SDK enables user to easily implement the checking of WHOIS information
|
28
|
+
for a particular domain into their solution using the API from www.ip2whois.com
|
29
|
+
email:
|
30
|
+
- support@ip2whois.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files:
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
files:
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- ip2whois_ruby.gemspec
|
42
|
+
- lib/ip2whois_ruby.rb
|
43
|
+
- lib/ip2whois_ruby/api.rb
|
44
|
+
- lib/ip2whois_ruby/configuration.rb
|
45
|
+
- lib/ip2whois_ruby/version.rb
|
46
|
+
- spec/ip2whois_ruby_spec.rb
|
47
|
+
- spec/spec_helper.rb
|
48
|
+
homepage: https://github.com/ip2whois/ip2whois-ruby
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.7.6.2
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: IP2WHOIS Ruby SDK
|
72
|
+
test_files: []
|