Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple .in.ua TLD parser (whois.in.ua). It seems that .in.ua is…
… handled separately from .ua.
- Loading branch information
Showing
11 changed files
with
261 additions
and
1 deletion.
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,77 @@ | |||
# | |||
# = 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.in.ua parser | |||
# | |||
# Parser for the whois.in.ua 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 WhoisInUa < Base | |||
|
|||
property_supported :status do | |||
@status ||= if content_for_scanner =~ /status:\s+(.*)\n/ | |||
$1.split("-").first | |||
end | |||
end | |||
|
|||
property_supported :available? do | |||
@available ||= !!(content_for_scanner =~ /No entries found for domain/) | |||
end | |||
|
|||
property_supported :registered? do | |||
@registered ||= !available? | |||
end | |||
|
|||
|
|||
property_not_supported :created_on | |||
|
|||
property_supported :updated_on do | |||
@updated_on ||= if content_for_scanner =~ /changed:\s+(.*)\n/ | |||
time = $1.split(" ").last | |||
DateTime.strptime(time, "%Y%m%d%H%M%S").to_time | |||
end | |||
end | |||
|
|||
property_supported :expires_on do | |||
@expires_on ||= if content_for_scanner =~ /status:\s+(.*)\n/ | |||
time = $1.split(" ").last | |||
DateTime.strptime(time, "%Y%m%d%H%M%S").to_time | |||
end | |||
end | |||
|
|||
|
|||
property_supported :nameservers do | |||
@nameservers ||= content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map { |value| value.strip.downcase } | |||
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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,91 @@ | |||
require 'test_helper' | |||
require 'whois/answer/parser/whois.net.ua' | |||
|
|||
class AnswerParserWhoisNetUaTest < Whois::Answer::Parser::TestCase | |||
|
|||
def setup | |||
@klass = Whois::Answer::Parser::WhoisNetUa | |||
@host = "whois.net.ua" | |||
end | |||
|
|||
|
|||
def test_status | |||
parser = @klass.new(load_part('/registered.txt')) | |||
expected = "OK" | |||
assert_equal expected, parser.status | |||
assert_equal expected, parser.instance_eval { @status } | |||
|
|||
parser = @klass.new(load_part('/available.txt')) | |||
expected = nil | |||
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 | |||
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/registered.txt')).created_on } | |||
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/available.txt')).created_on } | |||
end | |||
|
|||
def test_updated_on | |||
parser = @klass.new(load_part('/registered.txt')) | |||
expected = Time.utc(2010, 02, 14, 22, 22, 14) | |||
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, 02, 14) | |||
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('/property_nameservers_with_trailing_space.txt')) | |||
expected = %w( ns10.uadns.com ns11.uadns.com ns12.uadns.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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
% In.UA whois server. (whois.in.ua) | |||
% All questions regarding this service please send to help@whois.in.ua | |||
% To search for domains and In.UA maintainers using the web, visit http://whois.in.ua | |||
% No records found for object U34JEDZCQ.IN.UA |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
% In.UA whois server. (whois.in.ua) | |||
% All questions regarding this service please send to help@whois.in.ua | |||
% To search for domains and In.UA maintainers using the web, visit http://whois.in.ua | |||
domain: darite.in.ua | |||
descr: darite.in.ua | |||
admin-c: CP91-UANIC | |||
tech-c: NIC-UANIC | |||
status: OK-UNTIL 20110214000000 | |||
nserver: NS10.UADNS.COM | |||
nserver: NS11.UADNS.COM | |||
nserver: NS12.UADNS.COM | |||
mnt-by: DRS-MNT-INUA | |||
mnt-lower: UA-NIC-MNT-INUA | |||
changed: support@drs.ua 20100214222214 | |||
source: INUA | |||
|
29 changes: 29 additions & 0 deletions
29
test/testcases/responses/whois.net.ua/property_nameservers_uppercase.txt
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
% This is the Ukrainian Whois query server #B. | |||
% Rights restricted by copyright. | |||
% | |||
|
|||
% The object shown below is NOT in the UANIC database. | |||
% It has been obtained by querying a remote server: | |||
% (whois.in.ua) at port 43. | |||
% | |||
% REDIRECT BEGIN | |||
|
|||
% In.UA whois server. (whois.in.ua) | |||
% All questions regarding this service please send to help@whois.in.ua | |||
% To search for domains and In.UA maintainers using the web, visit http://whois.in.ua | |||
domain: darite.in.ua | |||
descr: darite.in.ua | |||
admin-c: CP91-UANIC | |||
tech-c: NIC-UANIC | |||
status: OK-UNTIL 20110214000000 | |||
nserver: NS10.UADNS.COM | |||
nserver: NS11.UADNS.COM | |||
nserver: NS12.UADNS.COM | |||
mnt-by: DRS-MNT-INUA | |||
mnt-lower: UA-NIC-MNT-INUA | |||
changed: support@drs.ua 20100214222214 | |||
source: INUA | |||
|
|||
|
|||
|
|||
% REDIRECT END |
29 changes: 29 additions & 0 deletions
29
test/testcases/responses/whois.net.ua/redirect_to_whois.in.ua.txt
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
% This is the Ukrainian Whois query server #B. | |||
% Rights restricted by copyright. | |||
% | |||
|
|||
% The object shown below is NOT in the UANIC database. | |||
% It has been obtained by querying a remote server: | |||
% (whois.in.ua) at port 43. | |||
% | |||
% REDIRECT BEGIN | |||
|
|||
% In.UA whois server. (whois.in.ua) | |||
% All questions regarding this service please send to help@whois.in.ua | |||
% To search for domains and In.UA maintainers using the web, visit http://whois.in.ua | |||
domain: darite.in.ua | |||
descr: darite.in.ua | |||
admin-c: CP91-UANIC | |||
tech-c: NIC-UANIC | |||
status: OK-UNTIL 20110214000000 | |||
nserver: NS10.UADNS.COM | |||
nserver: NS11.UADNS.COM | |||
nserver: NS12.UADNS.COM | |||
mnt-by: DRS-MNT-INUA | |||
mnt-lower: UA-NIC-MNT-INUA | |||
changed: support@drs.ua 20100214222214 | |||
source: INUA | |||
|
|||
|
|||
|
|||
% REDIRECT END |