Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit a5c3212ae73bc27e827414f536f990c64a9bd81f 1 parent b2342a3
@weppos authored
View
4 CHANGELOG.md
@@ -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".
View
2  lib/whois/definitions/tlds.rb
@@ -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 }
View
2  lib/whois/record/parser/base_afilias.rb
@@ -117,7 +117,7 @@ def parse
end
- private
+ private
def build_contact(element, type)
node("#{element} ID") do
View
125 lib/whois/record/parser/whois.registry.om.rb
@@ -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
View
39 lib/whois/record/scanners/whois.registry.om.rb
@@ -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
View
24 spec/fixtures/responses/whois.dns.hr/status_registered.expected
@@ -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)
View
56 spec/fixtures/responses/whois.registry.om/status_available.expected
@@ -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 == []
View
1  spec/fixtures/responses/whois.registry.om/status_available.txt
@@ -0,0 +1 @@
+No Data Found
View
100 spec/fixtures/responses/whois.registry.om/status_registered.expected
@@ -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
View
18 spec/fixtures/responses/whois.registry.om/status_registered.txt
@@ -0,0 +1,18 @@
+Domain Name: rop.gov.om
+Registrar Name: Oman Telecommunication Company
+Status: ok
+
+Registrant Contact ID: 10084244
+Registrant Contact Name: Nasser Said Al Daree
+Registrant Contact Email: Visit whois.registry.om for Web based WhoIs
+
+Tech Contact ID: 10084244
+Tech Contact Name: Nasser Said Al Daree
+Tech Contact Email: Visit whois.registry.om for Web based WhoIs
+
+Name Server: om14.omantel.net.om
+Name Server IP: 212.72.23.4
+Name Server: om16.omantel.net.om
+Name Server IP: 212.72.1.186
+Name Server: om41.omantel.net.om
+Name Server IP: 62.231.243.249
View
2  spec/tlds
@@ -216,7 +216,7 @@ np;;;
nr;;;
nu;whois.nic.nu;google.nu;u34jedzcq.nu
nz;whois.srs.net.nz;google.co.nz;u34jedzcq.co.nz
-om;;;
+om;whois.registry.om;rop.gov.om;u34jedzcq.om
org.za;whois.org.za;joburg.org.za;u34jedzcq.org.za
org;whois.publicinterestregistry.net;google.org;u34jedzcq.org
pa;;;
View
24 spec/whois/record/parser/responses/whois.dns.hr/status_registered_spec.rb
@@ -87,17 +87,19 @@
@parser.registrant_contacts.should be_a(Array)
@parser.registrant_contacts.should have(1).items
@parser.registrant_contacts[0].should be_a(Whois::Record::Contact)
- @parser.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
- @parser.registrant_contacts[0].name.should == "Google Hrvatska d.o.o."
- @parser.registrant_contacts[0].organization.should == nil
- @parser.registrant_contacts[0].address.should == "Primorska 26"
- @parser.registrant_contacts[0].city.should == "Zagreb"
- @parser.registrant_contacts[0].zip.should == "10 000"
- @parser.registrant_contacts[0].state.should == nil
- @parser.registrant_contacts[0].country.should == nil
- @parser.registrant_contacts[0].phone.should == nil
- @parser.registrant_contacts[0].fax.should == nil
- @parser.registrant_contacts[0].email.should == nil
+ @parser.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
+ @parser.registrant_contacts[0].id.should == nil
+ @parser.registrant_contacts[0].name.should == "Google Hrvatska d.o.o."
+ @parser.registrant_contacts[0].organization.should == nil
+ @parser.registrant_contacts[0].address.should == "Primorska 26"
+ @parser.registrant_contacts[0].city.should == "Zagreb"
+ @parser.registrant_contacts[0].zip.should == "10 000"
+ @parser.registrant_contacts[0].state.should == nil
+ @parser.registrant_contacts[0].country.should == nil
+ @parser.registrant_contacts[0].country_code.should == nil
+ @parser.registrant_contacts[0].phone.should == nil
+ @parser.registrant_contacts[0].fax.should == nil
+ @parser.registrant_contacts[0].email.should == nil
end
end
describe "#admin_contacts" do
View
107 spec/whois/record/parser/responses/whois.registry.om/status_available_spec.rb
@@ -0,0 +1,107 @@
+# encoding: utf-8
+
+# This file is autogenerated. Do not edit it manually.
+# If you want change the content of this file, edit
+#
+# /spec/fixtures/responses/whois.registry.om/status_available.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.registry.om.rb'
+
+describe Whois::Record::Parser::WhoisRegistryOm, "status_available.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.registry.om/status_available.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ end
+
+ describe "#disclaimer" do
+ it do
+ lambda { @parser.disclaimer }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#domain" do
+ it do
+ @parser.domain.should == nil
+ end
+ end
+ describe "#domain_id" do
+ it do
+ lambda { @parser.domain_id }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#referral_url" do
+ it do
+ lambda { @parser.referral_url }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#referral_whois" do
+ it do
+ lambda { @parser.referral_whois }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#status" do
+ it do
+ @parser.status.should == :available
+ end
+ end
+ describe "#available?" do
+ it do
+ @parser.available?.should == true
+ end
+ end
+ describe "#registered?" do
+ it do
+ @parser.registered?.should == false
+ end
+ end
+ describe "#created_on" do
+ it do
+ lambda { @parser.created_on }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#updated_on" do
+ it do
+ lambda { @parser.updated_on }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#expires_on" do
+ it do
+ lambda { @parser.expires_on }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#registrar" do
+ it do
+ @parser.registrar.should == nil
+ end
+ end
+ describe "#registrant_contacts" do
+ it do
+ @parser.registrant_contacts.should be_a(Array)
+ @parser.registrant_contacts.should == []
+ end
+ end
+ describe "#admin_contacts" do
+ it do
+ lambda { @parser.admin_contacts }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#technical_contacts" do
+ it do
+ @parser.technical_contacts.should be_a(Array)
+ @parser.technical_contacts.should == []
+ end
+ end
+ describe "#nameservers" do
+ it do
+ @parser.nameservers.should be_a(Array)
+ @parser.nameservers.should == []
+ end
+ end
+end
View
151 spec/whois/record/parser/responses/whois.registry.om/status_registered_spec.rb
@@ -0,0 +1,151 @@
+# encoding: utf-8
+
+# This file is autogenerated. Do not edit it manually.
+# If you want change the content of this file, edit
+#
+# /spec/fixtures/responses/whois.registry.om/status_registered.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.registry.om.rb'
+
+describe Whois::Record::Parser::WhoisRegistryOm, "status_registered.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.registry.om/status_registered.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ end
+
+ describe "#disclaimer" do
+ it do
+ lambda { @parser.disclaimer }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#domain" do
+ it do
+ @parser.domain.should == "rop.gov.om"
+ end
+ end
+ describe "#domain_id" do
+ it do
+ lambda { @parser.domain_id }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#referral_url" do
+ it do
+ lambda { @parser.referral_url }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#referral_whois" do
+ it do
+ lambda { @parser.referral_whois }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#status" do
+ it do
+ @parser.status.should == :registered
+ end
+ end
+ describe "#available?" do
+ it do
+ @parser.available?.should == false
+ end
+ end
+ describe "#registered?" do
+ it do
+ @parser.registered?.should == true
+ end
+ end
+ describe "#created_on" do
+ it do
+ lambda { @parser.created_on }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#updated_on" do
+ it do
+ lambda { @parser.updated_on }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#expires_on" do
+ it do
+ lambda { @parser.expires_on }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#registrar" do
+ it do
+ @parser.registrar.should be_a(Whois::Record::Registrar)
+ @parser.registrar.id.should == nil
+ @parser.registrar.name.should == "Oman Telecommunication Company"
+ @parser.registrar.organization.should == nil
+ @parser.registrar.url.should == nil
+ end
+ end
+ describe "#registrant_contacts" do
+ it do
+ @parser.registrant_contacts.should be_a(Array)
+ @parser.registrant_contacts.should have(1).items
+ @parser.registrant_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
+ @parser.registrant_contacts[0].id.should == "10084244"
+ @parser.registrant_contacts[0].name.should == "Nasser Said Al Daree"
+ @parser.registrant_contacts[0].organization.should == nil
+ @parser.registrant_contacts[0].address.should == nil
+ @parser.registrant_contacts[0].city.should == nil
+ @parser.registrant_contacts[0].zip.should == nil
+ @parser.registrant_contacts[0].state.should == nil
+ @parser.registrant_contacts[0].country.should == nil
+ @parser.registrant_contacts[0].country_code.should == nil
+ @parser.registrant_contacts[0].phone.should == nil
+ @parser.registrant_contacts[0].fax.should == nil
+ @parser.registrant_contacts[0].email.should == "Visit whois.registry.om for Web based WhoIs"
+ end
+ end
+ describe "#admin_contacts" do
+ it do
+ lambda { @parser.admin_contacts }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#technical_contacts" do
+ it do
+ @parser.technical_contacts.should be_a(Array)
+ @parser.technical_contacts.should have(1).items
+ @parser.technical_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.technical_contacts[0].type.should == Whois::Record::Contact::TYPE_TECHNICAL
+ @parser.technical_contacts[0].id.should == "10084244"
+ @parser.technical_contacts[0].name.should == "Nasser Said Al Daree"
+ @parser.technical_contacts[0].organization.should == nil
+ @parser.technical_contacts[0].address.should == nil
+ @parser.technical_contacts[0].city.should == nil
+ @parser.technical_contacts[0].zip.should == nil
+ @parser.technical_contacts[0].state.should == nil
+ @parser.technical_contacts[0].country.should == nil
+ @parser.technical_contacts[0].country_code.should == nil
+ @parser.technical_contacts[0].phone.should == nil
+ @parser.technical_contacts[0].fax.should == nil
+ @parser.technical_contacts[0].email.should == "Visit whois.registry.om for Web based WhoIs"
+ end
+ end
+ describe "#nameservers" do
+ it do
+ @parser.nameservers.should be_a(Array)
+ @parser.nameservers.should have(3).items
+ @parser.nameservers[0].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[0].name.should == "om14.omantel.net.om"
+ @parser.nameservers[0].ipv4.should == nil
+ @parser.nameservers[0].ipv6.should == nil
+ @parser.nameservers[1].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[1].name.should == "om16.omantel.net.om"
+ @parser.nameservers[1].ipv4.should == nil
+ @parser.nameservers[1].ipv6.should == nil
+ @parser.nameservers[2].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[2].name.should == "om41.omantel.net.om"
+ @parser.nameservers[2].ipv4.should == nil
+ @parser.nameservers[2].ipv6.should == nil
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.