Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplify scanner

  • Loading branch information...
commit a03472dcb7da0bd48681554ca2e768b9607389d0 1 parent 4ceac05
@rorymckinley authored
View
36 lib/whois/record/parser/whois.registry.net.za.rb
@@ -44,24 +44,31 @@ class WhoisRegistryNetZa < Base
end
property_supported :created_on do
- parse_date(node("field:registration_date"))
+ 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
- parse_date(node("field:renewal_date"))
+ 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_id") do
- Whois::Record::Registrar.new(:name => node("field:registrar_name"), :id => node("field:registrar_id"))
+ 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_name") do
+ node("field:registrant_details") do
build_registrant_contacts
end
end
@@ -71,8 +78,11 @@ class WhoisRegistryNetZa < Base
property_not_supported :technical_contacts
property_supported :nameservers do
- Array.wrap(node("field:nameservers")).map do |nameserver|
- Record::Nameserver.new(:name => nameserver)
+ 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
@@ -89,14 +99,16 @@ def build_registrant_contacts
end
def registrant_details
- {
- :name => node("field:registrant_name"), :email => node("field:registrant_email"),
- :phone => node("field:registrant_telephone"), :fax => node("field:registrant_fax")
- }
+ 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") }
+ { :address => node("field:registrant_address").gsub(/\n\s+/, " ") }
end
def parse_date(date_string)
View
18 lib/whois/record/scanners/whois.registry.net.za.rb
@@ -40,33 +40,25 @@ class WhoisRegistryNetZa < Base
tokenizer :get_registrant_details do
if find_heading("Registrant")
- registrant_lines = content_in_category.split("\n")
- @ast["field:registrant_name"] = registrant_lines.shift
- ["registrant_email", "registrant_telephone", "registrant_fax"].each do |contact_method|
- @ast["field:#{contact_method}"] = registrant_lines.shift.split(":").last.strip
- end
+ @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.gsub(/\n\s+/, " ")
+ @ast["field:registrant_address"] = content_in_category
end
end
tokenizer :get_registrar_details do
if find_heading("Registrar")
- content_in_category =~ /(.+) \[ ID = (.+) \]/
- @ast["field:registrar_name"] = $1.strip
- @ast["field:registrar_id"] = $2.strip
+ @ast["field:registrar"] = content_in_category
end
end
tokenizer :get_dates do
if find_heading("Relevant Dates")
- dates = content_in_category.split("\n")
- @ast["field:registration_date"] = dates.shift.split(":").last.strip
- @ast["field:renewal_date"] = dates.shift.split(":").last.strip
+ @ast["field:dates"] = content_in_category
end
end
@@ -85,7 +77,7 @@ class WhoisRegistryNetZa < Base
tokenizer :get_nameservers do
if find_heading("Name Servers")
- @ast["field:nameservers"] = content_in_category.gsub(/\n\s+/, ",").split(",")
+ @ast["field:nameservers"] = content_in_category
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.