forked from weppos/whois
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request weppos#490 from tanelj/489_tld_ee_new_format
Updated Estonian whois.tld.ee to the new response format
- Loading branch information
Showing
20 changed files
with
883 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,8 @@ | |
# Copyright (c) 2009-2015 Simone Carletti <[email protected]> | ||
#++ | ||
|
||
|
||
require 'whois/record/parser/base_whoisd' | ||
require 'whois/record/scanners/base_whoisd' | ||
|
||
require 'whois/record/parser/base' | ||
require 'whois/record/scanners/whois.tld.ee' | ||
|
||
module Whois | ||
class Record | ||
|
@@ -20,9 +18,113 @@ class Parser | |
# @see Whois::Record::Parser::Example | ||
# The Example parser for the list of all available methods. | ||
# | ||
class WhoisTldEe < BaseWhoisd | ||
end | ||
class WhoisTldEe < Base | ||
include Scanners::Scannable | ||
|
||
self.scanner = Scanners::WhoisTldEe | ||
|
||
|
||
property_supported :disclaimer do | ||
node('field:disclaimer').to_s.strip | ||
end | ||
|
||
property_supported :domain do | ||
if (content_for_scanner =~ /^Domain:\nname:\s+(.+)\n/) | ||
$1.to_s.strip.downcase | ||
end | ||
end | ||
|
||
property_not_supported :domain_id | ||
|
||
property_supported :status do | ||
if content_for_scanner =~ /status:\s+(.+?)\n/ | ||
case $1 | ||
when 'ok (paid and in zone)' | ||
:registered | ||
when 'expired' | ||
:expired | ||
else | ||
$1 | ||
end | ||
else | ||
:available | ||
end | ||
end | ||
|
||
property_supported :available? do | ||
!!node('status:available') | ||
end | ||
|
||
property_supported :registered? do | ||
!available? | ||
end | ||
|
||
property_supported :created_on do | ||
if content_for_scanner =~ /registered:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_supported :updated_on do | ||
if content_for_scanner =~ /changed:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_supported :expires_on do | ||
if content_for_scanner =~ /expire:\s+(.+?)\n/ | ||
Time.parse($1) | ||
end | ||
end | ||
|
||
property_supported :registrar do | ||
node('Registrar') do |hash| | ||
Record::Registrar.new( | ||
name: hash['name'], | ||
organization: hash['name'], | ||
url: hash['url'] | ||
) | ||
end | ||
end | ||
|
||
property_supported :registrant_contacts do | ||
build_contact('Registrant', Whois::Record::Contact::TYPE_REGISTRANT) | ||
end | ||
|
||
property_supported :admin_contacts do | ||
build_contact('Administrative contact', Whois::Record::Contact::TYPE_ADMINISTRATIVE) | ||
end | ||
|
||
property_supported :technical_contacts do | ||
build_contact('Technical contact', Whois::Record::Contact::TYPE_TECHNICAL) | ||
end | ||
|
||
property_supported :nameservers do | ||
node('Name servers') do |hash| | ||
Array.wrap(hash['nserver']).map do |name| | ||
Nameserver.new(name: name.downcase) | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def build_contact(element, type) | ||
node(element) do |hash| | ||
el_size = Array.wrap(hash['name']).size | ||
|
||
(0...el_size).map do |i| | ||
Record::Contact.new( | ||
type: type, | ||
name: Array.wrap(hash['name'])[i], | ||
email: Array.wrap(hash['email'])[i], | ||
updated_on: Time.parse(Array.wrap(hash['changed'])[i]) | ||
) | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#-- | ||
# Ruby Whois | ||
# | ||
# An intelligent pure Ruby WHOIS client and parser. | ||
# | ||
# Copyright (c) 2009-2015 Simone Carletti <[email protected]> | ||
#++ | ||
|
||
require 'whois/record/scanners/base' | ||
|
||
module Whois | ||
class Record | ||
module Scanners | ||
|
||
# Scanner for WhoisTldEe-based records. | ||
class WhoisTldEe < Base | ||
|
||
self.tokenizers += [ | ||
:scan_available, | ||
:skip_head, | ||
:scan_section, | ||
:skip_empty_line, | ||
:scan_disclaimer | ||
] | ||
|
||
|
||
tokenizer :scan_available do | ||
if @input.skip(/^Domain not found/) | ||
@ast['status:available'] = true | ||
end | ||
end | ||
|
||
tokenizer :scan_section do | ||
if @input.scan(/^(Domain|Registrant|Administrative contact|Technical contact|Registrar|Name servers|DNSSEC):?\n/) | ||
@tmp['_section'] = @input[1] | ||
while scan_keyvalue | ||
end | ||
@tmp.delete('_section') | ||
end | ||
end | ||
|
||
tokenizer :skip_head do | ||
@input.skip(/^Estonia .ee Top Level Domain WHOIS server\n\n/) | ||
end | ||
|
||
tokenizer :skip_end do | ||
@input.skip(/^More information at http:\/\/internet.ee\n?/) | ||
end | ||
|
||
tokenizer :scan_disclaimer do | ||
@input.skip_until(/^(Estonia .ee Top Level Domain WHOIS server)/m) | ||
@ast['field:disclaimer'] = @input[1] << @input.scan_until(/.*$/m) | ||
end | ||
end | ||
end | ||
end | ||
end |
33 changes: 0 additions & 33 deletions
33
spec/fixtures/responses/whois.tld.ee/ee/property_contact_admin.txt
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
spec/fixtures/responses/whois.tld.ee/ee/property_contact_registrant.txt
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
spec/fixtures/responses/whois.tld.ee/ee/property_status_expired.txt
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
spec/fixtures/responses/whois.tld.ee/ee/property_status_missing.txt
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
spec/fixtures/responses/whois.tld.ee/ee/property_status_paid.txt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.