lib/whois/record/scanners/whois.sx.rb in whois-2.7.0 vs lib/whois/record/scanners/whois.sx.rb in whois-3.0.0
- old
+ new
@@ -1,77 +1,45 @@
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
-# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+# Copyright (c) 2009-2013 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,
+ :skip_blank_line,
+ :scan_available,
:scan_keyvalue,
+ :skip_lastupdate,
+ :scan_disclaimer,
]
- tokenizer :skip_header do
- if @input.pos == 0 && @input.match?(/^\[/)
- @input.skip_until(/\n/)
+ tokenizer :scan_available do
+ if @input.scan(/^Status: (.+) \(No match for domain "(.+)"\)\n/)
+ @ast["Domain Status"] = @input[1]
+ @ast["Domain Name"] = @input[2]
end
end
- tokenizer :skip_comments do
- if @input.match?(/^%/)
- @input.skip_until(/\n/)
- end
+ tokenizer :skip_lastupdate do
+ @input.skip(/>>>(.+?)<<<\n/)
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')
+ tokenizer :scan_disclaimer do
+ if @input.match?(/^% WHOIS LEGAL STATEMENT/)
+ @ast["field:disclaimer"] = _scan_lines_to_array(/%(.*)\n/).map(&:strip).join("\n")
end
end
end