Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple .ht TLD parser (whois.nic.ht).
- Loading branch information
Showing
7 changed files
with
270 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
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,86 @@ | ||
# | ||
# = 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.ht parser | ||
# | ||
# Parser for the whois.nic.ht 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 WhoisNicHt < Base | ||
|
||
property_supported :status do | ||
@status ||= if content_for_scanner =~ /Status:\s+(.*)\n/ | ||
$1 | ||
end | ||
end | ||
|
||
property_supported :available? do | ||
@available ||= (status == "Not Registered") | ||
end | ||
|
||
property_supported :registered? do | ||
@registered ||= !available? | ||
end | ||
|
||
|
||
property_supported :created_on do | ||
@created_on ||= if content_for_scanner =~ /Created:\s+(.*)\n/ | ||
time = Time.parse($1) | ||
Time.utc(time.year, time.month, time.day) | ||
end | ||
end | ||
|
||
property_supported :updated_on do | ||
@updated_on ||= if content_for_scanner =~ /Modified:\s+(.*)\n/ | ||
time = Time.parse($1) | ||
Time.utc(time.year, time.month, time.day) | ||
end | ||
end | ||
|
||
property_supported :expires_on do | ||
@expires_on ||= if content_for_scanner =~ /Expires:\s+(.*)\n/ | ||
time = Time.parse($1) | ||
Time.utc(time.year, time.month, time.day) | ||
end | ||
end | ||
|
||
|
||
property_supported :nameservers do | ||
@nameservers ||= if content_for_scanner =~ /Name Servers:\n((.+\n)+)\n/ | ||
$1.split("\n").map { |value| value.split(" ").first.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
require 'test_helper' | ||
require 'whois/answer/parser/whois.nic.ht' | ||
|
||
class AnswerParserWhoisNicHtTest < Whois::Answer::Parser::TestCase | ||
|
||
def setup | ||
@klass = Whois::Answer::Parser::WhoisNicHt | ||
@host = "whois.nic.ht" | ||
end | ||
|
||
|
||
def test_status | ||
parser = @klass.new(load_part('/registered.txt')) | ||
expected = "Active" | ||
assert_equal expected, parser.status | ||
assert_equal expected, parser.instance_eval { @status } | ||
|
||
parser = @klass.new(load_part('/available.txt')) | ||
expected = "Not Registered" | ||
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.utc(2004, 6, 18) | ||
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.utc(2010, 5, 20) | ||
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.utc(2011, 6, 18) | ||
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( ns1.google.com ns2.google.com ns3.google.com ns4.google.com ) | ||
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 |
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,23 @@ | ||
TERMS OF USE: 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 Consortium FDS/RDDH as a service to the internet | ||
community on by of Consortium FDS/RDDH. (http://www.nic.ht) | ||
|
||
The data is for information purposes only. Consortium FDS/RDDH 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 Consortium FDS/RDDH it's members (or Consortium FDS/RDDH or member computer systems). The | ||
compilation, repackaging, dissemination or other use of this Data is | ||
expressly prohibited. | ||
|
||
Domain Information | ||
Query: gu34jedzcq.ht | ||
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,59 @@ | ||
TERMS OF USE: 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 Consortium FDS/RDDH as a service to the internet | ||
community on by of Consortium FDS/RDDH. (http://www.nic.ht) | ||
|
||
The data is for information purposes only. Consortium FDS/RDDH 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 Consortium FDS/RDDH it's members (or Consortium FDS/RDDH or member computer systems). The | ||
compilation, repackaging, dissemination or other use of this Data is | ||
expressly prohibited. | ||
|
||
Domain Information | ||
Query: google.ht | ||
Created: 18 Jun 2004 | ||
Expires: 18 Jun 2011 | ||
Modified: 20 May 2010 | ||
Status: Active | ||
Registrar: MarkMonitor | ||
Name Servers: | ||
ns1.google.com | ||
ns2.google.com | ||
ns3.google.com | ||
ns4.google.com | ||
|
||
Registrant: | ||
Google Inc. | ||
Google Inc. | ||
1600 Amphitheatre Parkway | ||
Mountain View, CA 94043 | ||
US | ||
dns-admin@google.com | ||
Voice: +1.6502530000 | ||
Fax: +1.6506188571 | ||
|
||
Administrative Contact: | ||
Google Inc. | ||
Google Inc. | ||
1600 Amphitheatre Parkway | ||
Mountain View, CA 94043 | ||
US | ||
dns-admin@google.com | ||
Voice: +1.6502530000 | ||
Fax: +1.6506188571 | ||
|
||
Technical Contact: | ||
Google Inc. | ||
1600 Amphitheatre Parkway | ||
Mountain View, CA 94043 | ||
US | ||
dns-admin@google.com | ||
Voice: +1.6502530000 | ||
Fax: +1.6506188571 | ||
|
||
|