Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WhoisNicGl < BaseCocca #166

Merged
merged 1 commit into from
May 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 2 additions & 63 deletions lib/whois/record/parser/whois.nic.gl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,15 @@
#++


require 'whois/record/parser/base'
require 'whois/record/parser/base_cocca'


module Whois
class Record
class Parser

#
# = whois.nic.gl parser
#
# Parser for the whois.nic.gl 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.
#
class WhoisNicGl < Base

property_supported :status do
if content_for_scanner =~ /Status:\s+(.+?)\n/
case $1.downcase
when "active" then :registered
when "delegated" then :registered
when "not registered" then :available
else
Whois.bug!(ParserError, "Unknown status `#{$1}'.")
end
else
Whois.bug!(ParserError, "Unable to parse status.")
end
end

property_supported :available? do
status == :available
end

property_supported :registered? do
!available?
end


property_supported :created_on do
if content_for_scanner =~ /Created:\s+(.+?)\n/
Time.parse($1)
end
end

property_supported :updated_on do
if content_for_scanner =~ /Modified:\s+(.+?)\n/
Time.parse($1)
end
end

property_supported :expires_on do
if content_for_scanner =~ /Expires:\s+(.+?)\n/
Time.parse($1)
end
end


property_supported :nameservers do
if content_for_scanner =~ /Name Servers:\n((.+\n)+)\n/
$1.split("\n").map do |name|
Record::Nameserver.new(name.strip)
end
end
end

class WhoisNicGl < BaseCocca
end

end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#domain
should: %s == "u34jedzcq.gl"

#domain_id
should: %s raise_error(Whois::PropertyNotSupported)


#status
should: %s == :available

Expand Down
14 changes: 14 additions & 0 deletions spec/fixtures/responses/whois.nic.gl/status_registered.expected
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#domain
should: %s == "google.gl"

#domain_id
should: %s raise_error(Whois::PropertyNotSupported)


#status
should: %s == :registered

Expand All @@ -21,6 +28,13 @@
should: %s == Time.parse("2013-01-01")


#registrar
should: %s CLASS(registrar)
should: %s.id == nil
should: %s.name == "MarkMonitor"
should: %s.url == "http://www.markmonitor.com"


#nameservers
should: %s CLASS(array)
should: %s SIZE(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
@parser = klass.new(part)
end

describe "#domain" do
it do
@parser.domain.should == "u34jedzcq.gl"
end
end
describe "#domain_id" do
it do
lambda { @parser.domain_id }.should raise_error(Whois::PropertyNotSupported)
end
end
describe "#status" do
it do
@parser.status.should == :available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
@parser = klass.new(part)
end

describe "#domain" do
it do
@parser.domain.should == "google.gl"
end
end
describe "#domain_id" do
it do
lambda { @parser.domain_id }.should raise_error(Whois::PropertyNotSupported)
end
end
describe "#status" do
it do
@parser.status.should == :registered
Expand Down Expand Up @@ -54,6 +64,14 @@
@parser.expires_on.should == Time.parse("2013-01-01")
end
end
describe "#registrar" do
it do
@parser.registrar.should be_a(Whois::Record::Registrar)
@parser.registrar.id.should == nil
@parser.registrar.name.should == "MarkMonitor"
@parser.registrar.url.should == "http://www.markmonitor.com"
end
end
describe "#nameservers" do
it do
@parser.nameservers.should be_a(Array)
Expand Down