Skip to content

Commit

Permalink
Updated GoDaddy parser to the new response (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos authored Aug 3, 2017
1 parent 7619d0c commit 718d7af
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 217 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,3 @@ matrix:
before_install:
- rvm get latest
- gem install bundler

before_script:
- rake spec:generate
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).

#### master

- CHANGED: Updated GoDaddy parser to the new response (GH-60).

- CHANGED: Updated Donuts parser to the new response. It looks like Donuts is now more compliant with base ICANN parser.

- CHANGED: Updated Verisign parser to the new response (GH-57). [Thanks @phcyso]
Expand Down
6 changes: 3 additions & 3 deletions lib/whois/parsers/base_icann_compliant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ class BaseIcannCompliant < Base


property_supported :created_on do
node('Creation Date') do |value|
node("Creation Date") do |value|
parse_time(value)
end
end

property_supported :updated_on do
node('Updated Date') do |value|
node("Updated Date") do |value|
parse_time(value)
end
end

property_supported :expires_on do
node('Registrar Registration Expiration Date') do |value|
node("Registrar Registration Expiration Date") do |value|
parse_time(value)
end
end
Expand Down
78 changes: 4 additions & 74 deletions lib/whois/parsers/whois.godaddy.com.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#++


require_relative 'base'
require_relative 'base_icann_compliant'


module Whois
Expand All @@ -18,9 +18,7 @@ class Parsers
# @see Whois::Parsers::Example
# The Example parser for the list of all available methods.
#
class WhoisGodaddyCom < Base

property_not_supported :status
class WhoisGodaddyCom < BaseIcannCompliant

# The server is contacted only in case of a registered domain.
property_supported :available? do
Expand All @@ -32,77 +30,9 @@ class WhoisGodaddyCom < Base
end


property_supported :created_on do
if content_for_scanner =~ /Creation Date: (.+)\n/
parse_time($1)
end
end

property_supported :updated_on do
if content_for_scanner =~ /Updated* Date: (.+)\n/
parse_time($1)
end
end

property_supported :expires_on do
if content_for_scanner =~ /Expiration Date: (.+)\n/
parse_time($1)
end
end


property_supported :registrar do
Parser::Registrar.new(
name: content_for_scanner[/Registrar: (.+)\n/, 1],
url: content_for_scanner[/Registrar URL: (.+)\n/, 1],
)
end

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

property_supported :admin_contacts do
build_contact('Admin', Parser::Contact::TYPE_ADMINISTRATIVE)
end

property_supported :technical_contacts do
build_contact('Tech', Parser::Contact::TYPE_TECHNICAL)
end

property_supported :nameservers do
content_for_scanner.scan(/Name Server: (.+)\n/).map do |line|
Parser::Nameserver.new(name: line[0].strip)
end
end


private

def build_contact(element, type)
Parser::Contact.new(
type: type,
id: nil,
name: value_for_property(element, 'Name'),
organization: value_for_property(element, 'Organization'),
address: value_for_property(element, 'Street'),
city: value_for_property(element, 'City'),
zip: value_for_property(element, 'Postal Code'),
state: value_for_property(element, 'State/Province'),
country: value_for_property(element, 'Country'),
phone: value_for_property(element, 'Phone'),
fax: value_for_property(element, 'Fax'),
email: value_for_property(element, 'Email')
)
end

def value_for_property(element, property)
matches = content_for_scanner.scan(/#{element} #{property}:\s(.+)\n/)
value = matches.collect(&:first).join(', ')
if value == ""
nil
else
value
node("Update Date") do |value|
parse_time(value)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#domain
%s == "godaddy.com"

#domain_id
%s == "4013247_DOMAIN_COM-VRSN"


#status
%s %ERROR{AttributeNotSupported}
%s == :registered

#available?
%s == false
Expand All @@ -8,80 +15,127 @@
%s == true


#created_on
%s %CLASS{time}
%s %TIME{1999-03-02 05:00:00 UTC}

#updated_on
%s %CLASS{time}
%s %TIME{2013-06-02 12:16:24 UTC}

#expires_on
%s %CLASS{time}
%s %TIME{2021-11-01 11:59:59 UTC}


#registrar
%s %CLASS{registrar}
%s.id == nil
%s.id == "146"
%s.name == "GoDaddy.com, LLC"
%s.organization == nil
%s.organization == "GoDaddy.com, LLC"
%s.url == "http://www.godaddy.com"


#registrant_contacts
%s %CLASS{array}
%s %SIZE{1}
%s[0] %CLASS{contact}
%s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT
%s[0].name == "Go Daddy Go Daddy"
%s[0].organization == "Go Daddy"
%s[0].id == "Not Available From Registry"
%s[0].name == "Domain Administrator"
%s[0].organization == "Go Daddy Operating Company, LLC"
%s[0].address == "14455 N Hayden Rd Suite 219"
%s[0].city == "Scottsdale"
%s[0].zip == "85260"
%s[0].state == "Arizona"
%s[0].country == "United States"
%s[0].phone == nil
%s[0].fax == nil
%s[0].email == nil
%s[0].country == nil
%s[0].country_code == "US"
%s[0].phone == "+1.4805058800"
%s[0].fax == "+1.4805058844"
%s[0].email == "[email protected]"
%s[0].created_on == nil
%s[0].updated_on == nil
%s[0].updated_on == nil

#admin_contacts
%s %CLASS{array}
%s %SIZE{1}
%s[0] %CLASS{contact}
%s[0].type == Whois::Parser::Contact::TYPE_ADMINISTRATIVE
%s[0].name == "Go Daddy Go Daddy"
%s[0].organization == "Go Daddy"
%s[0].id == "Not Available From Registry"
%s[0].name == "Domain Administrator"
%s[0].organization == "Go Daddy Operating Company, LLC"
%s[0].address == "14455 N Hayden Rd Suite 219"
%s[0].city == "Scottsdale"
%s[0].zip == "85260"
%s[0].state == "Arizona"
%s[0].country == "United States"
%s[0].country == nil
%s[0].country_code == "US"
%s[0].phone == "+1.4805058800"
%s[0].fax == "+1.4805058844"
%s[0].email == "[email protected]"
%s[0].email == "[email protected]"
%s[0].created_on == nil
%s[0].updated_on == nil
%s[0].updated_on == nil

#technical_contacts
%s %CLASS{array}
%s %SIZE{1}
%s[0] %CLASS{contact}
%s[0].type == Whois::Parser::Contact::TYPE_TECHNICAL
%s[0].name == "Go Daddy Go Daddy"
%s[0].organization == "Go Daddy"
%s[0].id == "Not Available From Registry"
%s[0].name == "Domain Administrator"
%s[0].organization == "Go Daddy Operating Company, LLC"
%s[0].address == "14455 N Hayden Rd Suite 219"
%s[0].city == "Scottsdale"
%s[0].zip == "85260"
%s[0].state == "Arizona"
%s[0].country == "United States"
%s[0].country == nil
%s[0].country_code == "US"
%s[0].phone == "+1.4805058800"
%s[0].fax == "+1.4805058844"
%s[0].email == "[email protected]"
%s[0].email == "[email protected]"
%s[0].created_on == nil
%s[0].updated_on == nil
%s[0].updated_on == nil


#nameservers
%s %CLASS{array}
%s %SIZE{3}
%s %SIZE{9}
%s[0] %CLASS{nameserver}
%s[0].name == "CNS1.SECURESERVER.NET"
%s[0].name == "cns1.godaddy.com"
%s[0].ipv4 == nil
%s[0].ipv6 == nil
%s[1] %CLASS{nameserver}
%s[1].name == "CNS2.SECURESERVER.NET"
%s[1].name == "cns2.godaddy.com"
%s[1].ipv4 == nil
%s[1].ipv6 == nil
%s[2] %CLASS{nameserver}
%s[2].name == "CNS3.SECURESERVER.NET"
%s[2].name == "cns3.godaddy.com"
%s[2].ipv4 == nil
%s[2].ipv6 == nil
%s[3] %CLASS{nameserver}
%s[3].name == "a11-64.akam.net"
%s[3].ipv4 == nil
%s[3].ipv6 == nil
%s[4] %CLASS{nameserver}
%s[4].name == "a1-245.akam.net"
%s[4].ipv4 == nil
%s[4].ipv6 == nil
%s[5] %CLASS{nameserver}
%s[5].name == "a20-65.akam.net"
%s[5].ipv4 == nil
%s[5].ipv6 == nil
%s[6] %CLASS{nameserver}
%s[6].name == "a6-66.akam.net"
%s[6].ipv4 == nil
%s[6].ipv6 == nil
%s[7] %CLASS{nameserver}
%s[7].name == "a8-67.akam.net"
%s[7].ipv4 == nil
%s[7].ipv6 == nil
%s[8] %CLASS{nameserver}
%s[8].name == "a9-67.akam.net"
%s[8].ipv4 == nil
%s[8].ipv6 == nil
Loading

0 comments on commit 718d7af

Please sign in to comment.