Skip to content

Commit

Permalink
Added full whois.nic.us, whois.nic.travel, and whois.nic.tel parsers.
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Feb 24, 2013
1 parent 784eda9 commit d88c2d7
Show file tree
Hide file tree
Showing 22 changed files with 717 additions and 235 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@


- NEW: whois.eu parser now recognizes throttled responses. - NEW: whois.eu parser now recognizes throttled responses.


- NEW: Added full whois.nic.us parser.

- NEW: Added full whois.nic.travel parser.

- NEW: Added full whois.nic.tel parser.

- CHANGED: Dropped support for Ruby 1.8 - CHANGED: Dropped support for Ruby 1.8


- CHANGED: Renamed Whois::Record::Scanners::Ast to Renamed Whois::Record::Scanners::Nodable - CHANGED: Renamed Whois::Record::Scanners::Ast to Renamed Whois::Record::Scanners::Nodable
Expand Down
57 changes: 4 additions & 53 deletions lib/whois/record/parser/whois.nic.tel.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,68 +7,19 @@
#++ #++




require 'whois/record/parser/base' require 'whois/record/parser/base_shared2'




module Whois module Whois
class Record class Record
class Parser class Parser


#
# = whois.nic.tel parser
#
# Parser for the whois.nic.tel server. # Parser for the whois.nic.tel server.
# #
# NOTE: This parser is just a stub and provides only a few basic methods # @see Whois::Record::Parser::Example
# to check for domain availability and get domain status. # The Example parser for the list of all available methods.
# Please consider to contribute implementing missing methods.
# See WhoisNicIt parser for an explanation of all available methods
# and examples.
# #
class WhoisNicTel < Base class WhoisNicTel < BaseShared2

property_supported :status do
if available?
:available
else
:registered
end
end

property_supported :available? do
!!(content_for_scanner =~ /Not found:/)
end

property_supported :registered? do
!available?
end


property_supported :created_on do
if content_for_scanner =~ /Domain Registration Date:\s+(.*)\n/
Time.parse($1)
end
end

property_supported :updated_on do
if content_for_scanner =~ /Domain Last Updated Date:\s+(.*)\n/
Time.parse($1)
end
end

property_supported :expires_on do
if content_for_scanner =~ /Domain Expiration Date:\s+(.*)\n/
Time.parse($1)
end
end


property_supported :nameservers do
content_for_scanner.scan(/Name Server:\s+(.+)\n/).flatten.map do |name|
Record::Nameserver.new(:name => name.downcase)
end
end

end end


end end
Expand Down
53 changes: 4 additions & 49 deletions lib/whois/record/parser/whois.nic.travel.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,64 +7,19 @@
#++ #++




require 'whois/record/parser/base' require 'whois/record/parser/base_shared2'




module Whois module Whois
class Record class Record
class Parser class Parser


#
# = whois.nic.travel parser
#
# Parser for the whois.nic.travel server. # Parser for the whois.nic.travel server.
# #
# NOTE: This parser is just a stub and provides only a few basic methods # @see Whois::Record::Parser::Example
# to check for domain availability and get domain status. # The Example parser for the list of all available methods.
# Please consider to contribute implementing missing methods.
# See WhoisNicIt parser for an explanation of all available methods
# and examples.
# #
class WhoisNicTravel < Base class WhoisNicTravel < BaseShared2

property_supported :status do
content_for_scanner.scan(/Domain Status:\s+(.+?)\n/).flatten
end

property_supported :available? do
!!(content_for_scanner =~ /Not found:/)
end

property_supported :registered? do
!available?
end


property_supported :created_on do
if content_for_scanner =~ /Domain Registration Date:\s+(.+?)\n/
Time.parse($1)
end
end

property_supported :updated_on do
if content_for_scanner =~ /Domain Last Updated Date:\s+(.+?)\n/
Time.parse($1)
end
end

property_supported :expires_on do
if content_for_scanner =~ /Domain Expiration Date:\s+(.+?)\n/
Time.parse($1)
end
end


property_supported :nameservers do
content_for_scanner.scan(/Name Server:\s+(.+)\n/).flatten.map do |name|
Record::Nameserver.new(:name => name.downcase)
end
end

end end


end end
Expand Down
53 changes: 4 additions & 49 deletions lib/whois/record/parser/whois.nic.us.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,64 +7,19 @@
#++ #++




require 'whois/record/parser/base' require 'whois/record/parser/base_shared2'




module Whois module Whois
class Record class Record
class Parser class Parser


#
# = whois.nic.us parser
#
# Parser for the whois.nic.us server. # Parser for the whois.nic.us server.
# #
# NOTE: This parser is just a stub and provides only a few basic methods # @see Whois::Record::Parser::Example
# to check for domain availability and get domain status. # The Example parser for the list of all available methods.
# Please consider to contribute implementing missing methods.
# See WhoisNicIt parser for an explanation of all available methods
# and examples.
# #
class WhoisNicUs < Base class WhoisNicUs < BaseShared2

property_supported :status do
content_for_scanner.scan(/Domain Status:\s+(.+?)\n/).flatten
end

property_supported :available? do
!!(content_for_scanner =~ /Not found:/)
end

property_supported :registered? do
!available?
end


property_supported :created_on do
if content_for_scanner =~ /Domain Registration Date:\s+(.+?)\n/
Time.parse($1)
end
end

property_supported :updated_on do
if content_for_scanner =~ /Domain Last Updated Date:\s+(.+?)\n/
Time.parse($1)
end
end

property_supported :expires_on do
if content_for_scanner =~ /Domain Expiration Date:\s+(.+?)\n/
Time.parse($1)
end
end


property_supported :nameservers do
content_for_scanner.scan(/Name Server:\s+(.+)\n/).flatten.map do |name|
Record::Nameserver.new(:name => name.downcase)
end
end

end end


end end
Expand Down
25 changes: 24 additions & 1 deletion spec/fixtures/responses/whois.nic.tel/status_available.expected
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,12 @@
#domain
should: %s == "u34jedzcq.tel"

#domain_id
should: %s == nil


#status #status
should: %s == :available should: %s == nil


#available? #available?
should: %s == true should: %s == true
Expand All @@ -18,6 +25,22 @@
should: %s == nil should: %s == nil




#registrar
should: %s == nil

#registrant_contacts
should: %s CLASS(array)
should: %s == []

#admin_contacts
should: %s CLASS(array)
should: %s == []

#technical_contacts
should: %s CLASS(array)
should: %s == []


#nameservers #nameservers
should: %s CLASS(array) should: %s CLASS(array)
should: %s == [] should: %s == []
2 changes: 1 addition & 1 deletion spec/fixtures/responses/whois.nic.tel/status_available.txt
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
Not found: u34jedzcq.tel Not found: u34jedzcq.tel


>>>> Whois database was last updated on: Wed Dec 23 18:30:16 GMT 2009 <<<< >>>> Whois database was last updated on: Sun Feb 24 18:30:38 GMT 2013 <<<<


Telnic, Ltd., the Registry Operator for .TEL, has collected this information Telnic, Ltd., the Registry Operator for .TEL, has collected this information
for the WHOIS database through an ICANN-Accredited Registrar. This information for the WHOIS database through an ICANN-Accredited Registrar. This information
Expand Down
75 changes: 71 additions & 4 deletions spec/fixtures/responses/whois.nic.tel/status_registered.expected
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,12 @@
#domain
should: %s == "google.tel"

#domain_id
should: %s == "D587349-TEL"


#status #status
should: %s == :registered should: %s == ["clientDeleteProhibited", "clientTransferProhibited", "clientUpdateProhibited"]


#available? #available?
should: %s == false should: %s == false
Expand All @@ -10,15 +17,75 @@


#created_on #created_on
should: %s CLASS(time) should: %s CLASS(time)
should: %s == Time.parse("2009-04-19 12:36:25 UTC") should: %s == Time.parse("2009-03-23 23:59:59 GMT")


#updated_on #updated_on
should: %s CLASS(time) should: %s CLASS(time)
should: %s == Time.parse("2009-04-20 12:39:49 UTC") should: %s == Time.parse("2013-02-19 10:23:33 GMT")


#expires_on #expires_on
should: %s CLASS(time) should: %s CLASS(time)
should: %s == Time.parse("2010-04-18 23:59:59 UTC") should: %s == Time.parse("2014-03-22 23:59:59 GMT")


#registrar
should: %s CLASS(registrar)
should: %s.id == "292"
should: %s.name == "MARKMONITOR, INC."

#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 == "MMR-2383"
should: %s[0].name == "DNS Admin"
should: %s[0].organization == "Google Inc."
should: %s[0].address == "1600 Amphitheatre Parkway"
should: %s[0].city == "Mountain View"
should: %s[0].zip == "94043"
should: %s[0].state == "CA"
should: %s[0].country == "United States"
should: %s[0].country_code == "US"
should: %s[0].phone == "+1.6502530000"
should: %s[0].fax == "+1.6506188571"
should: %s[0].email == "dns-admin@google.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 == "MMR-2383"
should: %s[0].name == "DNS Admin"
should: %s[0].organization == "Google Inc."
should: %s[0].address == "1600 Amphitheatre Parkway"
should: %s[0].city == "Mountain View"
should: %s[0].zip == "94043"
should: %s[0].state == "CA"
should: %s[0].country == "United States"
should: %s[0].country_code == "US"
should: %s[0].phone == "+1.6502530000"
should: %s[0].fax == "+1.6506188571"
should: %s[0].email == "dns-admin@google.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 == "MMR-2383"
should: %s[0].name == "DNS Admin"
should: %s[0].organization == "Google Inc."
should: %s[0].address == "1600 Amphitheatre Parkway"
should: %s[0].city == "Mountain View"
should: %s[0].zip == "94043"
should: %s[0].state == "CA"
should: %s[0].country == "United States"
should: %s[0].country_code == "US"
should: %s[0].phone == "+1.6502530000"
should: %s[0].fax == "+1.6506188571"
should: %s[0].email == "dns-admin@google.com"




#nameservers #nameservers
Expand Down
Loading

0 comments on commit d88c2d7

Please sign in to comment.