Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 102 lines (80 sloc) 2.734 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2011 Simone Carletti <weppos@weppos.net>
#++


require 'whois/record/parser/base'


module Whois
  class Record
    class Parser

      # Parser for the whois.tcinet.ru 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.
      #
      # @since 2.1.0
      class WhoisTcinetRu < Base

        property_supported :status do
          if content_for_scanner =~ /state:\s+(.+?)\n/
            $1.split(",").map(&:strip)
          else
            []
          end
        end

        property_supported :available? do
          !!(content_for_scanner =~ /No entries found/)
        end

        property_supported :registered? do
          !available?
        end


        property_supported :created_on do
          if content_for_scanner =~ /created:\s+(.*)\n/
            Time.parse($1)
          end
        end

        property_not_supported :updated_on

        property_supported :expires_on do
          if content_for_scanner =~ /paid-till:\s+(.*)\n/
            Time.parse($1)
          end
        end


        property_supported :registrar do
          if content_for_scanner =~ /registrar:\s+(.*)\n/
            Record::Registrar.new(:id => $1)
          end
        end


        property_supported :admin_contacts do
          content_for_scanner.scan(/e-mail:\s+(.+)\n/).flatten.map do |email|
            Record::Contact.new(
              :type => Record::Contact::TYPE_ADMIN,
              :name => content_for_scanner[/person:\s+(.+)\n/, 1],
              :organization => content_for_scanner[/org:\s+(.+)\n/, 1],
              :phone => content_for_scanner[/phone:\s+(.+)\n/, 1],
              :fax => content_for_scanner[/fax-no:\s+(.+)\n/, 1],
              :email => email
            )
          end
        end

        property_not_supported :registrant_contacts

        property_not_supported :technical_contacts


        # Nameservers are listed in the following formats:
        #
        # nserver: ns.masterhost.ru.
        # nserver: ns.masterhost.ru. 217.16.20.30
        #
        property_supported :nameservers do
          content_for_scanner.scan(/nserver:\s+(.+)\n/).flatten.map do |line|
            name, ipv4 = line.split(/\s+/)
            Record::Nameserver.new(name.chomp("."), ipv4)
          end
        end

      end

    end
  end
end
Something went wrong with that request. Please try again.