Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix whois.register.com parser for enom formats #181

Merged
merged 1 commit into from

4 participants

@justincampbell
whois -h whois.register.com register.com
whois -h whois.register.com cramerdev.com

These seem to return different formats, and this commit addresses the issue. If there is a better way to delegate to the whois.enom.com parser (which is the format is appears to be in) I'd be glad to fix it properly if you could point me in the right direction.

@travisbot

This pull request fails (merged 829c450 into 4673715).

@weppos weppos merged commit dcb657f into from
@weppos weppos was assigned
@weppos weppos referenced this pull request from a commit
@weppos Update CHANGELOG for GH-181 ef29278
@coveralls

Coverage Status

Changes Unknown when pulling 829c450 on justincampbell:register-enom into ** on weppos:master**.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2012
  1. @justincampbell
This page is out of date. Refresh to see the latest.
View
54 lib/whois/record/parser/whois.register.com.rb
@@ -33,7 +33,7 @@ class WhoisRegisterCom < Base
property_supported :created_on do
- if content_for_scanner =~ /Created on\.+: (.+)\n/
+ if content_for_scanner =~ /(?:Created on\.+|Creation date): (.+)\n/
Time.parse($1)
end
end
@@ -41,7 +41,7 @@ class WhoisRegisterCom < Base
property_not_supported :updated_on
property_supported :expires_on do
- if content_for_scanner =~ /Expires on\.+: (.+)\n/
+ if content_for_scanner =~ /(?:Expires on\.+|Expiration date): (.+)\n/
Time.parse($1)
end
end
@@ -56,20 +56,20 @@ class WhoisRegisterCom < Base
end
property_supported :registrant_contacts do
- build_contact('Registrant:', Record::Contact::TYPE_REGISTRANT)
+ build_contact(/Registrant(?: Contact)?:/, Record::Contact::TYPE_REGISTRANT)
end
property_supported :admin_contacts do
- build_contact('Administrative Contact:', Record::Contact::TYPE_ADMIN)
+ build_contact(/Administrative Contact:/, Record::Contact::TYPE_ADMIN)
end
property_supported :technical_contacts do
- build_contact('Technical Contact:', Record::Contact::TYPE_TECHNICAL)
+ build_contact(/Technical\s+Contact:/, Record::Contact::TYPE_TECHNICAL)
end
property_supported :nameservers do
- if content_for_scanner =~ /DNS Servers:\n((.+\n)+)\n/
+ if content_for_scanner =~ /(?:DNS|Name) Servers:\n((.+\n)+)\n/
$1.split("\n").map do |line|
Record::Nameserver.new(:name => line.strip)
end
@@ -80,6 +80,14 @@ class WhoisRegisterCom < Base
private
def build_contact(element, type)
+ if content_for_scanner.match /DNS Servers/
+ build_register_contact(element, type)
+ else
+ build_enom_contact(element, type)
+ end
+ end
+
+ def build_register_contact(element, type)
match = content_for_scanner.slice(/#{element}\n((.+\n){7})/, 1)
return unless match
@@ -109,6 +117,40 @@ def build_contact(element, type)
)
end
+ def build_enom_contact(element, type)
+ match = content_for_scanner.slice(/#{element}\n(((\s{3}+.*)\n)+)/, 1)
+ return unless match
+
+ # 0 AdBrite, Inc.
+ # 1 Host Master (hostmaster@adbrite.com)
+ # 2 4159750916
+ # 3 Fax:
+ # 4 731 Market Street, Suite 500
+ # 5 San Francisco, CA 94103
+ # 6 US
+
+ lines = match.split("\n").map(&:lstrip)
+ name, email = lines[1].match(/(.*)\((.*)\)/)[1..2].map(&:strip)
+ fax_match = lines[3].match(/Fax: (.*)/)
+ fax = fax_match[1] if fax_match
+ city, state, zip = lines[-2].match(/(.*),(.+?)(\d*)$/)[1..3].map(&:strip)
+
+ Record::Contact.new(
+ :type => type,
+ :id => nil,
+ :name => name,
+ :organization => lines[0],
+ :address => lines[4..-3].join("\n"),
+ :city => city,
+ :zip => zip,
+ :state => state,
+ :country_code => lines[-1],
+ :phone => lines[2] == "" ? nil : lines[2],
+ :fax => fax,
+ :email => email == "" ? nil : email
+ )
+ end
+
end
end
View
91 spec/fixtures/responses/whois.register.com/status_registered_2.expected
@@ -0,0 +1,91 @@
+#status
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#available?
+ should: %s == false
+
+#registered?
+ should: %s == true
+
+
+#created_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2002-03-14 00:19:48")
+
+#updated_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#expires_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2013-03-14 00:19:00")
+
+
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.id == nil
+ should: %s.name == "Register.com"
+ should: %s.url == "http://www.register.com/"
+
+
+#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].name == "Josh Cramer"
+ should: %s[0].organization == "Cramer Development"
+ should: %s[0].address == "226 S. Clinton Street"
+ should: %s[0].city == "Iowa City"
+ should: %s[0].zip == "52240"
+ should: %s[0].state == "IA"
+ should: %s[0].country_code == "US"
+ 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].name == "Host Master"
+ should: %s[0].organization == "Cramer Development Incorporated"
+ should: %s[0].address == "226 S Clinton St"
+ should: %s[0].city == "Iowa City"
+ should: %s[0].zip == "52245"
+ should: %s[0].state == "IA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5152920050"
+ should: %s[0].fax == nil
+ should: %s[0].email == "domains@cramerdev.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].name == "Host Master"
+ should: %s[0].organization == "Cramer Development Incorporated"
+ should: %s[0].address == "226 S Clinton St"
+ should: %s[0].city == "Iowa City"
+ should: %s[0].zip == "52245"
+ should: %s[0].state == "IA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5152920050"
+ should: %s[0].fax == nil
+ should: %s[0].email == "domains@cramerdev.com"
+
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(5)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "dns01.gpn.register.com"
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "dns02.gpn.register.com"
+ should: %s[2] CLASS(nameserver)
+ should: %s[2].name == "dns03.gpn.register.com"
+ should: %s[3] CLASS(nameserver)
+ should: %s[3].name == "dns04.gpn.register.com"
+ should: %s[4] CLASS(nameserver)
+ should: %s[4].name == "dns05.gpn.register.com"
View
91 spec/fixtures/responses/whois.register.com/status_registered_2.txt
@@ -0,0 +1,91 @@
+
+The data in Register.com's WHOIS database is provided to you by
+Register.com for information purposes only, that is, to assist you in
+obtaining information about or related to a domain name registration
+record. Register.com makes this information available "as is," and
+does not guarantee its accuracy. By submitting a WHOIS query, you
+agree that you will use this data only for lawful purposes and that,
+under no circumstances will you use this data to: (1) allow, enable,
+or otherwise support the transmission of mass unsolicited, commercial
+advertising or solicitations via direct mail, electronic mail, or by
+telephone; or (2) enable high volume, automated, electronic processes
+that apply to Register.com (or its systems). The compilation,
+repackaging, dissemination or other use of this data is expressly
+prohibited without the prior written consent of Register.com.
+Register.com reserves the right to modify these terms at any time.
+By submitting this query, you agree to abide by these terms.
+
+
+=-=-=-=
+
+
+Domain name: cramerdev.com
+ Is the domain you want taken? Make an offer: http://www.afternic.com/rcom.php?ref_id=2987&name=cramerdev.com
+
+Registrant Contact:
+ Cramer Development
+ Josh Cramer ()
+
+ Fax:
+ 226 S. Clinton Street
+ Iowa City, IA 52240
+ US
+
+Administrative Contact:
+ Cramer Development Incorporated
+ Host Master (domains@cramerdev.com)
+ +1.5152920050
+ Fax:
+ 226 S Clinton St
+ Iowa City, IA 52245
+ US
+
+Technical Contact:
+ Cramer Development Incorporated
+ Host Master (domains@cramerdev.com)
+ +1.5152920050
+ Fax:
+ 226 S Clinton St
+ Iowa City, IA 52245
+ US
+
+Status: Locked
+
+Name Servers:
+ dns01.gpn.register.com
+ dns02.gpn.register.com
+ dns03.gpn.register.com
+ dns04.gpn.register.com
+ dns05.gpn.register.com
+
+Creation date: 14 Mar 2002 00:19:48
+Expiration date: 14 Mar 2013 00:19:00
+
+
+
+
+=-=-=-=
+The data in this whois database is provided to you for information
+purposes only, that is, to assist you in obtaining information about or
+related to a domain name registration record. We make this information
+available "as is," and do not guarantee its accuracy. By submitting a
+whois query, you agree that you will use this data only for lawful
+purposes and that, under no circumstances will you use this data to: (1)
+enable high volume, automated, electronic processes that stress or load
+this whois database system providing you this information; or (2) allow,
+enable, or otherwise support the transmission of mass unsolicited,
+commercial advertising or solicitations via direct mail, electronic
+mail, or by telephone. The compilation, repackaging, dissemination or
+other use of this data is expressly prohibited without prior written
+consent from us.
+
+We reserve the right to modify these terms at any time. By submitting
+this query, you agree to abide by these terms.
+Version 6.3 4/3/2002
+
+
+Visit AboutUs.org for more information about cramerdev.com
+
+<A HREF="http://www.aboutus.org/cramerdev.com">AboutUs: cramerdev.com</A>
+
+Register your domain name at http://www.register.com
View
134 spec/whois/record/parser/responses/whois.register.com/status_registered_2_spec.rb
@@ -0,0 +1,134 @@
+# 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.register.com/status_registered_2.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.register.com.rb'
+
+describe Whois::Record::Parser::WhoisRegisterCom, "status_registered_2.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.register.com/status_registered_2.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ end
+
+ describe "#status" do
+ it do
+ lambda { @parser.status }.should raise_error(Whois::PropertyNotSupported)
+ 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
+ @parser.created_on.should be_a(Time)
+ @parser.created_on.should == Time.parse("2002-03-14 00:19:48")
+ 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
+ @parser.expires_on.should be_a(Time)
+ @parser.expires_on.should == Time.parse("2013-03-14 00:19:00")
+ end
+ end
+ describe "#registrar" do
+ it do
+ @parser.registrar.should be_a(Whois::Record::Registrar)
+ @parser.registrar.id.should == nil
+ @parser.registrar.name.should == "Register.com"
+ @parser.registrar.url.should == "http://www.register.com/"
+ 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].name.should == "Josh Cramer"
+ @parser.registrant_contacts[0].organization.should == "Cramer Development"
+ @parser.registrant_contacts[0].address.should == "226 S. Clinton Street"
+ @parser.registrant_contacts[0].city.should == "Iowa City"
+ @parser.registrant_contacts[0].zip.should == "52240"
+ @parser.registrant_contacts[0].state.should == "IA"
+ @parser.registrant_contacts[0].country_code.should == "US"
+ @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].name.should == "Host Master"
+ @parser.admin_contacts[0].organization.should == "Cramer Development Incorporated"
+ @parser.admin_contacts[0].address.should == "226 S Clinton St"
+ @parser.admin_contacts[0].city.should == "Iowa City"
+ @parser.admin_contacts[0].zip.should == "52245"
+ @parser.admin_contacts[0].state.should == "IA"
+ @parser.admin_contacts[0].country_code.should == "US"
+ @parser.admin_contacts[0].phone.should == "+1.5152920050"
+ @parser.admin_contacts[0].fax.should == nil
+ @parser.admin_contacts[0].email.should == "domains@cramerdev.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].name.should == "Host Master"
+ @parser.technical_contacts[0].organization.should == "Cramer Development Incorporated"
+ @parser.technical_contacts[0].address.should == "226 S Clinton St"
+ @parser.technical_contacts[0].city.should == "Iowa City"
+ @parser.technical_contacts[0].zip.should == "52245"
+ @parser.technical_contacts[0].state.should == "IA"
+ @parser.technical_contacts[0].country_code.should == "US"
+ @parser.technical_contacts[0].phone.should == "+1.5152920050"
+ @parser.technical_contacts[0].fax.should == nil
+ @parser.technical_contacts[0].email.should == "domains@cramerdev.com"
+ end
+ end
+ describe "#nameservers" do
+ it do
+ @parser.nameservers.should be_a(Array)
+ @parser.nameservers.should have(5).items
+ @parser.nameservers[0].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[0].name.should == "dns01.gpn.register.com"
+ @parser.nameservers[1].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[1].name.should == "dns02.gpn.register.com"
+ @parser.nameservers[2].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[2].name.should == "dns03.gpn.register.com"
+ @parser.nameservers[3].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[3].name.should == "dns04.gpn.register.com"
+ @parser.nameservers[4].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[4].name.should == "dns05.gpn.register.com"
+ end
+ end
+end
Something went wrong with that request. Please try again.