Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added whois.enom.com parser.

  • Loading branch information...
commit 1d412ead1fac016a885437423791a89eed673a8c 1 parent 92c3a41
@weppos authored
View
2  CHANGELOG.md
@@ -13,6 +13,8 @@
* NEW: Added full whois.cira.ca parser.
+* NEW: Added whois.enom.com parser.
+
* CHANGED: Moved scanners from Whois::Record::Parser::Scanners to Whois::Record::Scanners.
* FIXED: .IE availability checking returns incorrect results (GH-155)
View
123 lib/whois/record/parser/whois.enom.com.rb
@@ -0,0 +1,123 @@
+#--
+# 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.enom.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.
+ #
+ # @since RELEASE
+ class WhoisEnomCom < 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
+ true
+ end
+
+
+ property_supported :created_on do
+ if content_for_scanner =~ /Creation date: (.+)\n/
+ Time.parse($1)
+ end
+ end
+
+ property_not_supported :updated_on
+
+ property_supported :expires_on do
+ if content_for_scanner =~ /Expiration date: (.+)\n/
+ Time.parse($1)
+ end
+ end
+
+
+ property_supported :registrar do
+ Record::Registrar.new(
+ :name => "eNom Inc.",
+ :url => "http://www.enom.com/"
+ )
+ end
+
+ property_supported :registrant_contacts do
+ build_contact("Registrant Contact", 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 =~ /Name Servers:\n((\s+[^\s]+\n)+)/
+ $1.split("\n").map do |line|
+ Record::Nameserver.new(:name => line.strip)
+ end
+ end
+ end
+
+
+ private
+
+ def build_contact(element, type)
+ match = content_for_scanner.slice(/#{element}:\n((.+\n)+)/, 1)
+ return unless match
+
+ # 0 AdBrite, Inc.
+ # 1 Host Master (hostmaster@adbrite.com)
+ # 2 4159750916
+ # 3 Fax:
+ # 4 731 Market Street, Suite 500
+ # 5 San Francisco, CA 94103
+ # 6 US
+ lines = match.split("\n").map(&:strip)
+ name, email = lines[1].match(/(.+) \((.*)\)/)[1..2]
+ fax = lines[3].match(/Fax:(.*)/)[1]
+ city, state, zip = lines[5].match(/(.+), (.+?) (\d+)/)[1..3]
+
+ Record::Contact.new(
+ :type => type,
+ :id => nil,
+ :name => name,
+ :organization => lines[0],
+ :address => lines[4],
+ :city => city,
+ :zip => zip,
+ :state => state,
+ :country_code => lines[6],
+ :phone => lines[2],
+ :fax => fax,
+ :email => email
+ )
+ end
+
+ end
+
+ end
+ end
+end
View
97 spec/fixtures/responses/whois.enom.com/status_registered.expected
@@ -0,0 +1,97 @@
+#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("2004-06-16 18:07:25")
+
+#updated_on
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#expires_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2015-06-16 00:00:00")
+
+
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.id == nil
+ should: %s.name == "eNom Inc."
+ should: %s.url == "http://www.enom.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 == "Host Master"
+ should: %s[0].organization == "AdBrite, Inc."
+ should: %s[0].address == "731 Market Street, Suite 500"
+ should: %s[0].city == "San Francisco"
+ should: %s[0].zip == "94103"
+ should: %s[0].state == "CA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == ""
+ should: %s[0].fax == ""
+ should: %s[0].email == ""
+
+#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 == "Host Master"
+ should: %s[0].organization == "AdBrite, Inc."
+ should: %s[0].address == "731 Market Street, Suite 500"
+ should: %s[0].city == "San Francisco"
+ should: %s[0].zip == "94103"
+ should: %s[0].state == "CA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "4159750916"
+ should: %s[0].fax == ""
+ should: %s[0].email == "hostmaster@adbrite.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 == "Host Master"
+ should: %s[0].organization == "AdBrite, Inc."
+ should: %s[0].address == "731 Market Street, Suite 500"
+ should: %s[0].city == "San Francisco"
+ should: %s[0].zip == "94103"
+ should: %s[0].state == "CA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "4159750916"
+ should: %s[0].fax == ""
+ should: %s[0].email == "hostmaster@adbrite.com"
+
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(8)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "asia3.akam.net"
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "aus1.akam.net"
+ should: %s[2] CLASS(nameserver)
+ should: %s[2].name == "eur1.akam.net"
+ should: %s[3] CLASS(nameserver)
+ should: %s[3].name == "eur2.akam.net"
+ should: %s[4] CLASS(nameserver)
+ should: %s[4].name == "ns1-105.akam.net"
+ should: %s[5] CLASS(nameserver)
+ should: %s[5].name == "ns1-232.akam.net"
+ should: %s[6] CLASS(nameserver)
+ should: %s[6].name == "usc2.akam.net"
+ should: %s[7] CLASS(nameserver)
+ should: %s[7].name == "usw6.akam.net"
View
68 spec/fixtures/responses/whois.enom.com/status_registered.txt
@@ -0,0 +1,68 @@
+=-=-=-=
+
+
+Domain name: adbrite.com
+
+Registrant Contact:
+ AdBrite, Inc.
+ Host Master ()
+
+ Fax:
+ 731 Market Street, Suite 500
+ San Francisco, CA 94103
+ US
+
+Administrative Contact:
+ AdBrite, Inc.
+ Host Master (hostmaster@adbrite.com)
+ 4159750916
+ Fax:
+ 731 Market Street, Suite 500
+ San Francisco, CA 94103
+ US
+
+Technical Contact:
+ AdBrite, Inc.
+ Host Master (hostmaster@adbrite.com)
+ 4159750916
+ Fax:
+ 731 Market Street, Suite 500
+ San Francisco, CA 94103
+ US
+
+Status: Active
+
+Name Servers:
+ asia3.akam.net
+ aus1.akam.net
+ eur1.akam.net
+ eur2.akam.net
+ ns1-105.akam.net
+ ns1-232.akam.net
+ usc2.akam.net
+ usw6.akam.net
+
+Creation date: 16 Jun 2004 18:07:25
+Expiration date: 16 Jun 2015 00:00:00
+
+
+
+Get Noticed on the Internet! Increase visibility for this domain name by listing it at www.whoisbusinesslistings.com
+=-=-=-=
+The data in this whois database is provided to you for information
+purposes only, that is, to assist you in obtaining information about or
+related to a domain name registration record. We make this information
+available "as is," and do 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)
+enable high volume, automated, electronic processes that stress or load
+this whois database system providing you this information; or (2) allow,
+enable, or otherwise support the transmission of mass unsolicited,
+commercial advertising or solicitations via direct mail, electronic
+mail, or by telephone. The compilation, repackaging, dissemination or
+other use of this data is expressly prohibited without prior written
+consent from us.
+
+We reserve the right to modify these terms at any time. By submitting
+this query, you agree to abide by these terms.
+Version 6.3 4/3/2002
View
140 spec/whois/record/parser/responses/whois.enom.com/status_registered_spec.rb
@@ -0,0 +1,140 @@
+# encoding: utf-8
+
+# This file is autogenerated. Do not edit it manually.
+# If you want change the content of this file, edit
+#
+# /spec/fixtures/responses/whois.enom.com/status_registered.expected
+#
+# and regenerate the tests with the following rake task
+#
+# $ rake spec:generate
+#
+
+require 'spec_helper'
+require 'whois/record/parser/whois.enom.com.rb'
+
+describe Whois::Record::Parser::WhoisEnomCom, "status_registered.expected" do
+
+ before(:each) do
+ file = fixture("responses", "whois.enom.com/status_registered.txt")
+ part = Whois::Record::Part.new(:body => File.read(file))
+ @parser = klass.new(part)
+ end
+
+ describe "#status" do
+ it do
+ lambda { @parser.status }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#available?" do
+ it do
+ @parser.available?.should == false
+ end
+ end
+ describe "#registered?" do
+ it do
+ @parser.registered?.should == true
+ end
+ end
+ describe "#created_on" do
+ it do
+ @parser.created_on.should be_a(Time)
+ @parser.created_on.should == Time.parse("2004-06-16 18:07:25")
+ end
+ end
+ describe "#updated_on" do
+ it do
+ lambda { @parser.updated_on }.should raise_error(Whois::PropertyNotSupported)
+ end
+ end
+ describe "#expires_on" do
+ it do
+ @parser.expires_on.should be_a(Time)
+ @parser.expires_on.should == Time.parse("2015-06-16 00:00:00")
+ end
+ end
+ describe "#registrar" do
+ it do
+ @parser.registrar.should be_a(Whois::Record::Registrar)
+ @parser.registrar.id.should == nil
+ @parser.registrar.name.should == "eNom Inc."
+ @parser.registrar.url.should == "http://www.enom.com/"
+ end
+ end
+ describe "#registrant_contacts" do
+ it do
+ @parser.registrant_contacts.should be_a(Array)
+ @parser.registrant_contacts.should have(1).items
+ @parser.registrant_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
+ @parser.registrant_contacts[0].name.should == "Host Master"
+ @parser.registrant_contacts[0].organization.should == "AdBrite, Inc."
+ @parser.registrant_contacts[0].address.should == "731 Market Street, Suite 500"
+ @parser.registrant_contacts[0].city.should == "San Francisco"
+ @parser.registrant_contacts[0].zip.should == "94103"
+ @parser.registrant_contacts[0].state.should == "CA"
+ @parser.registrant_contacts[0].country_code.should == "US"
+ @parser.registrant_contacts[0].phone.should == ""
+ @parser.registrant_contacts[0].fax.should == ""
+ @parser.registrant_contacts[0].email.should == ""
+ end
+ end
+ describe "#admin_contacts" do
+ it do
+ @parser.admin_contacts.should be_a(Array)
+ @parser.admin_contacts.should have(1).items
+ @parser.admin_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.admin_contacts[0].type.should == Whois::Record::Contact::TYPE_ADMIN
+ @parser.admin_contacts[0].name.should == "Host Master"
+ @parser.admin_contacts[0].organization.should == "AdBrite, Inc."
+ @parser.admin_contacts[0].address.should == "731 Market Street, Suite 500"
+ @parser.admin_contacts[0].city.should == "San Francisco"
+ @parser.admin_contacts[0].zip.should == "94103"
+ @parser.admin_contacts[0].state.should == "CA"
+ @parser.admin_contacts[0].country_code.should == "US"
+ @parser.admin_contacts[0].phone.should == "4159750916"
+ @parser.admin_contacts[0].fax.should == ""
+ @parser.admin_contacts[0].email.should == "hostmaster@adbrite.com"
+ end
+ end
+ describe "#technical_contacts" do
+ it do
+ @parser.technical_contacts.should be_a(Array)
+ @parser.technical_contacts.should have(1).items
+ @parser.technical_contacts[0].should be_a(Whois::Record::Contact)
+ @parser.technical_contacts[0].type.should == Whois::Record::Contact::TYPE_TECHNICAL
+ @parser.technical_contacts[0].name.should == "Host Master"
+ @parser.technical_contacts[0].organization.should == "AdBrite, Inc."
+ @parser.technical_contacts[0].address.should == "731 Market Street, Suite 500"
+ @parser.technical_contacts[0].city.should == "San Francisco"
+ @parser.technical_contacts[0].zip.should == "94103"
+ @parser.technical_contacts[0].state.should == "CA"
+ @parser.technical_contacts[0].country_code.should == "US"
+ @parser.technical_contacts[0].phone.should == "4159750916"
+ @parser.technical_contacts[0].fax.should == ""
+ @parser.technical_contacts[0].email.should == "hostmaster@adbrite.com"
+ end
+ end
+ describe "#nameservers" do
+ it do
+ @parser.nameservers.should be_a(Array)
+ @parser.nameservers.should have(8).items
+ @parser.nameservers[0].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[0].name.should == "asia3.akam.net"
+ @parser.nameservers[1].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[1].name.should == "aus1.akam.net"
+ @parser.nameservers[2].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[2].name.should == "eur1.akam.net"
+ @parser.nameservers[3].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[3].name.should == "eur2.akam.net"
+ @parser.nameservers[4].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[4].name.should == "ns1-105.akam.net"
+ @parser.nameservers[5].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[5].name.should == "ns1-232.akam.net"
+ @parser.nameservers[6].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[6].name.should == "usc2.akam.net"
+ @parser.nameservers[7].should be_a(Whois::Record::Nameserver)
+ @parser.nameservers[7].name.should == "usw6.akam.net"
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.