Sha256: a5bf666815352492649d044efe8cf02618a6c6f667556bc423fbbef05d287325

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

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


require 'whois/record/scanners/base'


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

8 entries across 8 versions & 1 rubygems

Version Path
whois-2.7.0 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-2.6.4 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-2.6.3 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-2.6.2 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-2.6.1 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-2.6.0 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-2.5.1 lib/whois/record/scanners/whois.smallregistry.net.rb
whois-2.5.0 lib/whois/record/scanners/whois.smallregistry.net.rb