Permalink
Browse files

Replace WhoisNicCo custom parser with BaseShared2

  • Loading branch information...
1 parent a0f2812 commit 13fdc5db462d9e83178f8f22b1ed759a5df195cd @weppos committed Sep 18, 2012
@@ -7,64 +7,19 @@
#++
-require 'whois/record/parser/base'
+require 'whois/record/parser/base_shared2'
module Whois
class Record
class Parser
- #
- # = whois.nic.co parser
- #
# Parser for the whois.nic.co server.
#
- # NOTE: This parser is just a stub and provides only a few basic methods
- # to check for domain availability and get domain status.
- # Please consider to contribute implementing missing methods.
- # See WhoisNicIt parser for an explanation of all available methods
- # and examples.
+ # @see Whois::Record::Parser::Example
+ # The Example parser for the list of all available methods.
#
- class WhoisNicCo < Base
-
- property_supported :status do
- content_for_scanner.scan(/Domain Status:\s+(.*?)\n/).flatten
- end
-
- property_supported :available? do
- !!(content_for_scanner =~ /Not found:/)
- end
-
- property_supported :registered? do
- !available?
- end
-
-
- property_supported :created_on do
- if content_for_scanner =~ /Domain Registration Date:\s+(.*)\n/
- Time.parse($1)
- end
- end
-
- property_supported :updated_on do
- if content_for_scanner =~ /Domain Last Updated Date:\s+(.*)\n/
- Time.parse($1)
- end
- end
-
- property_supported :expires_on do
- if content_for_scanner =~ /Domain Expiration Date:\s+(.*)\n/
- Time.parse($1)
- end
- end
-
-
- property_supported :nameservers do
- content_for_scanner.scan(/Name Server:\s+(.+)\n/).flatten.map do |name|
- Record::Nameserver.new(:name => name.downcase)
- end
- end
-
+ class WhoisNicCo < BaseShared2
end
end
@@ -43,6 +43,10 @@ def parse
@input.skip(/^\n/)
end
+ tokenizer :skip_blank_line do
+ @input.skip(/^[\s]*\n/)
+ end
+
tokenizer :skip_newline do
@input.skip(/\n/)
end
@@ -18,7 +18,7 @@ module Scanners
class BaseShared2 < Base
self.tokenizers += [
- :skip_empty_line,
+ :skip_blank_line,
:scan_available,
:scan_keyvalue,
:skip_lastupdate,
@@ -38,7 +38,7 @@ class BaseShared2 < Base
end
tokenizer :skip_fuffa do
- @input.scan(/^\S(.+)\n/)
+ @input.skip(/^\S(.+)\n/)
end
end
@@ -1,5 +1,5 @@
#status
- should: %s == []
+ should: %s == nil
#available?
should: %s == true
@@ -23,7 +23,7 @@
describe "#status" do
it do
- subject.status.should == []
+ subject.status.should == nil
end
end
describe "#available?" do

0 comments on commit 13fdc5d

Please sign in to comment.