Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Parser for .ug domains (closes #35)

  • Loading branch information...
commit 960d017c2ad342f89ab1f216e3bd4878e663d469 2 parents e4f731d + 5ff1af7
@weppos authored
View
2  data/c/tld_serv_list
@@ -291,7 +291,7 @@
.tw whois.twnic.net.tw
.tz whois.tznic.or.tz
.ua whois.net.ua
-.ug www.registry.co.ug # this is a whois server too
+.ug whois.co.ug
.ac.uk whois.ja.net
.bl.uk NONE
.british-library.uk NONE
View
76 lib/whois/answer/parser/whois.co.ug.rb
@@ -0,0 +1,76 @@
+#
+# = Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+#
+# Category:: Net
+# Package:: Whois
+# Author:: Moritz Heidkamp <moritz.heidkamp@bevuta.com>
+# License:: MIT License
+#
+#--
+#
+#++
+
+
+require 'whois/answer/parser/base'
+
+
+module Whois
+ class Answer
+ class Parser
+
+ #
+ # = whois.co.ug parser
+ #
+ # Parser for the whois.co.ug 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 WhoisCoUg < Base
+
+ property_supported :status do
+ @status ||= content_for_scanner[/^Status:\s+(.+)$/, 1]
+ end
+
+ property_supported :available? do
+ @available ||= !!(content_for_scanner =~ /No entries found for the selected source/)
+ end
+
+ property_supported :registered? do
+ !available?
+ end
+
+ property_supported :created_on do
+ @created_on ||= if content_for_scanner =~ /Registered:\s+(.+)$/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :updated_on do
+ @updated_on ||= if content_for_scanner =~ /Updated:\s+(.+)$/
+ DateTime.strptime($1, '%d/%m/%Y %H:%M:%S').to_time
+ end
+ end
+
+ property_supported :expires_on do
+ @expires_on ||= if content_for_scanner =~ /Expiry:\s(.+)$/
+ Time.parse($1)
+ end
+ end
+
+
+ property_supported :nameservers do
+ @nameservers ||= content_for_scanner.scan(/Nameserver:\s+(.+)$/).flatten.map(&:downcase)
+ end
+
+ end
+
+ end
+ end
+end
View
2  lib/whois/definitions/tlds.rb
@@ -279,7 +279,7 @@
Whois::Server.define :tld, ".tz", "whois.tznic.or.tz"
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, ".ug", "whois.co.ug"
Whois::Server.define :tld, ".ac.uk", "whois.ja.net"
Whois::Server.define :tld, ".bl.uk", nil, {:adapter=>Whois::Server::Adapters::None}
Whois::Server.define :tld, ".british-library.uk", nil, {:adapter=>Whois::Server::Adapters::None}
View
7 test/testcases/responses/whois.co.ug/available.txt
@@ -0,0 +1,7 @@
+
+**********************************************************
+* The UG ccTLD Registry Database *
+**********************************************************
+
+% No entries found for the selected source(s).
+
View
35 test/testcases/responses/whois.co.ug/registered.txt
@@ -0,0 +1,35 @@
+
+**********************************************************
+* The UG ccTLD Registry Database *
+**********************************************************
+
+Domain: whois.co.ug
+Description: UG CCTLD Database (IT solutions, Domain Names, helpdesk and call center)
+Registered: 2nd April, 2001
+Expiry: 7th April, 2018
+Status: ACTIVE
+Admin Contact: Charles Musisi
+Tech Contact: Mpeirwe Johnson
+Nameserver: ns1.cfi.co.ug
+Nameserver: ns2.cfi.co.ug
+Nameserver: ns3.cfi.co.ug
+MNT-BY: MAINT-UG
+Source: UG
+Updated: 10/11/2009 14:06:58 EAT
+
+Admin Contact: Charles Musisi
+NIC: CM260
+Address: Computer Frontiers International, Plot 6B Windsor Loop, P.O. Box 12
+City: Kampala
+Country: Uganda
+Phone: +256 31 230 1800
+Updated: 13/02/2008 09:35:15 EAT hostmaster@cfi.co.ug
+
+Tech Contact: Mpeirwe Johnson
+NIC: MJ5-UG
+Address: Plot 6B, Windor Loop Kitante
+City: Kampala
+Country: Uganda
+Phone: +256782694615
+Updated: 11/12/2008 11:55:01 EAT hostmaster@cfi.co.ug
+
View
83 test/whois/answer/parser/whois.co.ug_test.rb
@@ -0,0 +1,83 @@
+require 'test_helper'
+require 'whois/answer/parser/whois.co.ug'
+
+class AnswerParserWhoisCoUgTest < Whois::Answer::Parser::TestCase
+
+ def setup
+ @klass = Whois::Answer::Parser::WhoisCoUg
+ @host = "whois.co.ug"
+ 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?
+ assert !@klass.new(load_part('/registered.txt')).available?
+ assert @klass.new(load_part('/available.txt')).available?
+ end
+
+ def test_registered?
+ assert @klass.new(load_part('/registered.txt')).registered?
+ assert !@klass.new(load_part('/available.txt')).registered?
+ end
+
+ def test_created_on
+ parser = @klass.new(load_part('/registered.txt'))
+
+ expected = Time.mktime(2001, 4, 2, 0, 0, 0)
+ 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.gm(2009, 11, 10, 14, 6, 58)
+ 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.mktime(2018, 4, 7)
+ 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.cfi.co.ug ns2.cfi.co.ug ns3.cfi.co.ug]
+ assert_equal expected, parser.nameservers
+ assert_equal expected, parser.instance_eval { @nameservers }
+
+ parser = @klass.new(load_part('/available.txt'))
+ expected = []
+ assert_equal expected, parser.nameservers
+ assert_equal expected, parser.instance_eval { @nameservers }
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.