Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added full whois.cira.ca parser

  • Loading branch information...
commit c7bb7e91a3070fe477c8771234186d74c68f7657 1 parent 158911c
@weppos authored
View
6 CHANGELOG.md
@@ -7,9 +7,11 @@
* NEW: Added full whois.audns.net.au parser.
-* NEW: Added full whois.cctld.by server (GH-154).
+* NEW: Added full whois.cctld.by parser (GH-154).
-* NEW: Added full whois.domainregistry.ie server.
+* NEW: Added full whois.domainregistry.ie parser.
+
+* NEW: Added full whois.cira.ca parser.
* CHANGED: Moved scanners from Whois::Record::Parser::Scanners to Whois::Record::Scanners.
View
2  lib/whois/record/parser/base_afilias.rb
@@ -24,7 +24,7 @@ class BaseAfilias < Base
property_supported :disclaimer do
- node("property:disclaimer")
+ node("field:disclaimer")
end
View
60 lib/whois/record/parser/whois.cira.ca.rb
@@ -24,6 +24,23 @@ class Parser
class WhoisCiraCa < Base
include Scanners::Ast
+ property_supported :disclaimer do
+ node("field:disclaimer")
+ end
+
+
+ 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
if content_for_scanner =~ /Domain status:\s+(.+?)\n/
case node("Domain status", &:downcase)
@@ -80,6 +97,27 @@ class WhoisCiraCa < Base
end
+ property_supported :registrant_contacts do
+ build_contact("Registrant", Whois::Record::Contact::TYPE_REGISTRANT)
+ end
+
+ property_supported :admin_contacts do
+ build_contact("Administrative contact", Whois::Record::Contact::TYPE_ADMIN)
+ end
+
+ property_supported :technical_contacts do
+ build_contact("Technical contact", Whois::Record::Contact::TYPE_TECHNICAL)
+ end
+
+
+ property_supported :nameservers do
+ Array.wrap(node("nserver")).map do |line|
+ name, ipv4 = line.split(/\s+/)
+ Record::Nameserver.new(:name => name, :ipv4 => ipv4)
+ end
+ end
+
+
# Nameservers are listed in the following formats:
#
# ns1.google.com
@@ -135,6 +173,28 @@ def parse
Scanners::WhoisCiraCa.new(content_for_scanner).parse
end
+
+ private
+
+ def build_contact(element, type)
+ node(element) do |hash|
+ Record::Contact.new(
+ :type => type,
+ :id => nil,
+ :name => hash["Name"],
+ :organization => nil,
+ :address => hash["Postal address"],
+ :city => nil,
+ :zip => nil,
+ :state => nil,
+ :country => nil,
+ :phone => hash["Phone"],
+ :fax => hash["Fax"],
+ :email => hash["Email"]
+ )
+ end
+ end
+
end
end
View
2  lib/whois/record/scanners/afilias.rb
@@ -50,7 +50,7 @@ class Afilias < Base
tokenizer :scan_disclaimer do
if @input.pos == 0 && @input.match?(/^(.+\n){3,}\n/)
- @ast["property:disclaimer"] = _scan_lines_to_array(/^(.+)\n/).join(" ")
+ @ast["field:disclaimer"] = _scan_lines_to_array(/^(.+)\n/).join(" ")
end
end
end
View
1  lib/whois/record/scanners/base.rb
@@ -64,6 +64,7 @@ def parse
def _scan_lines_to_array(pattern)
lines = []
while @input.scan(pattern)
+ @input[1].strip
lines << @input[1].strip
end
lines
View
8 lib/whois/record/scanners/whois.cira.ca.rb
@@ -21,6 +21,7 @@ class WhoisCiraCa < Base
self.tokenizers += [
:skip_empty_line,
+ :scan_disclaimer,
:skip_comment,
:scan_header,
:scan_keyvalue,
@@ -28,6 +29,13 @@ class WhoisCiraCa < Base
]
+
+ tokenizer :scan_disclaimer do
+ if @input.match?(/^% Use of CIRA/)
+ @ast["field:disclaimer"] = _scan_lines_to_array(/^%(.*)\n/).join("\n")
+ end
+ end
+
tokenizer :scan_header do
if @input.scan(/^(.+?):\n/)
@tmp["group"] = @input[1]
View
4 lib/whois/record/scanners/whois.domainregistry.ie.rb
@@ -19,7 +19,7 @@ class WhoisDomainregistryIe < Base
self.tokenizers += [
:skip_empty_line,
- :scan_copyright,
+ :scan_disclaimer,
:scan_contact,
:scan_keyvalue,
:scan_available,
@@ -31,7 +31,7 @@ class WhoisDomainregistryIe < Base
end
end
- tokenizer :scan_copyright do
+ tokenizer :scan_disclaimer do
if @input.match?(/^% Rights restricted by copyright/)
@ast["field:disclaimer"] = _scan_lines_to_array(/^%(.+)\n/).join("\n")
end
View
30 spec/fixtures/responses/whois.cira.ca/status_available.expected
@@ -1,3 +1,21 @@
+#disclaimer
+ should: %s == "Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2010 Canadian Internet Registration Authority, (http://www.cira.ca/)"
+
+
+#domain
+ should: %s == "u34jedzcq.ca"
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_url
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
#status
should: %s == :available
@@ -21,6 +39,18 @@
#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)
View
69 spec/fixtures/responses/whois.cira.ca/status_registered.expected
@@ -1,3 +1,21 @@
+#disclaimer
+ should: %s == "Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2010 Canadian Internet Registration Authority, (http://www.cira.ca/)"
+
+
+#domain
+ should: %s == "google.ca"
+
+#domain_id
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#referral_whois
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#referral_url
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
#status
should: %s == :registered
@@ -28,6 +46,57 @@
should: %s.organization == "Webnames.ca Inc."
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 == nil
+ should: %s[0].name == "Google Inc."
+ 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_code == nil
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == nil
+
+#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 == nil
+ should: %s[0].name == "Christina Chiou"
+ should: %s[0].organization == nil
+ should: %s[0].address == "130 King St. W., Suite 1800,\nToronto ON M5X1E3 Canada"
+ should: %s[0].city == nil
+ should: %s[0].zip == nil
+ should: %s[0].state == nil
+ should: %s[0].country_code == nil
+ should: %s[0].phone == "+1.4168653361x"
+ should: %s[0].fax == "+1.4169456616"
+ should: %s[0].email == "dns-admin@google.com"
+
+#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 == nil
+ should: %s[0].name == "Matt Serlin"
+ should: %s[0].organization == nil
+ should: %s[0].address == "Domain Provisioning,10400 Overland Rd. PMB 155\nBoise ID 83709 United States"
+ should: %s[0].city == nil
+ should: %s[0].zip == nil
+ should: %s[0].state == nil
+ should: %s[0].country_code == nil
+ should: %s[0].phone == "+1.2083895740x"
+ should: %s[0].fax == "+1.2083895771"
+ should: %s[0].email == "ccops@markmonitor.com"
+
#nameservers
should: %s CLASS(array)
View
43 spec/whois/record/parser/responses/whois.cira.ca/status_available_spec.rb
@@ -21,6 +21,31 @@
@parser = klass.new(part)
end
+ describe "#disclaimer" do
+ it do
+ @parser.disclaimer.should == "Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2010 Canadian Internet Registration Authority, (http://www.cira.ca/)"
+ end
+ end
+ describe "#domain" do
+ it do
+ @parser.domain.should == "u34jedzcq.ca"
+ end
+ end
+ describe "#domain_id" do
+ it do
+ lambda { @parser.domain_id }.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 "#referral_url" do
+ it do
+ lambda { @parser.referral_url }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
describe "#status" do
it do
@parser.status.should == :available
@@ -56,6 +81,24 @@
@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
+ @parser.admin_contacts.should be_a(Array)
+ @parser.admin_contacts.should == []
+ 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)
View
82 spec/whois/record/parser/responses/whois.cira.ca/status_registered_spec.rb
@@ -21,6 +21,31 @@
@parser = klass.new(part)
end
+ describe "#disclaimer" do
+ it do
+ @parser.disclaimer.should == "Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2010 Canadian Internet Registration Authority, (http://www.cira.ca/)"
+ end
+ end
+ describe "#domain" do
+ it do
+ @parser.domain.should == "google.ca"
+ end
+ end
+ describe "#domain_id" do
+ it do
+ lambda { @parser.domain_id }.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 "#referral_url" do
+ it do
+ lambda { @parser.referral_url }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
describe "#status" do
it do
@parser.status.should == :registered
@@ -63,6 +88,63 @@
@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 == nil
+ @parser.registrant_contacts[0].name.should == "Google Inc."
+ @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_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
+ 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 == nil
+ @parser.admin_contacts[0].name.should == "Christina Chiou"
+ @parser.admin_contacts[0].organization.should == nil
+ @parser.admin_contacts[0].address.should == "130 King St. W., Suite 1800,\nToronto ON M5X1E3 Canada"
+ @parser.admin_contacts[0].city.should == nil
+ @parser.admin_contacts[0].zip.should == nil
+ @parser.admin_contacts[0].state.should == nil
+ @parser.admin_contacts[0].country_code.should == nil
+ @parser.admin_contacts[0].phone.should == "+1.4168653361x"
+ @parser.admin_contacts[0].fax.should == "+1.4169456616"
+ @parser.admin_contacts[0].email.should == "dns-admin@google.com"
+ 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 == nil
+ @parser.technical_contacts[0].name.should == "Matt Serlin"
+ @parser.technical_contacts[0].organization.should == nil
+ @parser.technical_contacts[0].address.should == "Domain Provisioning,10400 Overland Rd. PMB 155\nBoise ID 83709 United States"
+ @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_code.should == nil
+ @parser.technical_contacts[0].phone.should == "+1.2083895740x"
+ @parser.technical_contacts[0].fax.should == "+1.2083895771"
+ @parser.technical_contacts[0].email.should == "ccops@markmonitor.com"
+ end
+ end
describe "#nameservers" do
it do
@parser.nameservers.should be_a(Array)
Please sign in to comment.
Something went wrong with that request. Please try again.