Sha256: e277aabcc707e994f6a6f4585c95bb861a5ac223cd0228e3c1242474e4315f45
Contents?: true
Size: 1.77 KB
Versions: 3
Compression:
Stored size: 1.77 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.sx record. # # @since 2.6.2 class WhoisSx < Base self.tokenizers += [ :skip_header, :skip_comments, :skip_empty_line, :flag_section_start, :flag_section_end, :scan_section, :scan_keyvalue, ] tokenizer :skip_header do if @input.pos == 0 && @input.match?(/^\[/) @input.skip_until(/\n/) end end tokenizer :skip_comments do if @input.match?(/^%/) @input.skip_until(/\n/) end end tokenizer :flag_section_start do if @input.scan(/(.+?):\n/) @tmp['section'] = @input[1].strip end end tokenizer :flag_section_end do # if @input.match?(/^\n/) # @tmp.delete('section') # end end tokenizer :scan_section do if @tmp['section'] lines = _scan_lines_to_array(/^(.+)\n/) # Check all lines to be sure there is no case where a value containing a : # is misinterpreted as key : value. # The section is a hash value = if lines.all? { |line| line.index(':', 1) } Hash[lines.map { |line| line.split(':', 2).map(&:strip) }] # The section is an array of values else lines end @ast[@tmp['section']] = value @tmp.delete('section') end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
whois-2.7.0 | lib/whois/record/scanners/whois.sx.rb |
whois-2.6.4 | lib/whois/record/scanners/whois.sx.rb |
whois-2.6.3 | lib/whois/record/scanners/whois.sx.rb |