Skip to content

Commit

Permalink
Added simple .uz TLD parser (whois.nic.uz).
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Jun 16, 2010
1 parent 234c0fd commit 93825e2
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.rdoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= Changelog


== Release 1.1.8
== master

* NEW: Added simple .ee TLD parser (whois.eenet.ee).

Expand All @@ -11,6 +11,8 @@

* NEW: Added simple .ec TLD parser (whois.nic.ec).

* NEW: Added simple .uz TLD parser (whois.nic.uz).


== Release 1.2.0

Expand Down
79 changes: 79 additions & 0 deletions lib/whois/answer/parser/whois.cctld.uz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# = 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.cctld.uz parser
#
# Parser for the whois.cctld.uz 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 WhoisCctldUz < Base

property_supported :status do
@status ||= if content_for_scanner =~ /^Status: (.*)\n/
$1
end
end

property_supported :available? do
@available ||= !!(content_for_scanner =~ /not found in database/)
end

property_supported :registered? do
@registered ||= !available?
end


property_supported :created_on do
@created_on ||= if content_for_scanner =~ /^Creation Date:(.*)\n/
Time.parse($1)
end
end

property_not_supported :updated_on

property_supported :expires_on do
@expires_on ||= if content_for_scanner =~ /^Expiration Date:(.*)\n/
Time.parse($1)
end
end


property_supported :nameservers do
@nameservers ||= if content_for_scanner =~ /Domain servers in listed order:\n((.+\n)+)\n/
$1.split("\n").map { |value| value.strip.chomp(".") }
else
[]
end
end

end

end
end
end
2 changes: 1 addition & 1 deletion test/list_tld
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ uk;whois.nic.uk;google.co.uk;u34jedzcq.co.uk
us;whois.nic.us;google.us;u34jedzcq.us
#Whois::Server.define :tld, ".com.uy", nil, {:web=>"https://nic.anteldata.com.uy/dns/", :adapter=>Whois::Server::Adapters::Web}
#Whois::Server.define :tld, ".uy", "whois.nic.org.uy"
#Whois::Server.define :tld, ".uz", "whois.cctld.uz"
uz;whois.cctld.uz;google.uz;u34jedzcq.uz
va;whois.ripe.net;vatican.va;u34jedzcq.va
vc;whois.afilias-grs.info;google.vc;u34jedzcq.vc
ve;whois.nic.ve;ula.ve;u34jedzcq.ve
Expand Down
12 changes: 12 additions & 0 deletions test/testcases/responses/whois.cctld.uz/available.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

% UzWhois Server Version 1.0

% Domain names in the .uz domain can now be registered
% with many different competing registrars. Go to http://www.cctld.uz/
% for detailed information.

Sorry, but domain: "u34jedzcq.uz", not found in database

% The Whois Server (ver. 1.0) of ccTLD.UZ
% (c) 2005, Center UZINFOCOM

123 changes: 123 additions & 0 deletions test/testcases/responses/whois.cctld.uz/registered.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

% UzWhois Server Version 1.0

% Domain names in the .uz domain can now be registered
% with many different competing registrars. Go to http://www.cctld.uz/
% for detailed information.

Domain Name: GOOGLE.UZ
Registrar: TOMAS
Whois Server: www.whois.uz
Referral URL: http://www.cctld.uz/
Name Server: ns1.google.com. not.defined.
Name Serever: ns2.google.com. not.defined.
Status: ACTIVE
Updated Date: 26-mar-2010
Creation Date: 13-Apr-2006
Expiration Date: 01-may-2011


% >>> Last update of whois database: Wed, 16 Jun 2010 15:37:09 +0500 <<<

% NOTICE: The expiration date displayed in this record is the date the
% registrar's sponsorship of the domain name registration in the registry is
% currently set to expire. This date does not necessarily reflect the expiration
% date of the domain name registrant's agreement with the sponsoring
% registrar. Users may consult the sponsoring registrar's Whois database to
% view the registrar's reported date of expiration for this registration.

% 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 except as reasonably necessary to register domain names or
% modify existing registrations; the Data in Center UZINFOCOM ccTLD.uz
% Services ( Center UZINFOCOM ) Whois database is provided by Center UZINFOCOM for
% information purposes only, and to assist persons in obtaining information
% about or related to a domain name registration record. Center UZINFOCOM 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 Center UZINFOCOM (or its computer systems). The compilation,
% repackaging, dissemination or other use of this Data is expressly
% prohibited without the prior written consent of Center UZINFOCOM. You agree not to
% use electronic processes that are automated and high-volume to access or
% query the Whois database except as reasonably necessary to register
% domain names or modify existing registrations. Center UZINFOCOM reserves the right
% to restrict your access to the Whois database in its sole discretion to ensure
% operational stability. Center UZINFOCOM may restrict or terminate your access to the
% Whois database for failure to abide by these terms of use. Center UZINFOCOM
% reserves the right to modify these terms at any time.

% The Registry database contains ONLY .UZ domains and
% Registrars.

% Registration Service Provided By: TOMAS

Domain Name: GOOGLE.UZ

Registrant:
Google Inc
DNS Admin (dns-admin [at] google.com)
2400 E Bayshore Pkwy
Mountain View
US, 94043
US
Tel. +1 6503300100
Fax. +1 6506181499

Creation Date: 13-Apr-2006
Expiration Date: 01-may-2011

Domain servers in listed order:
ns1.google.com.
ns2.google.com.


Administrative Contact:
Google Inc
DNS Admin (dns-admin [at] google.com)
2400 E Bayshore Pkwy
Mountain View
US, 94043
US
Tel. +1 6503300100
Fax. +1 6506181499

Technical Contact:
Google Inc
DNS Admin (dns-admin [at] google.com)
2400 E Bayshore Pkwy
Mountain View
US, 94043
US
Tel. +1 6503300100
Fax. +1 6506181499

Billing Contact:
MarkMonitor
Kevin Pearl (ccops [at] markmonitor.com)
10400 Overland Road PMB 155
Boise
US, 83709
US
Tel. +1 208 389 5798
Fax. +1 208 389 5771

Status: ACTIVE

% The data in this whois database is provided to you for informationpurposes only, that is, to assist you in obtaining
% information about or related to a domain name registration record. We make this informationavailable "as is", and do
% not guarantee its accuracy. By submitting awhois query, you agree that you will use this data only for lawfulpurposes
% and that, under no circumstances will you use this data to:(1) enable high volume, automated, electronic processes
% that stress orload this whois database system providing you this information; or(2) allow, enable, or otherwise
% support the transmission of massunsolicited, commercial advertising or solicitations via direct mail,electronic mail,
% or by telephone. The compilation, repackaging,dissemination or other use of this data is expressly prohibited withoutprior
% written consent from us. The registrar of record is Critical Internet, Inc.. We reserve the right to modifythese terms at
% any time. By submitting this query, you agree to abideby these terms.


% The Whois Server (ver. 1.0) of ccTLD.UZ
% (c) 2005, Center UZINFOCOM

91 changes: 91 additions & 0 deletions test/whois/answer/parser/whois.cctld.uz_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
require 'test_helper'
require 'whois/answer/parser/whois.cctld.uz'

class AnswerParserWhoisCctldUzTest < Whois::Answer::Parser::TestCase

def setup
@klass = Whois::Answer::Parser::WhoisCctldUz
@host = "whois.cctld.uz"
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 = 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
parser = @klass.new(load_part('/registered.txt'))
expected = Time.parse("2006-04-13")
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
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/registered.txt')).updated_on }
assert_raise(Whois::PropertyNotSupported) { @klass.new(load_part('/available.txt')).updated_on }
end

def test_expires_on
parser = @klass.new(load_part('/registered.txt'))
expected = Time.parse("2011-05-01")
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 )
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

0 comments on commit 93825e2

Please sign in to comment.