Skip to content

Commit

Permalink
Implement new methods for the parser whois.domain.kg.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsec888 committed Feb 5, 2013
1 parent 890cd45 commit 294cc85
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions lib/whois/record/parser/whois.domain.kg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class WhoisDomainKg < Base
end
end


property_supported :nameservers do
if content_for_scanner =~ /Name servers in the listed order:\n\n((.+\n)+)\n/
$1.split("\n").map do |name|
Expand All @@ -71,8 +70,65 @@ class WhoisDomainKg < Base
end
end

end
# The following methods are implemented by Yang Li on 01/24/2013
# ----------------------------------------------------------------------------
property_supported :domain do
return $1 if content_for_scanner =~ /^Domain\s+(.*)\n/i
end

property_not_supported :domain_id

property_supported :registrar do
reg=Record::Registrar.new
content_for_scanner.scan(/^(.+):\s+(.+)\n/).map do |entry|
reg["name"] = entry[1].strip if entry[0] =~ /Registrar/i
reg["organization"] = entry[1].strip if entry[0] =~ /Registrar/i
reg["url"] = entry[1].strip if entry[0] =~ /Referral URL/i
end
return reg
end

property_supported :admin_contacts do
build_contact("Administrative Contact", Whois::Record::Contact::TYPE_ADMIN)
end

property_supported :registrant_contacts do
build_contact("Administrative Contact", Whois::Record::Contact::TYPE_REGISTRANT)
end

property_supported :technical_contacts do
build_contact("Technical Contact", Whois::Record::Contact::TYPE_TECHNICAL)
end

property_supported :billing_contacts do
build_contact("Billing Contact", Whois::Record::Contact::TYPE_BILLING)
end

private

def build_contact(element, type)
reg=Record::Contact.new(:type => type)
if content_for_scanner =~ /#{element}:\n((.+\n)+)\n/i
line_num=1
$1.split(%r{\n}).each do |line|
reg["name"]=line.strip.split(',')[0].split('(')[0] if line_num==1
reg["id"]=line.strip.split(',')[0].split('(')[1].gsub(/\)/,'') if line_num==1
reg["organization"]=line.strip.split(',')[0] if line_num==1
reg["email"]=line.strip.split(',')[1].strip if line_num==1
reg["address"]=line.strip.split(',')[0] if line_num==2
reg["city"]=line.strip.split(',')[1] if line_num==2
reg["zip"]=line.strip.split(',')[2] if line_num==2
reg["country"]=line.strip.split(',')[3] if line_num==2
reg["phone"]=line.strip.split(':')[1] if line =~ /phone/i
reg["fax"]=line.strip.split(':')[1] if line =~ /fax/i
line_num=line_num+1
end
end
return reg
end
# ----------------------------------------------------------------------------

end
end
end
end

0 comments on commit 294cc85

Please sign in to comment.