Skip to content

Commit

Permalink
Parse whois.educause.edu contacts.
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed May 24, 2012
1 parent 8051510 commit 9b9b787
Show file tree
Hide file tree
Showing 40 changed files with 1,606 additions and 136 deletions.
120 changes: 101 additions & 19 deletions lib/whois/record/parser/whois.educause.edu.rb
Expand Up @@ -86,29 +86,18 @@ class WhoisEducauseEdu < Base
property_not_supported :registrar

property_supported :registrant_contacts do
if content_for_scanner =~ /Registrant:\n((.+\n)+)\n/
lines = $1.split("\n").map(&:strip)
build_contact_registrant("Registrant", Whois::Record::Contact::TYPE_REGISTRANT)
end

case lines[-2]
when /([^\n,]+),\s([A-Z]{2})(?:\s(\d{5}))/
city, state, zip = $1, $2, $3
else
city = lines[-2]
end
property_supported :admin_contacts do
build_contact("Administrative Contact", Whois::Record::Contact::TYPE_ADMIN)
end

Record::Contact.new(
:type => Whois::Record::Contact::TYPE_REGISTRANT,
:name => nil,
:organization => lines[0],
:address => lines[1..-3].join("\n"),
:city => city,
:state => state,
:zip => zip,
:country => lines[-1]
)
end
property_supported :technical_contacts do
build_contact("Technical Contact", Whois::Record::Contact::TYPE_TECHNICAL)
end


property_supported :nameservers do
if content_for_scanner =~ /Name Servers: \n((.+\n)+)\n/
$1.split("\n").map do |line|
Expand All @@ -118,6 +107,99 @@ class WhoisEducauseEdu < Base
end
end


private

# [NAME] | EMPTY
# [ROLE]?
# [ORGANIZATION]
# [ADDRESS]*
# [CITY, ST ZIP]
# [COUNTRY]
# [PHONE]
# [EMAIL]
def build_contact(element, type)
if content_for_scanner =~ /#{element}:\n+((.+\n)+)\n/
lines = $1.split("\n").map(&:strip)
items = lines.dup

# Extract variables

# items.shift if items[0].strip == ''

v13 = items.delete_at(-1)

v11 = items.delete_at(-1)

v9 = items.delete_at(-1)

v4 = []
until items[0] =~ /^\d+/
v4 << items.shift
end
v4 = v4.join("\n")

v6 = items.delete_at(-1)
if v6 =~ /([^\n,]+),\s([A-Z]{2})(?:\s(\d{5}(?:-\d{4})?))/
v6, v7, v8 = $1, $2, $3
end

v5 = items.empty? ? nil : items.join("\n")

# Create Contact

Record::Contact.new(
:type => type,
:name => v4,
:organization => nil,
:address => v5,
:city => v6,
:state => v7,
:zip => v8,
:country => v9,
:phone => v11,
:email => v13
)
end
end

# [ORGANIZATION]
# [ADDRESS]*
# [CITY, ST ZIP] | [CITY]
# [COUNTRY]
def build_contact_registrant(element, type)
if content_for_scanner =~ /#{element}:\n((.+\n)+)\n/
lines = $1.split("\n").map(&:strip)
items = lines.dup

# Extract variables

v9 = items.delete_at(-1)

v4 = items.delete_at(0)

v6 = items.delete_at(-1)
if v6 =~ /([^\n,]+),\s([A-Z]{2})(?:\s(\d{5}))/
v6, v7, v8 = $1, $2, $3
end

v5 = items.empty? ? nil : items.join("\n")

# Create Contact

Record::Contact.new(
:type => type,
:name => nil,
:organization => v4,
:address => v5,
:city => v6,
:state => v7,
:zip => v8,
:country => v9
)
end
end

end

end
Expand Down
63 changes: 63 additions & 0 deletions spec/fixtures/responses/whois.educause.edu/fixture1.txt
@@ -0,0 +1,63 @@

This Registry database contains ONLY .EDU domains.
The data in the EDUCAUSE Whois database is provided
by EDUCAUSE for information purposes in order to
assist in the process of obtaining information about
or related to .edu domain registration records.

The EDUCAUSE Whois database is authoritative for the
.EDU domain.

A Web interface for the .EDU EDUCAUSE Whois Server is
available at: http://whois.educause.net

By submitting a Whois query, you agree that this information
will not be used to allow, enable, or otherwise support
the transmission of unsolicited commercial advertising or
solicitations via e-mail. The use of electronic processes to
harvest information from this server is generally prohibited
except as reasonably necessary to register or modify .edu
domain names.

You may use "%" as a wildcard in your search. For further
information regarding the use of this WHOIS server, please
type: help

--------------------------

Domain Name: NIC.EDU

Registrant:
North Idaho College
1000 W. Garden Avenue
Coeur d'Alene, ID 83814
UNITED STATES

Administrative Contact:
NetAdmin
North Idaho College
1000 W. Garden Avenue
Coeur d Alene, ID 83814
UNITED STATES
(208) 769-7860
netsys@nic.edu

Technical Contact:
Dennis L Noordam
Windows System Administrator
North Idaho College
1000 W. Garden Avenue
Coeur d Alene, ID 83814
UNITED STATES
(208) 769-7860
dlnoordam@nic.edu

Name Servers:
NICNS1.NIC.EDU 198.187.233.211
NICNS2.NIC.EDU 198.187.233.212

Domain record activated: 20-Dec-1996
Domain record last updated: 29-Jun-2010
Domain expires: 31-Jul-2012


66 changes: 66 additions & 0 deletions spec/fixtures/responses/whois.educause.edu/fixture2.txt
@@ -0,0 +1,66 @@

This Registry database contains ONLY .EDU domains.
The data in the EDUCAUSE Whois database is provided
by EDUCAUSE for information purposes in order to
assist in the process of obtaining information about
or related to .edu domain registration records.

The EDUCAUSE Whois database is authoritative for the
.EDU domain.

A Web interface for the .EDU EDUCAUSE Whois Server is
available at: http://whois.educause.net

By submitting a Whois query, you agree that this information
will not be used to allow, enable, or otherwise support
the transmission of unsolicited commercial advertising or
solicitations via e-mail. The use of electronic processes to
harvest information from this server is generally prohibited
except as reasonably necessary to register or modify .edu
domain names.

You may use "%" as a wildcard in your search. For further
information regarding the use of this WHOIS server, please
type: help

--------------------------

Domain Name: HARVARD.EDU

Registrant:
Harvard University
HUIT Network Services
60 Oxford Street
Cambridge, MA 02138
UNITED STATES

Administrative Contact:
Jacques N Laflamme
Director, Network Services
Harvard University
60 Oxford Street
Cambridge, MA 02138
UNITED STATES
(617) 384-6663
jacques_laflamme@harvard.edu

Technical Contact:
Network Operations
Harvard University
HUIT Network Services
60 Oxford Street
Cambridge, MA 02138
UNITED STATES
(617) 495-7777
netmanager@harvard.edu

Name Servers:
EXTERNALDNS-C1.HARVARD.EDU 128.103.200.35
EXTERNALDNS-C2.HARVARD.EDU 128.103.200.51
EXTERNALDNS-C3.BR.HARVARD.EDU 128.119.3.185

Domain record activated: 27-Jun-1985
Domain record last updated: 19-Mar-2012
Domain expires: 31-Jul-2012


67 changes: 67 additions & 0 deletions spec/fixtures/responses/whois.educause.edu/fixture3.txt
@@ -0,0 +1,67 @@

This Registry database contains ONLY .EDU domains.
The data in the EDUCAUSE Whois database is provided
by EDUCAUSE for information purposes in order to
assist in the process of obtaining information about
or related to .edu domain registration records.

The EDUCAUSE Whois database is authoritative for the
.EDU domain.

A Web interface for the .EDU EDUCAUSE Whois Server is
available at: http://whois.educause.net

By submitting a Whois query, you agree that this information
will not be used to allow, enable, or otherwise support
the transmission of unsolicited commercial advertising or
solicitations via e-mail. The use of electronic processes to
harvest information from this server is generally prohibited
except as reasonably necessary to register or modify .edu
domain names.

You may use "%" as a wildcard in your search. For further
information regarding the use of this WHOIS server, please
type: help

--------------------------

Domain Name: STANFORD.EDU

Registrant:
Stanford University
The Board of Trustees of the Leland Stanford Junior University
241 Panama Street, Pine Hall, Room 115
Stanford, CA 94305-4122
UNITED STATES

Administrative Contact:

Domain Admin
Stanford University
241 Panama Street Pine Hall, Room 115
Stanford, CA 94305-4122
UNITED STATES
(650) 723-4328
sunet-admin@stanford.edu

Technical Contact:

Domain Admin
Stanford University
241 Panama Street Pine Hall, Room 115
Stanford, CA 94305-4122
UNITED STATES
(650) 723-4328
sunet-admin@stanford.edu

Name Servers:
ARGUS.STANFORD.EDU 171.64.7.115, 2607:f6d0:0:9113::ab40:773
AVALLONE.STANFORD.EDU 171.64.7.88, 2607:f6d0:0:9116::ab40:758
ATALANTE.STANFORD.EDU 171.64.7.61, 2607:f6d0:0:d32::ab40:73d
AERATHEA.STANFORD.EDU 152.3.104.250

Domain record activated: 04-Oct-1985
Domain record last updated: 07-May-2009
Domain expires: 31-Jul-2013


0 comments on commit 9b9b787

Please sign in to comment.