Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
whois.coza.net.za became whois.registry.net.za (closes GH-191). [Thanks
- Loading branch information
Showing
17 changed files
with
614 additions
and
356 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
This file was deleted.
Oops, something went wrong.
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,121 @@ | ||
require 'whois/record/parser/base' | ||
require 'whois/record/scanners/whois.registry.net.za' | ||
|
||
|
||
module Whois | ||
class Record | ||
class Parser | ||
# Parser for the whois.registry.za.net server. | ||
# | ||
# @note This parser is just a stub and provides only a few basic methods | ||
# to check for domain availability and get domain status. | ||
# Please consider to contribute implementing missing methods. | ||
# | ||
# @see Whois::Record::Parser::Example | ||
# The Example parser for the list of all available methods. | ||
# | ||
class WhoisRegistryNetZa < Base | ||
include Scanners::Nodable | ||
|
||
property_supported :disclaimer do | ||
node("field:disclaimer") | ||
end | ||
|
||
property_supported :domain do | ||
node("field:domain_name") | ||
end | ||
|
||
property_not_supported :domain_id | ||
|
||
property_not_supported :referral_whois | ||
|
||
property_not_supported :referral_url | ||
|
||
property_supported :status do | ||
node("field:status") | ||
end | ||
|
||
property_supported :available? do | ||
node("status:available") ? true : false | ||
end | ||
|
||
property_supported :registered? do | ||
!available? | ||
end | ||
|
||
property_supported :created_on do | ||
node("field:dates") do | ||
node("field:dates") =~ /Registration Date:\s*(\d{4}-\d{2}-\d{2})/ | ||
parse_date($1) | ||
end | ||
end | ||
|
||
property_not_supported :updated_on | ||
|
||
property_supported :expires_on do | ||
node("field:dates") do | ||
node("field:dates") =~ /Renewal Date:\s*(\d{4}-\d{2}-\d{2})/ | ||
parse_date($1) | ||
end | ||
end | ||
|
||
property_supported :registrar do | ||
node("field:registrar") do | ||
node("field:registrar") =~ /(.+) \[ ID = (.+) \]/ | ||
Whois::Record::Registrar.new(:name => $1.strip, :id => $2.strip) | ||
end | ||
end | ||
|
||
# The response for this property gets wrapped in an array by Whois::Record::Parser::Base#handle_property | ||
property_supported :registrant_contacts do | ||
node("field:registrant_details") do | ||
build_registrant_contacts | ||
end | ||
end | ||
|
||
property_not_supported :admin_contacts | ||
|
||
property_not_supported :technical_contacts | ||
|
||
property_supported :nameservers do | ||
node("field:nameservers") do | ||
nameservers = node("field:nameservers").gsub(/\n\s+/, ",").split(",") | ||
Array.wrap(nameservers).map do |nameserver| | ||
Record::Nameserver.new(:name => nameserver) | ||
end | ||
end | ||
end | ||
|
||
def parse | ||
Scanners::WhoisRegistryNetZa.new(content_for_scanner).parse | ||
end | ||
|
||
private | ||
|
||
def build_registrant_contacts | ||
Whois::Record::Contact.new( | ||
{:type => Whois::Record::Contact::TYPE_REGISTRANT}.merge(registrant_details).merge(registrant_address_details) | ||
) | ||
end | ||
|
||
def registrant_details | ||
registrant_lines = node("field:registrant_details").split("\n") | ||
details = { :name => registrant_lines.shift } | ||
[:email, :phone, :fax].each do |contact_method| | ||
details[contact_method] = registrant_lines.shift.split(":").last.strip | ||
end | ||
details | ||
end | ||
|
||
def registrant_address_details | ||
{ :address => node("field:registrant_address").gsub(/\n\s+/, " ") } | ||
end | ||
|
||
def parse_date(date_string) | ||
Time.parse(date_string) if date_string | ||
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,101 @@ | ||
#-- | ||
# Ruby Whois | ||
# | ||
# An intelligent pure Ruby WHOIS client and parser. | ||
# | ||
# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net> | ||
#++ | ||
|
||
require 'whois/record/scanners/base' | ||
|
||
module Whois | ||
class Record | ||
module Scanners | ||
|
||
class WhoisRegistryNetZa < Base | ||
self.tokenizers += [ | ||
:get_availability, | ||
:get_domain_name, | ||
:get_registrant_details, | ||
:get_registrant_address, | ||
:get_registrar_details, | ||
:get_dates, | ||
:get_status, | ||
:get_pending_timer_events, | ||
:get_nameservers, | ||
:get_disclaimer | ||
] | ||
|
||
tokenizer :get_availability do | ||
if @input.scan_until(/^Available\n$/m) | ||
@ast["status:available"] = true | ||
end | ||
end | ||
|
||
tokenizer :get_domain_name do | ||
if find_heading("Domain Name") | ||
@ast["field:domain_name"] = content_in_category | ||
end | ||
end | ||
|
||
tokenizer :get_registrant_details do | ||
if find_heading("Registrant") | ||
@ast["field:registrant_details"] = content_in_category | ||
end | ||
end | ||
|
||
tokenizer :get_registrant_address do | ||
if find_heading("Registrant's Address") | ||
@ast["field:registrant_address"] = content_in_category | ||
end | ||
end | ||
|
||
tokenizer :get_registrar_details do | ||
if find_heading("Registrar") | ||
@ast["field:registrar"] = content_in_category | ||
end | ||
end | ||
|
||
tokenizer :get_dates do | ||
if find_heading("Relevant Dates") | ||
@ast["field:dates"] = content_in_category | ||
end | ||
end | ||
|
||
tokenizer :get_status do | ||
if find_heading("Domain Status") | ||
statuses = content_in_category | ||
@ast["field:status"] = statuses.split(", ") | ||
end | ||
end | ||
|
||
tokenizer :get_pending_timer_events do | ||
if find_heading("Pending Timer Events") | ||
@ast["field:pending_timer_events"] = content_in_category | ||
end | ||
end | ||
|
||
tokenizer :get_nameservers do | ||
if find_heading("Name Servers") | ||
@ast["field:nameservers"] = content_in_category | ||
end | ||
end | ||
|
||
tokenizer :get_disclaimer do | ||
@input.skip_until(/\n--\n/m) | ||
@ast["field:disclaimer"] = @input.scan_until(/.*$/m) | ||
end | ||
|
||
private | ||
|
||
def content_in_category | ||
@input.scan_until(/(?=\n [A-Z])/).strip | ||
end | ||
|
||
def find_heading(heading_name) | ||
@input.skip_until(/ #{heading_name}:\n/) | ||
end | ||
end | ||
end | ||
end | ||
end |
46 changes: 0 additions & 46 deletions
46
spec/fixtures/responses/whois.coza.net.za/status_available.expected
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.