Skip to content

Commit

Permalink
Merge branch 'whois.tucows.com'
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Aug 4, 2012
2 parents 744075f + 869fc43 commit 80561cb
Show file tree
Hide file tree
Showing 6 changed files with 424 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* NEW: Added full whois.register.com parser.

* NEW: Added full whois.tucows.com parser.


## Release 2.6.4

Expand Down
5 changes: 3 additions & 2 deletions lib/whois/record/parser/whois.godaddy.com.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def build_contact(element, type)
match = content_for_scanner.slice(/#{element}\n((.+\n)+)\n/, 1)
return unless match

lines = $1.split("\n").map(&:strip)

# Lines 1 and 5 may be absent, depending on the record.
# The parser attempts to correct for this, but may be a bit flaky
# on non-standard data.
Expand All @@ -102,6 +100,9 @@ def build_contact(element, type)
# 3 Scottsdale, Arizona 85260
# 4 United States
# 5 +1.4805058800 Fax -- +1.4805058844

lines = $1.split("\n").map(&:strip)

phone = nil
fax = nil
if lines[-1].to_s =~ /Fax --/
Expand Down
122 changes: 122 additions & 0 deletions lib/whois/record/parser/whois.tucows.com.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
#++


require 'whois/record/parser/base'


module Whois
class Record
class Parser

# Parser for the whois.tucows.com server.
#
# @see Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
class WhoisTucowsCom < Base

property_not_supported :status

# The server is contacted only in case of a registered domain.
property_supported :available? do
false
end

property_supported :registered? do
!available?
end


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

property_supported :updated_on do
if content_for_scanner =~ /Record last updated on (.+)\.\n/
Time.parse($1)
end
end

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


property_supported :registrar do
Record::Registrar.new(
:name => 'Tucows',
:organization => 'Tucows',
:url => 'http://www.tucows.com/'
)
end

property_supported :registrant_contacts do
build_contact('Registrant:', Record::Contact::TYPE_REGISTRANT)
end

property_supported :admin_contacts do
build_contact('Administrative Contact', Record::Contact::TYPE_ADMIN)
end

property_supported :technical_contacts do
build_contact('Technical Contact', Record::Contact::TYPE_TECHNICAL)
end


property_supported :nameservers do
if content_for_scanner =~ /Domain servers in listed order:\n((.+\n)+)\n/
$1.split("\n").map do |line|
Record::Nameserver.new(:name => line.strip.downcase)
end
end
end


private

def build_contact(element, type)
match = content_for_scanner.slice(/#{element}.*\n((.*\n){5})/, 1)
return unless match

# 0 Almahdi, Ahmad alatol@yahoo.com
# 1 1-183 Carroll Street
# 2 Dunedin, 9001
# 3 NZ
# 4 +1.6434701257

lines = $1.split("\n")

name, email = if lines[0].index('@')
lines[0].scan(/(.+) (.*)/).first.map(&:strip)
else
lines[0].strip
end
city, zip = lines[2].scan(/(.+?), ([^\s]+)/).first.map(&:strip)
phone = lines[4].strip if lines[4]

Record::Contact.new(
:type => type,
:name => name,
:organization => nil,
:address => lines[1].strip,
:city => city,
:state => nil,
:zip => zip,
:country_code => lines[3].strip,
:email => email,
:phone => phone
)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#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("2006-03-06")

#updated_on
should: %s CLASS(time)
should: %s == Time.parse("2012-03-19")

#expires_on
should: %s CLASS(time)
should: %s == Time.parse("2013-03-06")


#registrar
should: %s CLASS(registrar)
should: %s.name == "Tucows"
should: %s.organization == "Tucows"
should: %s.url == "http://www.tucows.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 == "Wadadiah"
should: %s[0].organization == nil
should: %s[0].address == "1-183 Carroll Street"
should: %s[0].city == "Dunedin"
should: %s[0].zip == "9001"
should: %s[0].state == nil
should: %s[0].country_code == "NZ"
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 == "Almahdi, Ahmad"
should: %s[0].organization == nil
should: %s[0].address == "1-183 Carroll Street"
should: %s[0].city == "Dunedin"
should: %s[0].zip == "9001"
should: %s[0].state == nil
should: %s[0].country_code == "NZ"
should: %s[0].phone == "+1.6434701257"
should: %s[0].fax == nil
should: %s[0].email == "alatol@yahoo.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 == "Almahdi, Ahmad"
should: %s[0].organization == nil
should: %s[0].address == "1-183 Carroll Street"
should: %s[0].city == "Dunedin"
should: %s[0].zip == "9001"
should: %s[0].state == nil
should: %s[0].country_code == "NZ"
should: %s[0].phone == "+1.6434701257"
should: %s[0].fax == nil
should: %s[0].email == "alatol@yahoo.com"


#nameservers
should: %s CLASS(array)
should: %s SIZE(2)
should: %s[0] CLASS(nameserver)
should: %s[0].name == "ns5.ixwebhosting.com"
should: %s[1] CLASS(nameserver)
should: %s[1].name == "ns6.ixwebhosting.com"
83 changes: 83 additions & 0 deletions spec/fixtures/responses/whois.tucows.com/status_registered.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Registrant:
Wadadiah
1-183 Carroll Street
Dunedin, 9001
NZ

Domain name: SS-NZ.COM


Administrative Contact:
Almahdi, Ahmad alatol@yahoo.com
1-183 Carroll Street
Dunedin, 9001
NZ
+1.6434701257
Technical Contact:
Almahdi, Ahmad alatol@yahoo.com
1-183 Carroll Street
Dunedin, 9001
NZ
+1.6434701257


Registration Service Provider:
Ecommerce, Inc., registrars@ecommerce.com
800-861-9394
http://ecommerce.com
UNLIMITED Storage Space, Monthly Transfer, and up-to 15 domains,
starting at $3.95!

FREE DOMAIN REGISTRATIONS WITH EVERY HOSTING ACCOUNT + FREE FEATURES
INCLUDED. ONLY AT ECOMMERCE.COM


Registrar of Record: TUCOWS, INC.
Record last updated on 19-Mar-2012.
Record expires on 06-Mar-2013.
Record created on 06-Mar-2006.

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

Domain servers in listed order:
NS5.IXWEBHOSTING.COM
NS6.IXWEBHOSTING.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.


Loading

0 comments on commit 80561cb

Please sign in to comment.