Sha256: 943efbfdf37429091a62bc419a5b084b7084908717862828e8a9c4b9048da094

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2014 Simone Carletti <weppos@weppos.net>
#++


require 'whois/record/scanners/base'


module Whois
  class Record
    module Scanners

      # Scanner for the Afilias-based records.
      class BaseAfilias < Base

        self.tokenizers += [
            :skip_empty_line,
            :scan_available,
            :scan_reserved,
            :scan_throttled,
            :scan_disclaimer,
            :scan_keyvalue,
        ]


        tokenizer :scan_available do
          if @input.scan(/^NOT FOUND\n/)
            @ast["status:available"] = true
          end
        end

        tokenizer :scan_reserved do
          if settings[:pattern_reserved] && @input.scan(settings[:pattern_reserved])
            @ast["status:reserved"] = true
          end
        end

        # .ORG
        tokenizer :scan_throttled do
          if @input.match?(/^WHOIS LIMIT EXCEEDED/)
            @ast["response:throttled"] = true
            @input.skip(/^.+\n/)
          end
        end

        tokenizer :scan_disclaimer do
          if settings[:pattern_disclaimer]
            if @input.match?(settings[:pattern_disclaimer])
              @ast["field:disclaimer"] = _scan_lines_to_array(/^(.+)\n/).join(" ")
            end
          elsif @input.pos == 0 && @input.match?(/^(.+\n){3,}\n/)
            @ast["field:disclaimer"] = _scan_lines_to_array(/^(.+)\n/).join(" ")
          end
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
whois-3.6.2 lib/whois/record/scanners/base_afilias.rb
whois-3.6.1 lib/whois/record/scanners/base_afilias.rb
whois-3.6.0 lib/whois/record/scanners/base_afilias.rb
whois-3.5.9 lib/whois/record/scanners/base_afilias.rb
whois-3.5.8 lib/whois/record/scanners/base_afilias.rb
whois-3.5.7 lib/whois/record/scanners/base_afilias.rb
whois-3.5.6 lib/whois/record/scanners/base_afilias.rb
whois-3.5.5 lib/whois/record/scanners/base_afilias.rb