Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
409 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#-- | ||
# 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.cira.ca record. | ||
# | ||
# @since RELEASE | ||
class WhoisCiraCa < Base | ||
|
||
self.tokenizers += [ | ||
:skip_empty_line, | ||
:scan_disclaimer, | ||
:skip_comment, | ||
:scan_header, | ||
:scan_keyvalue, | ||
:scan_nameserver, | ||
] | ||
|
||
|
||
|
||
tokenizer :scan_disclaimer do | ||
if @input.match?(/^% Use of CIRA/) | ||
@ast["field:disclaimer"] = _scan_lines_to_array(/^%(.*)\n/).join("\n") | ||
end | ||
end | ||
|
||
tokenizer :scan_header do | ||
if @input.scan(/^(.+?):\n/) | ||
@tmp["group"] = @input[1] | ||
end | ||
end | ||
|
||
tokenizer :scan_keyvalue do | ||
if @input.scan(/^(.+?):(.*?)\n/) | ||
start = @input[1] | ||
key, value = start.strip, @input[2].strip | ||
|
||
# This is a nested key | ||
target = if start[0] == " " | ||
error!("Expected group.") if @tmp["group"].nil? | ||
@ast[@tmp["group"]] ||= {} | ||
else | ||
@tmp.delete("group") | ||
@ast | ||
end | ||
|
||
more = _scan_lines_to_array(/^\s{#{start.size}}(.+)\n/) | ||
value = more.unshift(value).join("\n") unless more.empty? | ||
|
||
if target[key].nil? | ||
target[key] = value | ||
else | ||
target[key] = Array.wrap(target[key]) | ||
target[key] << value | ||
end | ||
end | ||
end | ||
|
||
tokenizer :scan_nameserver do | ||
if @input.scan(/^\s+(.+?)\n/) && @tmp["group"] == "Name servers" | ||
@ast["field:nameservers"] ||= [] | ||
@ast["field:nameservers"] << @input[1].strip | ||
end | ||
end | ||
|
||
tokenizer :skip_comment do | ||
@input.skip(/^%.*\n/) | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.