Skip to content

Commit

Permalink
Merge pull request weppos#11 from cramerdev/fastdomain
Browse files Browse the repository at this point in the history
Create whois.fastdomain.com parser
  • Loading branch information
Travis Palmer committed Jun 21, 2012
2 parents 8b44758 + da536fc commit 8dc9565
Show file tree
Hide file tree
Showing 4 changed files with 405 additions and 0 deletions.
105 changes: 105 additions & 0 deletions lib/whois/record/parser/whois.fastdomain.com.rb
@@ -0,0 +1,105 @@
#--
# 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.fastdomain.com server.
#
# @see Whois::Record::Parser::Example
# The Example parser for the list of all available methods.
#
# @author Justin Campbell <justin@cramerdev.me>
#
class WhoisFastdomainCom < Base
property_supported(:status) { :registered }
property_supported(:available?) { false }
property_supported(:registered?) { true }

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

property_supported :updated_on do
if content_for_scanner =~ /Last modified on\.+: (.+)$/
Time.parse($1)
end
end

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

property_supported :registrar do
Record::Registrar.new(
:name => "FastDomain",
:organization => "FastDomain Inc.",
:url => "http://www.fastdomain.com"
)
end

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

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

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

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

private

def build_contact(element, type)
content_match = content_for_scanner.match(/#{element}\:\s\((.+)\)\n((\s+.*){7,9})/)
return unless content_match
id, contact = content_match.captures
return unless contact

contact = contact.lines.map(&:strip).join("\n")

match = contact.match(/
(?<name>.+)\n
(?<address>(.|\n)+)\n
(?<city>.+),\s(?<state>.+) (?<zip>.+)\n
(?<country>.+)\n
Phone:\s(?<phone>.+)?\n?
Fax\.\.:\s(?<fax>.+)?\n?
Email:\s(?<email>.+)?
/x)

return unless match

attributes = { :type => type, :id => id }

match.names.each do |name|
attributes[name.to_sym] = match[name].strip if match[name]
end

Record::Contact.new attributes
end
end
end
end
end
@@ -0,0 +1,91 @@
#status
should: %s == :registered

#available?
should: %s == false

#registered?
should: %s == true


#created_on
should: %s CLASS(time)
should: %s == Time.parse("2002-11-07 05:49:33 GMT")

#updated_on
should: %s CLASS(time)
should: %s == Time.parse("2012-04-19 17:40:46 GMT")

#expires_on
should: %s CLASS(time)
should: %s == Time.parse("2017-11-07 05:49:33 GMT")


#registrar
should: %s CLASS(registrar)
should: %s.id == nil
should: %s.name == "FastDomain"
should: %s.organization == "FastDomain Inc."
should: %s.url == "http://www.fastdomain.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].id == "FAST-18447012"
should: %s[0].name == "Domain Privacy Service"
should: %s[0].organization == nil
should: %s[0].address == "1958 South 950 East"
should: %s[0].city == "Provo"
should: %s[0].state == "Utah"
should: %s[0].zip == "-"
should: %s[0].country == "United States"
should: %s[0].phone == "+1.8014948462"
should: %s[0].fax == nil
should: %s[0].email == "whois@fastdomain.com"

#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].id == "FAST-18447012"
should: %s[0].name == "Domain Privacy Service"
should: %s[0].organization == nil
should: %s[0].address == "1958 South 950 East"
should: %s[0].city == "Provo"
should: %s[0].state == "Utah"
should: %s[0].zip == "-"
should: %s[0].country == "United States"
should: %s[0].phone == "+1.8014948462"
should: %s[0].fax == nil
should: %s[0].email == "whois@fastdomain.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].id == "FAST-18447012"
should: %s[0].name == "Domain Privacy Service"
should: %s[0].organization == nil
should: %s[0].address == "1958 South 950 East"
should: %s[0].city == "Provo"
should: %s[0].state == "Utah"
should: %s[0].zip == "-"
should: %s[0].country == "United States"
should: %s[0].phone == "+1.8014948462"
should: %s[0].fax == nil
should: %s[0].email == "whois@fastdomain.com"


#nameservers
should: %s CLASS(array)
should: %s SIZE(2)
should: %s[0] CLASS(nameserver)
should: %s[0].name == "ns1.fastdomain.com"
should: %s[0].ipv4 == nil
should: %s[1] CLASS(nameserver)
should: %s[1].name == "ns2.fastdomain.com"
should: %s[1].ipv4 == nil
74 changes: 74 additions & 0 deletions spec/fixtures/responses/whois.fastdomain.com/status_registered.txt
@@ -0,0 +1,74 @@
The data in the FastDomain Inc. WHOIS database is provided
to you by FastDomain Inc. for information purposes only,
that is, to assist you in obtaining information about or related to
a domain name registration record. FastDomain Inc. 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: (1) allow, enable, or otherwise support
the transmission of mass unsolicited, commercial advertising or
solicitations via direct mail, electronic mail, or by telephone; or
(2) enable high volume, automated, electronic processes that apply
to FastDomain Inc. (or its systems). The compilation,
repackaging, dissemination or other use of this data is expressly
prohibited without the prior written consent of
FastDomain Inc.. FastDomain Inc. reserves the
right to modify these terms at any time. By submitting this query,
you agree to abide by these terms.

=-=-=-=

Registrar: FastDomain Inc.
Provider Name....: FastDomain Inc.
Provider Whois...: whois.fastdomain.com
Provider Homepage: http://www.fastdomain.com/

Domain Name: FASTDOMAIN.COM

Created on..............: 2002-11-07 05:49:33 GMT
Expires on..............: 2017-11-07 05:49:33 GMT
Last modified on........: 2012-04-19 17:40:46 GMT

Registrant Info: (FAST-18447012)

Domain Privacy Service
1958 South 950 East
Provo, Utah -
United States
Phone: +1.8014948462
Fax..:
Email: whois@fastdomain.com
Last modified: 2012-06-11 20:32:05 GMT

Administrative Info: (FAST-18447012)

Domain Privacy Service
1958 South 950 East
Provo, Utah -
United States
Phone: +1.8014948462
Fax..:
Email: whois@fastdomain.com
Last modified: 2012-06-11 20:32:05 GMT

Technical Info: (FAST-18447012)

Domain Privacy Service
1958 South 950 East
Provo, Utah -
United States
Phone: +1.8014948462
Fax..:
Email: whois@fastdomain.com
Last modified: 2012-06-11 20:32:05 GMT

Status: Active

Domain servers in listed order:

NS1.FASTDOMAIN.COM
NS2.FASTDOMAIN.COM
=-=-=-=

Now UNLIMITED Storage and UNLIMITED Bandwidth and Host UNLIMITED Domains on one account for ONLY $6.95 per month.
You also get a *FREE* DOMAIN REGISTRATION for one year when you host with http://www.fastdomain.com/

0 comments on commit 8dc9565

Please sign in to comment.