Skip to content

Commit

Permalink
whois.registrypro.pro is now a full parser.
Browse files Browse the repository at this point in the history
Based on BaseAfilias.
See whois/ianawhois@a21b227
  • Loading branch information
weppos committed Jun 26, 2012
1 parent 5cac11d commit c87a7c1
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 117 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

## master

* NEW: whois.registrypro.pro is now a full parser.

* FIXED: In some cases the parser class is not correctly detected from hostname (GH-173). [Thanks @JustinCampbell]

* FIXED: whois.ua parser raises ArgumentError when the created_on object invalid data.
Expand Down
4 changes: 4 additions & 0 deletions lib/whois/record/parser/whois.aero.rb
Expand Up @@ -15,6 +15,10 @@ class Record
class Parser

# Parser for the whois.aero server.
#
# @see Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
#
class WhoisAero < BaseAfilias

property_supported :status do
Expand Down
47 changes: 2 additions & 45 deletions lib/whois/record/parser/whois.registrypro.pro.rb
Expand Up @@ -7,62 +7,19 @@
#++


require 'whois/record/parser/base'
require 'whois/record/parser/base_afilias'


module Whois
class Record
class Parser

# Parser for the whois.registrypro.pro 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 Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
#
class WhoisRegistryproPro < Base

property_supported :status do
content_for_scanner.scan(/Status:(.+?)\n/).flatten
end

property_supported :available? do
!!(content_for_scanner.strip == 'NOT FOUND')
end

property_supported :registered? do
!available?
end


property_supported :created_on do
if content_for_scanner =~ /Created On:(.+)\n/
Time.parse($1)
end
end

property_supported :updated_on do
if content_for_scanner =~ /Last Updated On:(.+)\n/
Time.parse($1)
end
end

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


property_supported :nameservers do
content_for_scanner.scan(/Name Server:([^\s]+)\n/).flatten.map do |name|
Record::Nameserver.new(:name => name.downcase)
end
end

class WhoisRegistryproPro < BaseAfilias
end

end
Expand Down
72 changes: 36 additions & 36 deletions spec/fixtures/responses/whois.aero/status_registered.expected
Expand Up @@ -49,52 +49,52 @@
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 == "C4526901-AERO"
should: %s[0].name == "Domain Name Administrator"
should: %s[0].organization == "SriLankan Airlines Ltd"
should: %s[0].address == "Admin Bldg"
should: %s[0].city == "Katunayaka"
should: %s[0].zip == "11450"
should: %s[0].state == "WP"
should: %s[0].country_code == "LK"
should: %s[0].phone == "+94.197331600"
should: %s[0].fax == "+94.197335160"
should: %s[0].email == "domregister@srilankan.aero"
should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
should: %s[0].id == "C4526901-AERO"
should: %s[0].name == "Domain Name Administrator"
should: %s[0].organization == "SriLankan Airlines Ltd"
should: %s[0].address == "Admin Bldg"
should: %s[0].city == "Katunayaka"
should: %s[0].zip == "11450"
should: %s[0].state == "WP"
should: %s[0].country_code == "LK"
should: %s[0].phone == "+94.197331600"
should: %s[0].fax == "+94.197335160"
should: %s[0].email == "domregister@srilankan.aero"

#admin_contacts
should: %s CLASS(array)
should: %s SIZE(1)
should: %s[0] CLASS(contact)
should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
should: %s[0].id == "C4526901-AERO"
should: %s[0].name == "Domain Name Administrator"
should: %s[0].organization == "SriLankan Airlines Ltd"
should: %s[0].address == "Admin Bldg"
should: %s[0].city == "Katunayaka"
should: %s[0].zip == "11450"
should: %s[0].state == "WP"
should: %s[0].country_code == "LK"
should: %s[0].phone == "+94.197331600"
should: %s[0].fax == "+94.197335160"
should: %s[0].email == "domregister@srilankan.aero"
should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
should: %s[0].id == "C4526901-AERO"
should: %s[0].name == "Domain Name Administrator"
should: %s[0].organization == "SriLankan Airlines Ltd"
should: %s[0].address == "Admin Bldg"
should: %s[0].city == "Katunayaka"
should: %s[0].zip == "11450"
should: %s[0].state == "WP"
should: %s[0].country_code == "LK"
should: %s[0].phone == "+94.197331600"
should: %s[0].fax == "+94.197335160"
should: %s[0].email == "domregister@srilankan.aero"

#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 == "C4526901-AERO"
should: %s[0].name == "Domain Name Administrator"
should: %s[0].organization == "SriLankan Airlines Ltd"
should: %s[0].address == "Admin Bldg"
should: %s[0].city == "Katunayaka"
should: %s[0].zip == "11450"
should: %s[0].state == "WP"
should: %s[0].country_code == "LK"
should: %s[0].phone == "+94.197331600"
should: %s[0].fax == "+94.197335160"
should: %s[0].email == "domregister@srilankan.aero"
should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
should: %s[0].id == "C4526901-AERO"
should: %s[0].name == "Domain Name Administrator"
should: %s[0].organization == "SriLankan Airlines Ltd"
should: %s[0].address == "Admin Bldg"
should: %s[0].city == "Katunayaka"
should: %s[0].zip == "11450"
should: %s[0].state == "WP"
should: %s[0].country_code == "LK"
should: %s[0].phone == "+94.197331600"
should: %s[0].fax == "+94.197335160"
should: %s[0].email == "domregister@srilankan.aero"


#nameservers
Expand Down
@@ -1,3 +1,21 @@
#disclaimer
should: %s == nil


#domain
should: %s == nil

#domain_id
should: %s == nil


#referral_whois
should: %s raise_error(Whois::PropertyNotSupported)

#referral_url
should: %s raise_error(Whois::PropertyNotSupported)


#status
should: %s == []

Expand All @@ -18,6 +36,22 @@
should: %s == nil


#registrar
should: %s == nil

#registrant_contacts
should: %s CLASS(array)
should: %s == []

#admin_contacts
should: %s CLASS(array)
should: %s == []

#technical_contacts
should: %s CLASS(array)
should: %s == []


#nameservers
should: %s CLASS(array)
should: %s == []
@@ -1,3 +1,21 @@
#disclaimer
should: %s == "Access to .PRO REGISTRY WHOIS information is provided to assist persons in determining the contents of a domain name registration record in the .PRO Registry registry database. The data in this record is provided by .PRO Registry for informational purposes only, and .PRO Registry does not guarantee its accuracy. This service is intended only for query-based access. You agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to: (a) allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the data recipient's own existing customers; or (b) enable high volume, automated, electronic processes that send queries or data to the systems of Registry Operator, a Registrar, or Afilias except as reasonably necessary to register domain names or modify existing registrations. All rights reserved. .PRO Registry reserves the right to modify these terms at any time. By submitting this query, you agree to abide by this policy."


#domain
should: %s == "registrypro.pro"

#domain_id
should: %s == "D6394-PRO"


#referral_whois
should: %s raise_error(Whois::PropertyNotSupported)

#referral_url
should: %s raise_error(Whois::PropertyNotSupported)


#status
should: %s == ["CLIENT TRANSFER PROHIBITED", "DELETE PROHIBITED"]

Expand All @@ -21,6 +39,64 @@
should: %s == Time.parse("2017-01-26 00:00:00 UTC")


#registrar
should: %s CLASS(registrar)
should: %s.id == "R2338-PRO"
should: %s.name == "Corporation Service Company dba CSC Corporate Domains, Inc"
should: %s.organization == "Corporation Service Company dba CSC Corporate Domains, Inc"

#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 == "RSC-1"
should: %s[0].name == "Afilias Limited"
should: %s[0].organization == "Afilias Limited"
should: %s[0].address == "2 La Touche House\nIFSC"
should: %s[0].city == "Dublin"
should: %s[0].zip == "1"
should: %s[0].state == "IL"
should: %s[0].country_code == "IE"
should: %s[0].phone == "+353.14310511"
should: %s[0].fax == "+353.14310557"
should: %s[0].email == "domainadmin@afilias.info"

#admin_contacts
should: %s CLASS(array)
should: %s SIZE(1)
should: %s[0] CLASS(contact)
should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
should: %s[0].id == "RSC-1"
should: %s[0].name == "Afilias Limited"
should: %s[0].organization == "Afilias Limited"
should: %s[0].address == "2 La Touche House\nIFSC"
should: %s[0].city == "Dublin"
should: %s[0].zip == "1"
should: %s[0].state == "IL"
should: %s[0].country_code == "IE"
should: %s[0].phone == "+353.14310511"
should: %s[0].fax == "+353.14310557"
should: %s[0].email == "domainadmin@afilias.info"

#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 == "RSC-1"
should: %s[0].name == "Afilias Limited"
should: %s[0].organization == "Afilias Limited"
should: %s[0].address == "2 La Touche House\nIFSC"
should: %s[0].city == "Dublin"
should: %s[0].zip == "1"
should: %s[0].state == "IL"
should: %s[0].country_code == "IE"
should: %s[0].phone == "+353.14310511"
should: %s[0].fax == "+353.14310557"
should: %s[0].email == "domainadmin@afilias.info"


#nameservers
should: %s CLASS(array)
should: %s SIZE(5)
Expand Down
Expand Up @@ -92,56 +92,56 @@
@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 == "C4526901-AERO"
@parser.registrant_contacts[0].name.should == "Domain Name Administrator"
@parser.registrant_contacts[0].organization.should == "SriLankan Airlines Ltd"
@parser.registrant_contacts[0].address.should == "Admin Bldg"
@parser.registrant_contacts[0].city.should == "Katunayaka"
@parser.registrant_contacts[0].zip.should == "11450"
@parser.registrant_contacts[0].state.should == "WP"
@parser.registrant_contacts[0].country_code.should == "LK"
@parser.registrant_contacts[0].phone.should == "+94.197331600"
@parser.registrant_contacts[0].fax.should == "+94.197335160"
@parser.registrant_contacts[0].email.should == "domregister@srilankan.aero"
@parser.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
@parser.registrant_contacts[0].id.should == "C4526901-AERO"
@parser.registrant_contacts[0].name.should == "Domain Name Administrator"
@parser.registrant_contacts[0].organization.should == "SriLankan Airlines Ltd"
@parser.registrant_contacts[0].address.should == "Admin Bldg"
@parser.registrant_contacts[0].city.should == "Katunayaka"
@parser.registrant_contacts[0].zip.should == "11450"
@parser.registrant_contacts[0].state.should == "WP"
@parser.registrant_contacts[0].country_code.should == "LK"
@parser.registrant_contacts[0].phone.should == "+94.197331600"
@parser.registrant_contacts[0].fax.should == "+94.197335160"
@parser.registrant_contacts[0].email.should == "domregister@srilankan.aero"
end
end
describe "#admin_contacts" do
it do
@parser.admin_contacts.should be_a(Array)
@parser.admin_contacts.should have(1).items
@parser.admin_contacts[0].should be_a(Whois::Record::Contact)
@parser.admin_contacts[0].type.should == Whois::Record::Contact::TYPE_ADMIN
@parser.admin_contacts[0].id.should == "C4526901-AERO"
@parser.admin_contacts[0].name.should == "Domain Name Administrator"
@parser.admin_contacts[0].organization.should == "SriLankan Airlines Ltd"
@parser.admin_contacts[0].address.should == "Admin Bldg"
@parser.admin_contacts[0].city.should == "Katunayaka"
@parser.admin_contacts[0].zip.should == "11450"
@parser.admin_contacts[0].state.should == "WP"
@parser.admin_contacts[0].country_code.should == "LK"
@parser.admin_contacts[0].phone.should == "+94.197331600"
@parser.admin_contacts[0].fax.should == "+94.197335160"
@parser.admin_contacts[0].email.should == "domregister@srilankan.aero"
@parser.admin_contacts[0].type.should == Whois::Record::Contact::TYPE_ADMIN
@parser.admin_contacts[0].id.should == "C4526901-AERO"
@parser.admin_contacts[0].name.should == "Domain Name Administrator"
@parser.admin_contacts[0].organization.should == "SriLankan Airlines Ltd"
@parser.admin_contacts[0].address.should == "Admin Bldg"
@parser.admin_contacts[0].city.should == "Katunayaka"
@parser.admin_contacts[0].zip.should == "11450"
@parser.admin_contacts[0].state.should == "WP"
@parser.admin_contacts[0].country_code.should == "LK"
@parser.admin_contacts[0].phone.should == "+94.197331600"
@parser.admin_contacts[0].fax.should == "+94.197335160"
@parser.admin_contacts[0].email.should == "domregister@srilankan.aero"
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 == "C4526901-AERO"
@parser.technical_contacts[0].name.should == "Domain Name Administrator"
@parser.technical_contacts[0].organization.should == "SriLankan Airlines Ltd"
@parser.technical_contacts[0].address.should == "Admin Bldg"
@parser.technical_contacts[0].city.should == "Katunayaka"
@parser.technical_contacts[0].zip.should == "11450"
@parser.technical_contacts[0].state.should == "WP"
@parser.technical_contacts[0].country_code.should == "LK"
@parser.technical_contacts[0].phone.should == "+94.197331600"
@parser.technical_contacts[0].fax.should == "+94.197335160"
@parser.technical_contacts[0].email.should == "domregister@srilankan.aero"
@parser.technical_contacts[0].type.should == Whois::Record::Contact::TYPE_TECHNICAL
@parser.technical_contacts[0].id.should == "C4526901-AERO"
@parser.technical_contacts[0].name.should == "Domain Name Administrator"
@parser.technical_contacts[0].organization.should == "SriLankan Airlines Ltd"
@parser.technical_contacts[0].address.should == "Admin Bldg"
@parser.technical_contacts[0].city.should == "Katunayaka"
@parser.technical_contacts[0].zip.should == "11450"
@parser.technical_contacts[0].state.should == "WP"
@parser.technical_contacts[0].country_code.should == "LK"
@parser.technical_contacts[0].phone.should == "+94.197331600"
@parser.technical_contacts[0].fax.should == "+94.197335160"
@parser.technical_contacts[0].email.should == "domregister@srilankan.aero"
end
end
describe "#nameservers" do
Expand Down

0 comments on commit c87a7c1

Please sign in to comment.