Skip to content
This repository
Browse code

Merge pull request #181 from JustinCampbell/register-enom

Fix whois.register.com parser for enom formats
  • Loading branch information...
commit dcb657f55cbea633c42cda1dccc6847b4f1f80d1 2 parents 4673715 + 829c450
Simone Carletti authored
54 lib/whois/record/parser/whois.register.com.rb
@@ -33,7 +33,7 @@ class WhoisRegisterCom < Base
33 33
34 34
35 35 property_supported :created_on do
36   - if content_for_scanner =~ /Created on\.+: (.+)\n/
  36 + if content_for_scanner =~ /(?:Created on\.+|Creation date): (.+)\n/
37 37 Time.parse($1)
38 38 end
39 39 end
@@ -41,7 +41,7 @@ class WhoisRegisterCom < Base
41 41 property_not_supported :updated_on
42 42
43 43 property_supported :expires_on do
44   - if content_for_scanner =~ /Expires on\.+: (.+)\n/
  44 + if content_for_scanner =~ /(?:Expires on\.+|Expiration date): (.+)\n/
45 45 Time.parse($1)
46 46 end
47 47 end
@@ -56,20 +56,20 @@ class WhoisRegisterCom < Base
56 56 end
57 57
58 58 property_supported :registrant_contacts do
59   - build_contact('Registrant:', Record::Contact::TYPE_REGISTRANT)
  59 + build_contact(/Registrant(?: Contact)?:/, Record::Contact::TYPE_REGISTRANT)
60 60 end
61 61
62 62 property_supported :admin_contacts do
63   - build_contact('Administrative Contact:', Record::Contact::TYPE_ADMIN)
  63 + build_contact(/Administrative Contact:/, Record::Contact::TYPE_ADMIN)
64 64 end
65 65
66 66 property_supported :technical_contacts do
67   - build_contact('Technical Contact:', Record::Contact::TYPE_TECHNICAL)
  67 + build_contact(/Technical\s+Contact:/, Record::Contact::TYPE_TECHNICAL)
68 68 end
69 69
70 70
71 71 property_supported :nameservers do
72   - if content_for_scanner =~ /DNS Servers:\n((.+\n)+)\n/
  72 + if content_for_scanner =~ /(?:DNS|Name) Servers:\n((.+\n)+)\n/
73 73 $1.split("\n").map do |line|
74 74 Record::Nameserver.new(:name => line.strip)
75 75 end
@@ -80,6 +80,14 @@ class WhoisRegisterCom < Base
80 80 private
81 81
82 82 def build_contact(element, type)
  83 + if content_for_scanner.match /DNS Servers/
  84 + build_register_contact(element, type)
  85 + else
  86 + build_enom_contact(element, type)
  87 + end
  88 + end
  89 +
  90 + def build_register_contact(element, type)
83 91 match = content_for_scanner.slice(/#{element}\n((.+\n){7})/, 1)
84 92 return unless match
85 93
@@ -109,6 +117,40 @@ def build_contact(element, type)
109 117 )
110 118 end
111 119
  120 + def build_enom_contact(element, type)
  121 + match = content_for_scanner.slice(/#{element}\n(((\s{3}+.*)\n)+)/, 1)
  122 + return unless match
  123 +
  124 + # 0 AdBrite, Inc.
  125 + # 1 Host Master (hostmaster@adbrite.com)
  126 + # 2 4159750916
  127 + # 3 Fax:
  128 + # 4 731 Market Street, Suite 500
  129 + # 5 San Francisco, CA 94103
  130 + # 6 US
  131 +
  132 + lines = match.split("\n").map(&:lstrip)
  133 + name, email = lines[1].match(/(.*)\((.*)\)/)[1..2].map(&:strip)
  134 + fax_match = lines[3].match(/Fax: (.*)/)
  135 + fax = fax_match[1] if fax_match
  136 + city, state, zip = lines[-2].match(/(.*),(.+?)(\d*)$/)[1..3].map(&:strip)
  137 +
  138 + Record::Contact.new(
  139 + :type => type,
  140 + :id => nil,
  141 + :name => name,
  142 + :organization => lines[0],
  143 + :address => lines[4..-3].join("\n"),
  144 + :city => city,
  145 + :zip => zip,
  146 + :state => state,
  147 + :country_code => lines[-1],
  148 + :phone => lines[2] == "" ? nil : lines[2],
  149 + :fax => fax,
  150 + :email => email == "" ? nil : email
  151 + )
  152 + end
  153 +
112 154 end
113 155
114 156 end
91 spec/fixtures/responses/whois.register.com/status_registered_2.expected
... ... @@ -0,0 +1,91 @@
  1 +#status
  2 + should: %s raise_error(Whois::PropertyNotSupported)
  3 +
  4 +#available?
  5 + should: %s == false
  6 +
  7 +#registered?
  8 + should: %s == true
  9 +
  10 +
  11 +#created_on
  12 + should: %s CLASS(time)
  13 + should: %s == Time.parse("2002-03-14 00:19:48")
  14 +
  15 +#updated_on
  16 + should: %s raise_error(Whois::PropertyNotSupported)
  17 +
  18 +#expires_on
  19 + should: %s CLASS(time)
  20 + should: %s == Time.parse("2013-03-14 00:19:00")
  21 +
  22 +
  23 +#registrar
  24 + should: %s CLASS(registrar)
  25 + should: %s.id == nil
  26 + should: %s.name == "Register.com"
  27 + should: %s.url == "http://www.register.com/"
  28 +
  29 +
  30 +#registrant_contacts
  31 + should: %s CLASS(array)
  32 + should: %s SIZE(1)
  33 + should: %s[0] CLASS(contact)
  34 + should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
  35 + should: %s[0].name == "Josh Cramer"
  36 + should: %s[0].organization == "Cramer Development"
  37 + should: %s[0].address == "226 S. Clinton Street"
  38 + should: %s[0].city == "Iowa City"
  39 + should: %s[0].zip == "52240"
  40 + should: %s[0].state == "IA"
  41 + should: %s[0].country_code == "US"
  42 + should: %s[0].phone == nil
  43 + should: %s[0].fax == nil
  44 + should: %s[0].email == nil
  45 +
  46 +#admin_contacts
  47 + should: %s CLASS(array)
  48 + should: %s SIZE(1)
  49 + should: %s[0] CLASS(contact)
  50 + should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
  51 + should: %s[0].name == "Host Master"
  52 + should: %s[0].organization == "Cramer Development Incorporated"
  53 + should: %s[0].address == "226 S Clinton St"
  54 + should: %s[0].city == "Iowa City"
  55 + should: %s[0].zip == "52245"
  56 + should: %s[0].state == "IA"
  57 + should: %s[0].country_code == "US"
  58 + should: %s[0].phone == "+1.5152920050"
  59 + should: %s[0].fax == nil
  60 + should: %s[0].email == "domains@cramerdev.com"
  61 +
  62 +#technical_contacts
  63 + should: %s CLASS(array)
  64 + should: %s SIZE(1)
  65 + should: %s[0] CLASS(contact)
  66 + should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
  67 + should: %s[0].name == "Host Master"
  68 + should: %s[0].organization == "Cramer Development Incorporated"
  69 + should: %s[0].address == "226 S Clinton St"
  70 + should: %s[0].city == "Iowa City"
  71 + should: %s[0].zip == "52245"
  72 + should: %s[0].state == "IA"
  73 + should: %s[0].country_code == "US"
  74 + should: %s[0].phone == "+1.5152920050"
  75 + should: %s[0].fax == nil
  76 + should: %s[0].email == "domains@cramerdev.com"
  77 +
  78 +
  79 +#nameservers
  80 + should: %s CLASS(array)
  81 + should: %s SIZE(5)
  82 + should: %s[0] CLASS(nameserver)
  83 + should: %s[0].name == "dns01.gpn.register.com"
  84 + should: %s[1] CLASS(nameserver)
  85 + should: %s[1].name == "dns02.gpn.register.com"
  86 + should: %s[2] CLASS(nameserver)
  87 + should: %s[2].name == "dns03.gpn.register.com"
  88 + should: %s[3] CLASS(nameserver)
  89 + should: %s[3].name == "dns04.gpn.register.com"
  90 + should: %s[4] CLASS(nameserver)
  91 + should: %s[4].name == "dns05.gpn.register.com"
91 spec/fixtures/responses/whois.register.com/status_registered_2.txt
... ... @@ -0,0 +1,91 @@
  1 +
  2 +The data in Register.com's WHOIS database is provided to you by
  3 +Register.com for information purposes only, that is, to assist you in
  4 +obtaining information about or related to a domain name registration
  5 +record. Register.com makes this information available "as is," and
  6 +does not guarantee its accuracy. By submitting a WHOIS query, you
  7 +agree that you will use this data only for lawful purposes and that,
  8 +under no circumstances will you use this data to: (1) allow, enable,
  9 +or otherwise support the transmission of mass unsolicited, commercial
  10 +advertising or solicitations via direct mail, electronic mail, or by
  11 +telephone; or (2) enable high volume, automated, electronic processes
  12 +that apply to Register.com (or its systems). The compilation,
  13 +repackaging, dissemination or other use of this data is expressly
  14 +prohibited without the prior written consent of Register.com.
  15 +Register.com reserves the right to modify these terms at any time.
  16 +By submitting this query, you agree to abide by these terms.
  17 +
  18 +
  19 +=-=-=-=
  20 +
  21 +
  22 +Domain name: cramerdev.com
  23 + Is the domain you want taken? Make an offer: http://www.afternic.com/rcom.php?ref_id=2987&name=cramerdev.com
  24 +
  25 +Registrant Contact:
  26 + Cramer Development
  27 + Josh Cramer ()
  28 +
  29 + Fax:
  30 + 226 S. Clinton Street
  31 + Iowa City, IA 52240
  32 + US
  33 +
  34 +Administrative Contact:
  35 + Cramer Development Incorporated
  36 + Host Master (domains@cramerdev.com)
  37 + +1.5152920050
  38 + Fax:
  39 + 226 S Clinton St
  40 + Iowa City, IA 52245
  41 + US
  42 +
  43 +Technical Contact:
  44 + Cramer Development Incorporated
  45 + Host Master (domains@cramerdev.com)
  46 + +1.5152920050
  47 + Fax:
  48 + 226 S Clinton St
  49 + Iowa City, IA 52245
  50 + US
  51 +
  52 +Status: Locked
  53 +
  54 +Name Servers:
  55 + dns01.gpn.register.com
  56 + dns02.gpn.register.com
  57 + dns03.gpn.register.com
  58 + dns04.gpn.register.com
  59 + dns05.gpn.register.com
  60 +
  61 +Creation date: 14 Mar 2002 00:19:48
  62 +Expiration date: 14 Mar 2013 00:19:00
  63 +
  64 +
  65 +
  66 +
  67 +=-=-=-=
  68 +The data in this whois database is provided to you for information
  69 +purposes only, that is, to assist you in obtaining information about or
  70 +related to a domain name registration record. We make this information
  71 +available "as is," and do not guarantee its accuracy. By submitting a
  72 +whois query, you agree that you will use this data only for lawful
  73 +purposes and that, under no circumstances will you use this data to: (1)
  74 +enable high volume, automated, electronic processes that stress or load
  75 +this whois database system providing you this information; or (2) allow,
  76 +enable, or otherwise support the transmission of mass unsolicited,
  77 +commercial advertising or solicitations via direct mail, electronic
  78 +mail, or by telephone. The compilation, repackaging, dissemination or
  79 +other use of this data is expressly prohibited without prior written
  80 +consent from us.
  81 +
  82 +We reserve the right to modify these terms at any time. By submitting
  83 +this query, you agree to abide by these terms.
  84 +Version 6.3 4/3/2002
  85 +
  86 +
  87 +Visit AboutUs.org for more information about cramerdev.com
  88 +
  89 +<A HREF="http://www.aboutus.org/cramerdev.com">AboutUs: cramerdev.com</A>
  90 +
  91 +Register your domain name at http://www.register.com
134 spec/whois/record/parser/responses/whois.register.com/status_registered_2_spec.rb
... ... @@ -0,0 +1,134 @@
  1 +# encoding: utf-8
  2 +
  3 +# This file is autogenerated. Do not edit it manually.
  4 +# If you want change the content of this file, edit
  5 +#
  6 +# /spec/fixtures/responses/whois.register.com/status_registered_2.expected
  7 +#
  8 +# and regenerate the tests with the following rake task
  9 +#
  10 +# $ rake spec:generate
  11 +#
  12 +
  13 +require 'spec_helper'
  14 +require 'whois/record/parser/whois.register.com.rb'
  15 +
  16 +describe Whois::Record::Parser::WhoisRegisterCom, "status_registered_2.expected" do
  17 +
  18 + before(:each) do
  19 + file = fixture("responses", "whois.register.com/status_registered_2.txt")
  20 + part = Whois::Record::Part.new(:body => File.read(file))
  21 + @parser = klass.new(part)
  22 + end
  23 +
  24 + describe "#status" do
  25 + it do
  26 + lambda { @parser.status }.should raise_error(Whois::PropertyNotSupported)
  27 + end
  28 + end
  29 + describe "#available?" do
  30 + it do
  31 + @parser.available?.should == false
  32 + end
  33 + end
  34 + describe "#registered?" do
  35 + it do
  36 + @parser.registered?.should == true
  37 + end
  38 + end
  39 + describe "#created_on" do
  40 + it do
  41 + @parser.created_on.should be_a(Time)
  42 + @parser.created_on.should == Time.parse("2002-03-14 00:19:48")
  43 + end
  44 + end
  45 + describe "#updated_on" do
  46 + it do
  47 + lambda { @parser.updated_on }.should raise_error(Whois::PropertyNotSupported)
  48 + end
  49 + end
  50 + describe "#expires_on" do
  51 + it do
  52 + @parser.expires_on.should be_a(Time)
  53 + @parser.expires_on.should == Time.parse("2013-03-14 00:19:00")
  54 + end
  55 + end
  56 + describe "#registrar" do
  57 + it do
  58 + @parser.registrar.should be_a(Whois::Record::Registrar)
  59 + @parser.registrar.id.should == nil
  60 + @parser.registrar.name.should == "Register.com"
  61 + @parser.registrar.url.should == "http://www.register.com/"
  62 + end
  63 + end
  64 + describe "#registrant_contacts" do
  65 + it do
  66 + @parser.registrant_contacts.should be_a(Array)
  67 + @parser.registrant_contacts.should have(1).items
  68 + @parser.registrant_contacts[0].should be_a(Whois::Record::Contact)
  69 + @parser.registrant_contacts[0].type.should == Whois::Record::Contact::TYPE_REGISTRANT
  70 + @parser.registrant_contacts[0].name.should == "Josh Cramer"
  71 + @parser.registrant_contacts[0].organization.should == "Cramer Development"
  72 + @parser.registrant_contacts[0].address.should == "226 S. Clinton Street"
  73 + @parser.registrant_contacts[0].city.should == "Iowa City"
  74 + @parser.registrant_contacts[0].zip.should == "52240"
  75 + @parser.registrant_contacts[0].state.should == "IA"
  76 + @parser.registrant_contacts[0].country_code.should == "US"
  77 + @parser.registrant_contacts[0].phone.should == nil
  78 + @parser.registrant_contacts[0].fax.should == nil
  79 + @parser.registrant_contacts[0].email.should == nil
  80 + end
  81 + end
  82 + describe "#admin_contacts" do
  83 + it do
  84 + @parser.admin_contacts.should be_a(Array)
  85 + @parser.admin_contacts.should have(1).items
  86 + @parser.admin_contacts[0].should be_a(Whois::Record::Contact)
  87 + @parser.admin_contacts[0].type.should == Whois::Record::Contact::TYPE_ADMIN
  88 + @parser.admin_contacts[0].name.should == "Host Master"
  89 + @parser.admin_contacts[0].organization.should == "Cramer Development Incorporated"
  90 + @parser.admin_contacts[0].address.should == "226 S Clinton St"
  91 + @parser.admin_contacts[0].city.should == "Iowa City"
  92 + @parser.admin_contacts[0].zip.should == "52245"
  93 + @parser.admin_contacts[0].state.should == "IA"
  94 + @parser.admin_contacts[0].country_code.should == "US"
  95 + @parser.admin_contacts[0].phone.should == "+1.5152920050"
  96 + @parser.admin_contacts[0].fax.should == nil
  97 + @parser.admin_contacts[0].email.should == "domains@cramerdev.com"
  98 + end
  99 + end
  100 + describe "#technical_contacts" do
  101 + it do
  102 + @parser.technical_contacts.should be_a(Array)
  103 + @parser.technical_contacts.should have(1).items
  104 + @parser.technical_contacts[0].should be_a(Whois::Record::Contact)
  105 + @parser.technical_contacts[0].type.should == Whois::Record::Contact::TYPE_TECHNICAL
  106 + @parser.technical_contacts[0].name.should == "Host Master"
  107 + @parser.technical_contacts[0].organization.should == "Cramer Development Incorporated"
  108 + @parser.technical_contacts[0].address.should == "226 S Clinton St"
  109 + @parser.technical_contacts[0].city.should == "Iowa City"
  110 + @parser.technical_contacts[0].zip.should == "52245"
  111 + @parser.technical_contacts[0].state.should == "IA"
  112 + @parser.technical_contacts[0].country_code.should == "US"
  113 + @parser.technical_contacts[0].phone.should == "+1.5152920050"
  114 + @parser.technical_contacts[0].fax.should == nil
  115 + @parser.technical_contacts[0].email.should == "domains@cramerdev.com"
  116 + end
  117 + end
  118 + describe "#nameservers" do
  119 + it do
  120 + @parser.nameservers.should be_a(Array)
  121 + @parser.nameservers.should have(5).items
  122 + @parser.nameservers[0].should be_a(Whois::Record::Nameserver)
  123 + @parser.nameservers[0].name.should == "dns01.gpn.register.com"
  124 + @parser.nameservers[1].should be_a(Whois::Record::Nameserver)
  125 + @parser.nameservers[1].name.should == "dns02.gpn.register.com"
  126 + @parser.nameservers[2].should be_a(Whois::Record::Nameserver)
  127 + @parser.nameservers[2].name.should == "dns03.gpn.register.com"
  128 + @parser.nameservers[3].should be_a(Whois::Record::Nameserver)
  129 + @parser.nameservers[3].name.should == "dns04.gpn.register.com"
  130 + @parser.nameservers[4].should be_a(Whois::Record::Nameserver)
  131 + @parser.nameservers[4].name.should == "dns05.gpn.register.com"
  132 + end
  133 + end
  134 +end

0 comments on commit dcb657f

Please sign in to comment.
Something went wrong with that request. Please try again.