Permalink
Browse files

Added simple .in.ua TLD parser (whois.in.ua). It seems that .in.ua is…

… handled separately from .ua.
  • Loading branch information...
1 parent 3ba93d4 commit b85f00b9b1b624bc5c02a476d60f2156cc4f37b5 @weppos committed May 19, 2010
View
@@ -1,6 +1,11 @@
= Changelog
+== master
+
+* NEW: Added simple .in.ua TLD parser (whois.in.ua). It seems that .in.ua is handled separately from .ua.
+
+
== Release 1.1.5
* NEW: Added simple .ua TLD parser (whois.net.ua).
@@ -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
@@ -67,7 +67,7 @@ class WhoisNetUa < Base
property_supported :nameservers do
- @nameservers ||= content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten
+ @nameservers ||= content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map { |value| value.strip.downcase }
end
end
@@ -276,6 +276,7 @@
Whois::Server.define :tld, ".tv", "whois.nic.tv", {:adapter=>Whois::Server::Adapters::Verisign}
Whois::Server.define :tld, ".tw", "whois.twnic.net"
Whois::Server.define :tld, ".tz", nil, {:web=>"http://whois.tznic.or.tz/", :adapter=>Whois::Server::Adapters::Web}
+Whois::Server.define :tld, ".in.ua", "whois.in.ua"
Whois::Server.define :tld, ".ua", "whois.net.ua"
Whois::Server.define :tld, ".ug", "www.registry.co.ug"
Whois::Server.define :tld, ".ac.uk", "whois.ja.net"
@@ -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
@@ -88,4 +88,11 @@ def test_nameservers
assert_equal expected, parser.instance_eval { @nameservers }
end
+ def test_nameservers_uppercase
+ parser = @klass.new(load_part('/property_nameservers_uppercase.txt'))
+ expected = %w( ns10.uadns.com ns11.uadns.com ns12.uadns.com )
+ assert_equal expected, parser.nameservers
+ assert_equal expected, parser.instance_eval { @nameservers }
+ end
+
end
View
@@ -277,6 +277,7 @@ tt;;;
tv;whois.nic.tv;thinkcode.tv;u34jedzcq.tv
#Whois::Server.define :tld, ".tw", "whois.twnic.net"
tz;;;
+in.ua;whois.in.ua;google.in.ua;u34jedzcq.in.ua
ua;whois.net.ua;google.com.ua;u34jedzcq.com.ua
#Whois::Server.define :tld, ".ug", "www.registry.co.ug"
#Whois::Server.define :tld, ".ac.uk", "whois.ja.net"
@@ -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
@@ -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
+
@@ -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
@@ -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

0 comments on commit b85f00b

Please sign in to comment.