Skip to content

Commit

Permalink
Fix issue with whois.tucows.com when the response contains a fax
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Aug 4, 2012
1 parent 0884569 commit bae2dbb
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/whois/record/parser/whois.tucows.com.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def build_contact(element, type)
lines[0].strip
end
city, state, zip = lines[2].scan(/(.+?), ([^\s]*?) (.+)/).first.map(&:strip)
#city, zip = lines[2].scan(/(.+?), ([^\s]+)/).first.map(&:strip)
phone = lines[4].strip if lines[4]
phone, fax = if lines[4]
lines[4].match(/\s+(.+?)\s*(?:Fax: (.+))?$/).to_a[1,2]
end

Record::Contact.new(
:type => type,
Expand All @@ -114,7 +115,8 @@ def build_contact(element, type)
:zip => zip,
:country_code => lines[3].strip,
:email => email,
:phone => phone
:phone => phone,
:fax => fax
)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#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 == "Administrator, Domain"
should: %s[0].organization == nil
should: %s[0].address == "95 Hayden Avenue"
should: %s[0].city == "Lexington"
should: %s[0].zip == "02421"
should: %s[0].state == "MA"
should: %s[0].country_code == "US"
should: %s[0].phone == "+1.7816526199"
should: %s[0].fax == "+1.7816526096"
should: %s[0].email == "csadmin@vistaprint.com"
81 changes: 81 additions & 0 deletions spec/fixtures/responses/whois.tucows.com/property_contacts_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Registrant:
VistaPrint Technologies Ltd
Canon's Court
22 Victoria Street
Hamilton, HM12
BM

Domain name: LEDVERLICHTINGSOEST.COM


Administrative Contact:
Administrator, Domain csadmin@vistaprint.com
95 Hayden Avenue
Lexington, MA 02421
US
+1.7816526199 Fax: +1.7816526096

Technical Contact:
Administrator, Domain csadmin@vistaprint.com
95 Hayden Ave.
Lexington, MA 02421
US
+1.7816526199 Fax: +1.7816526096



Registration Service Provider:
Vistaprint, csadmin@vistaprint.com
866-811-1674



Registrar of Record: TUCOWS, INC.
Record last updated on 05-Jun-2012.
Record expires on 19-Jun-2013.
Record created on 19-Jun-2008.

Registrar Domain Name Help Center:
http://tucowsdomains.com

Domain servers in listed order:
NS4.VPWEB.COM
NS3.VPWEB.COM


Domain status: clientTransferProhibited
clientUpdateProhibited

The Data in the Tucows Registrar WHOIS database is provided to you by Tucows
for information purposes only, and may be used to assist you in obtaining
information about or related to a domain name's registration record.

Tucows 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:
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 any Registry Operator or
ICANN-Accredited registrar, except as reasonably necessary to register
domain names or modify existing registrations.

The compilation, repackaging, dissemination or other use of this Data is
expressly prohibited without the prior written consent of Tucows.

Tucows reserves the right to terminate your access to the Tucows WHOIS
database in its sole discretion, including without limitation, for excessive
querying of the WHOIS database or for failure to otherwise abide by this
policy.

Tucows reserves the right to modify these terms at any time.

By submitting this query, you agree to abide by these terms.

NOTE: THE WHOIS DATABASE IS A CONTACT DATABASE ONLY. LACK OF A DOMAIN
RECORD DOES NOT SIGNIFY DOMAIN AVAILABILITY.


Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.tucows.com/property_contacts_2.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#

require 'spec_helper'
require 'whois/record/parser/whois.tucows.com.rb'

describe Whois::Record::Parser::WhoisTucowsCom, "property_contacts_2.expected" do

before(:each) do
file = fixture("responses", "whois.tucows.com/property_contacts_2.txt")
part = Whois::Record::Part.new(:body => File.read(file))
@parser = klass.new(part)
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 == "Administrator, Domain"
@parser.admin_contacts[0].organization.should == nil
@parser.admin_contacts[0].address.should == "95 Hayden Avenue"
@parser.admin_contacts[0].city.should == "Lexington"
@parser.admin_contacts[0].zip.should == "02421"
@parser.admin_contacts[0].state.should == "MA"
@parser.admin_contacts[0].country_code.should == "US"
@parser.admin_contacts[0].phone.should == "+1.7816526199"
@parser.admin_contacts[0].fax.should == "+1.7816526096"
@parser.admin_contacts[0].email.should == "csadmin@vistaprint.com"
end
end
end

0 comments on commit bae2dbb

Please sign in to comment.