Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple .ng TLD parser (whois.nic.net.ng).
- Loading branch information
Showing
7 changed files
with
244 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# | ||
# = Ruby Whois | ||
# | ||
# An intelligent pure Ruby WHOIS client and parser. | ||
# | ||
# | ||
# Category:: Net | ||
# Package:: Whois | ||
# Author:: Simone Carletti <weppos@weppos.net> | ||
# License:: MIT License | ||
# | ||
#-- | ||
# | ||
#++ | ||
|
||
|
||
require 'whois/answer/parser/base' | ||
|
||
|
||
module Whois | ||
class Answer | ||
class Parser | ||
|
||
# | ||
# = whois.nic.net.ng parser | ||
# | ||
# Parser for the whois.nic.net.ng server. | ||
# | ||
# NOTE: This parser is just a stub and provides only a few basic methods | ||
# to check for domain availability and get domain status. | ||
# Please consider to contribute implementing missing methods. | ||
# See WhoisNicIt parser for an explanation of all available methods | ||
# and examples. | ||
# | ||
class WhoisNicNetNg < Base | ||
|
||
property_supported :status do | ||
@status ||= if content_for_scanner =~ /Status:\s+(.+?)\n/ | ||
case $1.downcase | ||
when "active" then :registered | ||
when "not registered" then :available | ||
else | ||
Whois.bug!(ParserError, "Unknown status `#{$1}'.") | ||
end | ||
else | ||
Whois.bug!(ParserError, "Unable to parse status.") | ||
end | ||
end | ||
|
||
property_supported :available? do | ||
@available ||= (status == :available) | ||
end | ||
|
||
property_supported :registered? do | ||
@registered ||= !available? | ||
end | ||
|
||
|
||
property_supported :created_on do | ||
@created_on ||= if content_for_scanner =~ /Created:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_supported :updated_on do | ||
@updated_on ||= if content_for_scanner =~ /Modified:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_supported :expires_on do | ||
@expires_on ||= if content_for_scanner =~ /Expires:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
|
||
property_supported :nameservers do | ||
@nameservers ||= if content_for_scanner =~ /Name Servers:\n((.+\n)+)\n/ | ||
$1.split("\n").map { |value| value.strip.downcase } | ||
else | ||
[] | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<br/> | ||
<b>TERMS OF USE:</b> You are not authorized to access or query our Whois database through the use of electronic processes that are high-volume and automated. Whois database is provided by NIRA as a service to the internet community. <br/><br/>The data is for information purposes only. NIRA does not guarantee its accuracy. By submitting a Whois query, you agree to abide by the following terms of use: You agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to NIRA or NIRA Accredited Registrars and their computer systems. The compilation, repackaging, dissemination or other use of this Data is expressly prohibited. | ||
|
||
Domain Information | ||
Query: u34jedzcq.ng | ||
Status: Not Registered | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<br/> | ||
<b>TERMS OF USE:</b> You are not authorized to access or query our Whois database through the use of electronic processes that are high-volume and automated. Whois database is provided by NIRA as a service to the internet community. <br/><br/>The data is for information purposes only. NIRA does not guarantee its accuracy. By submitting a Whois query, you agree to abide by the following terms of use: You agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to NIRA or NIRA Accredited Registrars and their computer systems. The compilation, repackaging, dissemination or other use of this Data is expressly prohibited. | ||
|
||
Domain Information | ||
Query: nic.net.ng | ||
Status: Active | ||
Created: 13 May 2009 15:27 WAT | ||
Modified: 02 Jul 2010 20:06 WAT | ||
Expires: 31 Jul 2020 00:00 WAT | ||
Name Servers: | ||
rns1.nic.net.ng | ||
rns2.nic.net.ng | ||
rns3.nic.net.ng | ||
rns4.nic.net.ng | ||
|
||
Registrar Information | ||
Registrar Name: nira | ||
Country: NG | ||
|
||
|
||
|
||
|
||
Registrant: | ||
Organisation: Nigeria Internet Registration Association (NIRA) | ||
Address: | ||
9 Kofo Abayomi Street | ||
Victoria Island | ||
Lagos, Lagos, Nigeria P O Box 1088 Yaba | ||
NG | ||
Email Address: ugo@nira.org.ng | ||
|
||
|
||
Admin Contact: | ||
Organisation: Nigeria Internet Registration Association (NIRA) | ||
Address: | ||
9 Kofo Abayomi Street | ||
Victoria Island | ||
Lagos, Lagos, Nigeria P O Box 1088 Yaba | ||
NG | ||
Email Address: ugo@nira.org.ng | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
require 'test_helper' | ||
require 'whois/answer/parser/whois.nic.net.ng' | ||
|
||
class AnswerParserWhoisNicNetNgTest < Whois::Answer::Parser::TestCase | ||
|
||
def setup | ||
@klass = Whois::Answer::Parser::WhoisNicNetNg | ||
@host = "whois.nic.net.ng" | ||
end | ||
|
||
|
||
def test_status | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = :registered | ||
assert_equal expected, parser.status | ||
assert_equal expected, parser.instance_eval { @status } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = :available | ||
assert_equal expected, parser.status | ||
assert_equal expected, parser.instance_eval { @status } | ||
end | ||
|
||
def test_available? | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = false | ||
assert_equal expected, parser.available? | ||
assert_equal expected, parser.instance_eval { @available } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = true | ||
assert_equal expected, parser.available? | ||
assert_equal expected, parser.instance_eval { @available } | ||
end | ||
|
||
def test_registered? | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = true | ||
assert_equal expected, parser.registered? | ||
assert_equal expected, parser.instance_eval { @registered } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = false | ||
assert_equal expected, parser.registered? | ||
assert_equal expected, parser.instance_eval { @registered } | ||
end | ||
|
||
|
||
def test_created_on | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = Time.parse("2009-05-13 15:27 WAT") | ||
assert_equal expected, parser.created_on | ||
assert_equal expected, parser.instance_eval { @created_on } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = nil | ||
assert_equal expected, parser.created_on | ||
assert_equal expected, parser.instance_eval { @created_on } | ||
end | ||
|
||
def test_updated_on | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = Time.parse("2010-07-02 20:06 WAT") | ||
assert_equal expected, parser.updated_on | ||
assert_equal expected, parser.instance_eval { @updated_on } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = nil | ||
assert_equal expected, parser.updated_on | ||
assert_equal expected, parser.instance_eval { @updated_on } | ||
end | ||
|
||
def test_expires_on | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = Time.parse("2020-07-31 00:00 WAT") | ||
assert_equal expected, parser.expires_on | ||
assert_equal expected, parser.instance_eval { @expires_on } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = nil | ||
assert_equal expected, parser.expires_on | ||
assert_equal expected, parser.instance_eval { @expires_on } | ||
end | ||
|
||
|
||
def test_nameservers | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = %w( rns1.nic.net.ng rns2.nic.net.ng rns3.nic.net.ng rns4.nic.net.ng ) | ||
assert_equal expected, parser.nameservers | ||
assert_equal expected, parser.instance_eval { @nameservers } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = %w() | ||
assert_equal expected, parser.nameservers | ||
assert_equal expected, parser.instance_eval { @nameservers } | ||
end | ||
|
||
end |