lib/whois/record/parser/whois.nic.tr.rb in whois-3.2.0 vs lib/whois/record/parser/whois.nic.tr.rb in whois-3.2.1

- old
+ new

@@ -12,23 +12,25 @@ module Whois class Record class Parser - # - # = whois.nic.tr parser - # # Parser for the whois.nic.tr 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 WhoisNicIt parser for an explanation of all available methods - # and examples. + # @see Whois::Record::Parser::Example + # The Example parser for the list of all available methods. # class WhoisNicTr < Base + property_not_supported :disclaimer + + + property_not_supported :domain + + property_not_supported :domain_id + + property_supported :status do if available? :available else :registered @@ -59,16 +61,81 @@ Time.utc(time.year, time.month, time.day) end end + property_not_supported :registrar + + + property_supported :registrant_contacts do + textblock = content_for_scanner.slice(/^\*\* Registrant:\n((?:\s+.+\n)+)/, 1) + return unless textblock + + lines = textblock.lines.map(&:strip) + + name = lines[0] + address = lines[1..2].delete_if(&:blank?).join("\n") + city, country = if (lines[3] == "Out of Turkey,") + [nil, lines[4]] + else + [lines[3].chomp(","), lines[4]] + end + + Record::Contact.new( + type: Record::Contact::TYPE_REGISTRANT, + name: name, + address: address, + city: city, + country: country, + email: lines[5], + phone: lines[6], + fax: lines[7] + ) + 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 if content_for_scanner =~ /Domain Servers:\n((.+\n)+)\n/ $1.split("\n").map do |line| name, ipv4 = line.split(/\s+/) Record::Nameserver.new(:name => name, :ipv4 => ipv4) end end + end + + private + + def build_contact(element, type) + textblock = content_for_scanner.slice(/^\*\* #{element}:\n((?:.+\n)+)\n/, 1) + return unless textblock + + lines = [] + textblock.lines.each do |line| + if line =~ /^\s+.+/ + lines.last.last << "\n" << line.strip + else + lines << line.match(/([^\t]+)\t+:\s+(.+)/).to_a[1..2] + end + end + lines = Hash[lines] + + Record::Contact.new( + type: type, + id: lines["NIC Handle"], + name: lines["Person"], + organization: lines["Organization Name"], + address: lines["Address"], + phone: lines["Phone"], + fax: lines["Fax"] + ) end end end