Sha256: 57a5fb34a16882cd3983a014b199061dd89ae9b62561c7ef0c0574cfc72bd68c

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

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


require 'whois/record/scanners/base'
require 'yaml'

module Whois
  class Record
    module Scanners

      # Scanner for the whois.smallregistry.net record.
      class WhoisSmallregistryNet < Base

        self.tokenizers += [
            :scan_yaml_header,
            :scan_disclaimer,
            :scan_request_time,
            :scan_available,
            :scan_body,
        ]
        
        tokenizer :scan_yaml_header do
          # skip the YAML prelude
          @input.scan(/^---.*\n/)
        end

        tokenizer :scan_disclaimer do
          if @input.match?(/^#/) && disclaimer = @input.scan_until(/^#\n/)
            @ast["field:disclaimer"] = disclaimer
          end
        end

        tokenizer :scan_request_time do
          if @input.scan(/^# (\d+-\d+-\d+T.*)\n/)
            @ast["field:request_time"] = @input[1].strip
          end
        end

        tokenizer :scan_available do
          if @input.scan(/^# Object not found.*\n/)
            @ast["status:available"] = true
          end
        end

        tokenizer :scan_body do
          str = @input.rest
          str.gsub!(/ (![\w]+) \n/, " \n") # remove custom types
          @ast.merge! YAML.load(str)
          @input.terminate
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
whois-3.6.5 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-3.6.4 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-3.6.3 lib/whois/record/scanners/whois.smallregistry.net.rb