Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated the whois.networksolutions.com parser to handle more contact …

…formats
  • Loading branch information...
commit 515e4752157bb829285ce6d9b9e16a78e9e9948c 1 parent 08f8689
@bramp authored
View
48 lib/whois/record/parser/whois.networksolutions.com.rb
@@ -91,37 +91,47 @@ class WhoisNetworksolutionsCom < Base
private
def build_contact(element, type)
- match = content_for_scanner.slice(/#{element}.*\n((.+\n){5,7})/, 1)
+ match = content_for_scanner.slice(/#{element}.*\n((.+\n){4,7})/, 1)
return unless match
lines = match.split("\n").map(&:strip)
- # 0 XIF Communications
- # 1 1200 New Hampshire Avenue NW
- # 2 Suite 410
- # 3 Washington, DC 20036
+ # 0 XIF Communications | mpowers LLC
+ # 1 1200 New Hampshire Avenue NW | 21010 Southbank St #575
+ # 2 Suite 410 | Potomac Falls, VA 20165
+ # 3 Washington, DC 20036 | US
# 4 US
-
- # 0 Communications, XIF ContactMiddleName noc@xif.com
- # 1 XIF Communications
- # 2 1200 New Hampshire Avenue NW
- # 3 Suite 410
- # 4 Washington, DC 20036
+
+ # 0 Communications, XIF ContactMiddleName noc@xif.com | mpowers LLC michael@mpowers.net
+ # 1 XIF Communications | 21010 Southbank St #575
+ # 2 1200 New Hampshire Avenue NW | Potomac Falls, VA 20165
+ # 3 Suite 410 | US
+ # 4 Washington, DC 20036 | +1.5712832829
# 5 US
# 6 202-463-7200 fax: 202-318-4003
- if lines.length == 7 then
+ # Does the first line end in something that looks like a email address?
+ if lines[0].to_s =~ /\S+@\S+$/
# The record has a extra name and number line
- name, email = lines[0].scan(/^(.+)\s(\S+@\S+)$/).first
- phone, fax = lines[6].scan(/^(.+) fax: (.+)$/).first
+ name, email = lines.shift.scan(/^(.+)\s(\S+@\S+)$/).first
name = name.strip
- lines.shift
end
- organization = lines[0]
- address = lines[1] + "\n" + lines[2]
- city, state, zip = lines[3].scan(/^(.+), ([A-Z]{2}) ([0-9]+)$/).first
- country_code = lines[4]
+ # Does the last line contains the word fax, or has >9 digits
+ if lines[-1].to_s =~ / fax: /
+ phone, fax = lines.pop.to_s.scan(/^(.+) fax: (.+)$/).first
+ phone = phone.strip
+ fax = fax.strip
+
+ elsif lines[-1].to_s.gsub(/[^\d]+/, '').length > 9
+ phone = lines.pop
+ end
+
+ country_code = lines.pop
+ city, state, zip = lines.pop.scan(/^(.+), ([A-Z]{2}) ([\sA-Z0-9\-]+)$/).first
+ organization = lines.shift if lines.length >= 2
+
+ address = lines.join("\n")
Record::Contact.new(
:type => type,
View
47 spec/fixtures/responses/whois.networksolutions.com/property_contact_short.expected
@@ -0,0 +1,47 @@
+
+#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].organization == "mpowers LLC"
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ 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 == "mpowers LLC"
+ should: %s[0].organization == nil
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5712832829"
+ should: %s[0].fax == nil
+ should: %s[0].email == "michael@mpowers.net"
+
+#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 == "mpowers LLC"
+ should: %s[0].organization == nil
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5712832829"
+ should: %s[0].fax == nil
+ should: %s[0].email == "michael@mpowers.net"
View
21 spec/fixtures/responses/whois.networksolutions.com/property_contact_short.txt
@@ -0,0 +1,21 @@
+
+Registrant:
+mpowers LLC
+ 21010 Southbank St #575
+ Potomac Falls, VA 20165
+ US
+
+ Domain Name: APPTAP.COM
+
+ ------------------------------------------------------------------------
+ Promote your business to millions of viewers for only $1 a month
+ Learn how you can get an Enhanced Business Listing here for your domain name.
+ Learn more at http://www.NetworkSolutions.com/
+ ------------------------------------------------------------------------
+
+ Administrative Contact, Technical Contact:
+ mpowers LLC michael@mpowers.net
+ 21010 Southbank St #575
+ Potomac Falls, VA 20165
+ US
+ +1.5712832829
Please sign in to comment.
Something went wrong with that request. Please try again.