Permalink
Browse files

Added .OM TLD server and full whois.registry.om parser.

  • Loading branch information...
1 parent b2342a3 commit a5c3212ae73bc27e827414f536f990c64a9bd81f @weppos committed May 7, 2012
View
@@ -3,8 +3,12 @@
## master
+* SERVER: Added .OM TLD server.
+
* NEW: whois.srs.net.nz parser now recognizes throttled responses.
+* NEW: Added full whois.registry.om parser.
+
* CHANGED: whois.nic.uk changed response format.
* FIXED: whois.hkirc.hk parser crashes when expiration date is "null".
@@ -232,7 +232,7 @@
Whois::Server.define :tld, ".nr", nil, { :web => "http://www.cenpac.net.nr/dns/whois.html", :adapter => Whois::Server::Adapters::Web }
Whois::Server.define :tld, ".nu", "whois.nic.nu"
Whois::Server.define :tld, ".nz", "whois.srs.net.nz"
-Whois::Server.define :tld, ".om", nil, { :web => "http://www.omnic.om/onlineUser/WHOISLookup.jsp", :adapter => Whois::Server::Adapters::Web }
+Whois::Server.define :tld, ".om", "whois.registry.om"
Whois::Server.define :tld, ".pa", nil, { :web => "http://www.nic.pa/", :adapter => Whois::Server::Adapters::Web }
Whois::Server.define :tld, ".pe", "kero.yachay.pe"
Whois::Server.define :tld, ".pf", nil, { :adapter => Whois::Server::Adapters::None }
@@ -117,7 +117,7 @@ def parse
end
- private
+ private
def build_contact(element, type)
node("#{element} ID") do
@@ -0,0 +1,125 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/parser/base'
+require 'whois/record/scanners/whois.registry.om.rb'
+
+
+module Whois
+ class Record
+ class Parser
+
+ # Parser for the whois.registry.om server.
+ #
+ # @see Whois::Record::Parser::Example
+ # The Example parser for the list of all available methods.
+ #
+ # @since RELEASE
+ class WhoisRegistryOm < Base
+ include Scanners::Ast
+
+ property_not_supported :disclaimer
+
+
+ property_supported :domain do
+ node('Domain Name')
+ end
+
+ property_not_supported :domain_id
+
+
+ property_not_supported :referral_whois
+
+ property_not_supported :referral_url
+
+
+ property_supported :status do
+ case (s = node('Status'))
+ when nil
+ :available
+ when 'ok'
+ :registered
+ else
+ Whois.bug!(ParserError, "Unknown status `#{s}'.")
+ end
+ end
+
+ property_supported :available? do
+ !!node('status:available')
+ end
+
+ property_supported :registered? do
+ !available?
+ end
+
+
+ property_not_supported :created_on
+
+ property_not_supported :updated_on
+
+ property_not_supported :expires_on
+
+
+ property_supported :registrar do
+ node('Registrar Name') do |name|
+ Record::Registrar.new(
+ :name => name
+ )
+ end
+ end
+
+
+ property_supported :registrant_contacts do
+ build_contact('Registrant', Whois::Record::Contact::TYPE_REGISTRANT)
+ end
+
+ property_not_supported :admin_contacts
+
+ property_supported :technical_contacts do
+ build_contact('Tech', Whois::Record::Contact::TYPE_TECHNICAL)
+ end
+
+
+ property_supported :nameservers do
+ node('Name Server') do |names|
+ names.map do |name|
+ Record::Nameserver.new(:name => name)
+ end
+ end
+ end
+
+
+ # Initializes a new {Scanners::WhoisRegistryOm} instance
+ # passing the {#content_for_scanner}
+ # and calls +parse+ on it.
+ #
+ # @return [Hash]
+ def parse
+ Scanners::WhoisRegistryOm.new(content_for_scanner).parse
+ end
+
+
+ private
+
+ def build_contact(element, type)
+ node("#{element} Contact ID") do
+ Record::Contact.new(
+ :type => type,
+ :id => node("#{element} Contact ID"),
+ :name => node("#{element} Contact Name"),
+ :email => node("#{element} Contact Email")
+ )
+ end
+ end
+
+ end
+
+ end
+ end
+end
@@ -0,0 +1,39 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/scanners/base'
+
+
+module Whois
+ class Record
+ module Scanners
+
+ # Scanner for the whois.registry.om record.
+ #
+ # @since RELEASE
+ class WhoisRegistryOm < Base
+
+ self.tokenizers += [
+ :skip_empty_line,
+ :scan_available,
+ :scan_keyvalue,
+ ]
+
+
+ tokenizer :scan_available do
+ if @input.skip(/^No Data Found\n/)
+ @ast['status:available'] = true
+ end
+ end
+
+ end
+
+ end
+ end
+end
@@ -44,17 +44,19 @@
should: %s CLASS(array)
should: %s SIZE(1)
should: %s[0] CLASS(contact)
- should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
- should: %s[0].name == "Google Hrvatska d.o.o."
- should: %s[0].organization == nil
- should: %s[0].address == "Primorska 26"
- should: %s[0].city == "Zagreb"
- should: %s[0].zip == "10 000"
- should: %s[0].state == nil
- should: %s[0].country == nil
- should: %s[0].phone == nil
- should: %s[0].fax == nil
- should: %s[0].email == nil
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].id == nil
+ should: %s[0].name == "Google Hrvatska d.o.o."
+ should: %s[0].organization == nil
+ should: %s[0].address == "Primorska 26"
+ should: %s[0].city == "Zagreb"
+ should: %s[0].zip == "10 000"
+ should: %s[0].state == nil
+ should: %s[0].country == nil
+ should: %s[0].country_code == nil
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == nil
#admin_contacts
should: %s raise_error(Whois::PropertyNotSupported)
@@ -0,0 +1,56 @@
+#disclaimer
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#domain
+ should: %s == nil
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#referral_url
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#status
+ should: %s == :available
+
+#available?
+ should: %s == true
+
+#registered?
+ should: %s == false
+
+
+#created_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#updated_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#expires_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#registrar
+ should: %s == nil
+
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s == []
+
+#admin_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#technical_contacts
+ should: %s CLASS(array)
+ should: %s == []
+
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s == []
@@ -0,0 +1 @@
+No Data Found
@@ -0,0 +1,100 @@
+#disclaimer
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#domain
+ should: %s == "rop.gov.om"
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#referral_url
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#status
+ should: %s == :registered
+
+#available?
+ should: %s == false
+
+#registered?
+ should: %s == true
+
+
+#created_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#updated_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#expires_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.id == nil
+ should: %s.name == "Oman Telecommunication Company"
+ should: %s.organization == nil
+ should: %s.url == nil
+
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].id == "10084244"
+ should: %s[0].name == "Nasser Said Al Daree"
+ should: %s[0].organization == nil
+ should: %s[0].address == nil
+ should: %s[0].city == nil
+ should: %s[0].zip == nil
+ should: %s[0].state == nil
+ should: %s[0].country == nil
+ should: %s[0].country_code == nil
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == "Visit whois.registry.om for Web based WhoIs"
+
+#admin_contacts
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#technical_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
+ should: %s[0].id == "10084244"
+ should: %s[0].name == "Nasser Said Al Daree"
+ should: %s[0].organization == nil
+ should: %s[0].address == nil
+ should: %s[0].city == nil
+ should: %s[0].zip == nil
+ should: %s[0].state == nil
+ should: %s[0].country == nil
+ should: %s[0].country_code == nil
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == "Visit whois.registry.om for Web based WhoIs"
+
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(3)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "om14.omantel.net.om"
+ should: %s[0].ipv4 == nil
+ should: %s[0].ipv6 == nil
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "om16.omantel.net.om"
+ should: %s[1].ipv4 == nil
+ should: %s[1].ipv6 == nil
+ should: %s[2] CLASS(nameserver)
+ should: %s[2].name == "om41.omantel.net.om"
+ should: %s[2].ipv4 == nil
+ should: %s[2].ipv6 == nil
Oops, something went wrong.

0 comments on commit a5c3212

Please sign in to comment.