Sha256: e6eba8193a4415eb61f8d45bf10153b377c7c17205ee904382ca47d8410b0532
Contents?: true
Size: 1.13 KB
Versions: 8
Compression:
Stored size: 1.13 KB
Contents
require_relative 'base' require 'yaml' module Whois 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
Version data entries
8 entries across 8 versions & 2 rubygems