Skip to content

Commit

Permalink
Merge pull request weppos#490 from tanelj/489_tld_ee_new_format
Browse files Browse the repository at this point in the history
Updated Estonian whois.tld.ee to the new response format
  • Loading branch information
weppos committed Dec 9, 2015
2 parents da5b47a + d33d01d commit eaedef8
Show file tree
Hide file tree
Showing 20 changed files with 883 additions and 279 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

- CHANGED: whois.aero now recognizes reserved domains (GH-464, GH-418). [Thanks @linrock]

- CHANGED: Update whois.tld.ee to the new response format (GH-489).


#### Release 3.6.3

Expand Down
114 changes: 108 additions & 6 deletions lib/whois/record/parser/whois.tld.ee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
57 changes: 57 additions & 0 deletions lib/whois/record/scanners/whois.tld.ee.rb
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 spec/fixtures/responses/whois.tld.ee/ee/property_contact_admin.txt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions spec/fixtures/responses/whois.tld.ee/ee/property_status_paid.txt

This file was deleted.

Loading

0 comments on commit eaedef8

Please sign in to comment.