Browse files

Added a whois.networksolutions.com parser.

  • Loading branch information...
1 parent 72ff788 commit dfa8742404b5a8a90653bf84017b1ea46187455f @bramp bramp committed May 28, 2012
View
130 lib/whois/record/parser/whois.networksolutions.com.rb
@@ -0,0 +1,130 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+# Copyright (c) 2012 Andrew Brampton <me@bramp.net>
+#++
+
+
+require 'whois/record/parser/base'
+
+
+module Whois
+ class Record
+ class Parser
+
+ # Parser for the whois.networksolutions.com server.
+ #
+ # @note This parser is just a stub and provides only a few basic methods
+ # to check for domain availability and get domain status.
+ # Please consider to contribute implementing missing methods.
+ #
+ # @see Whois::Record::Parser::Example
+ # The Example parser for the list of all available methods.
+ class WhoisNetworksolutionsCom < Base
+
+ property_not_supported :status
+
+ # The server is contacted only in case of a registered domain.
+ property_not_supported :available?
+ property_not_supported :registered?
+
+ property_not_supported :registrar
+
+ 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 =~ /Database 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 :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]+\n)+)/
+ $1.split("\n").map do |line|
+ # NS01.XIF.COM 63.240.200.70
+ dns = line.strip.split(" ")
+ Record::Nameserver.new(dns[0], dns[1])
+ end
+ end
+ end
+
+
+ private
+
+ def build_contact(element, type)
+ match = content_for_scanner.slice(/#{element}.*\n((.+\n){5,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
+ # 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
+ # 5 US
+ # 6 202-463-7200 fax: 202-318-4003
+
+ if lines.length == 7 then
+ # 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 = 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]
+
+ Record::Contact.new(
+ :type => type,
+ :name => name,
+ :organization => organization,
+ :address => address,
+ :city => city,
+ :state => state,
+ :zip => zip,
+ :country_code => country_code,
+ :email => email,
+ :phone => phone,
+ :fax => fax
+ )
+ end
+ end
+ end
+ end
+end
View
25 spec/fixtures/responses/whois.networksolutions.com/status_available.txt
@@ -0,0 +1,25 @@
+NOTICE AND TERMS OF USE: You are not authorized to access or query our WHOIS
+database through the use of high-volume, automated, electronic processes. The
+Data in Network Solutions' WHOIS database is provided by Network Solutions for information
+purposes only, and to assist persons in obtaining information about or related
+to a domain name registration record. Network Solutions does not guarantee its accuracy.
+By submitting a WHOIS query, you agree to abide by the following terms of use:
+You agree that you may 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 e-mail, telephone, or facsimile; or (2) enable high volume, automated,
+electronic processes that apply to Network Solutions (or its computer systems). The
+compilation, repackaging, dissemination or other use of this Data is expressly
+prohibited without the prior written consent of Network Solutions. You agree not to use
+high-volume, automated, electronic processes to access or query the WHOIS
+database. Network Solutions reserves the right to terminate your access to the 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.
+Network Solutions reserves the right to modify these terms at any time.
+
+Get a FREE domain name registration, transfer, or renewal with any annual hosting package.
+
+http://www.networksolutions.com
+
+No match for "BLAHBLAHBLAH.COM".
+
View
84 spec/fixtures/responses/whois.networksolutions.com/status_registered.expected
@@ -0,0 +1,84 @@
+#status
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#available?
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#registered?
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#created_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("1997-06-10")
+
+#updated_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2012-05-27 22:19:52 EDT")
+
+#expires_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2014-06-09")
+
+
+#registrar
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+
+#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 == nil
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ 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 == "Communications, XIF ContactMiddleName"
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "202-463-7200"
+ should: %s[0].fax == "202-318-4003"
+ should: %s[0].email == "noc@xif.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 == "Communications, XIF ContactMiddleName"
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "202-463-7200"
+ should: %s[0].fax == "202-318-4003"
+ should: %s[0].email == "noc@xif.com"
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(3)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0] == _nameserver.new(:name => "NS01.XIF.COM", :ipv4 => "63.240.200.70")
+ should: %s[1] CLASS(nameserver)
+ should: %s[1] == _nameserver.new(:name => "NS-EAST.CERF.NET", :ipv4 => "207.252.96.3")
+ should: %s[2] CLASS(nameserver)
+ should: %s[2] == _nameserver.new(:name => "NS-WEST.CERF.NET", :ipv4 => "192.153.156.3")
View
66 spec/fixtures/responses/whois.networksolutions.com/status_registered.txt
@@ -0,0 +1,66 @@
+NOTICE AND TERMS OF USE: You are not authorized to access or query our WHOIS
+database through the use of high-volume, automated, electronic processes. The
+Data in Network Solutions' WHOIS database is provided by Network Solutions for information
+purposes only, and to assist persons in obtaining information about or related
+to a domain name registration record. Network Solutions does not guarantee its accuracy.
+By submitting a WHOIS query, you agree to abide by the following terms of use:
+You agree that you may 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 e-mail, telephone, or facsimile; or (2) enable high volume, automated,
+electronic processes that apply to Network Solutions (or its computer systems). The
+compilation, repackaging, dissemination or other use of this Data is expressly
+prohibited without the prior written consent of Network Solutions. You agree not to use
+high-volume, automated, electronic processes to access or query the WHOIS
+database. Network Solutions reserves the right to terminate your access to the 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.
+Network Solutions reserves the right to modify these terms at any time.
+
+Get a FREE domain name registration, transfer, or renewal with any annual hosting package.
+
+http://www.networksolutions.com
+
+Visit AboutUs.org for more information about XIF.COM
+<a href="http://www.aboutus.org/XIF.COM">AboutUs: XIF.COM </a>
+
+
+
+
+Registrant:
+XIF Communications
+ 1200 New Hampshire Avenue NW
+ Suite 410
+ Washington, DC 20036
+ US
+
+ Domain Name: XIF.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:
+ Communications, XIF ContactMiddleName noc@xif.com
+ XIF Communications
+ 1200 New Hampshire Avenue NW
+ Suite 410
+ Washington, DC 20036
+ US
+ 202-463-7200 fax: 202-318-4003
+
+
+ Record expires on 09-Jun-2014.
+ Record created on 10-Jun-1997.
+ Database last updated on 27-May-2012 22:19:52 EDT.
+
+ Domain servers in listed order:
+
+ NS01.XIF.COM 63.240.200.70
+ NS-EAST.CERF.NET 207.252.96.3
+ NS-WEST.CERF.NET 192.153.156.3
+
+
+

0 comments on commit dfa8742

Please sign in to comment.