Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #339 from domainr/fi-reserved
Add 'not available' status to .fi
  • Loading branch information
weppos committed Jun 17, 2014
2 parents f7e7cfc + 68d0c47 commit 46adf58
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/whois/record/parser/whois.fi.rb
Expand Up @@ -39,7 +39,9 @@ class WhoisFi < Base


property_supported :status do
if registered?
if reserved?
:reserved
elsif registered?
case node("status", &:downcase)
when "granted"
:registered
Expand Down Expand Up @@ -76,11 +78,11 @@ class WhoisFi < Base


property_not_supported :registrar

property_supported :registrant_contacts do
node("descr") do |array|
address = node("address")

Record::Contact.new(
type: Record::Contact::TYPE_REGISTRANT,
id: array[1],
Expand All @@ -105,6 +107,11 @@ class WhoisFi < Base
end
end

# NEWPROPERTY
def reserved?
!!content_for_scanner.match(/Domain not available/)
end

end

end
Expand Down
7 changes: 7 additions & 0 deletions lib/whois/record/scanners/whois.fi.rb
Expand Up @@ -22,6 +22,7 @@ class WhoisFi < Base
:scan_available,
:scan_disclaimer,
:scan_keyvalue,
:scan_reserved
]


Expand All @@ -31,6 +32,12 @@ class WhoisFi < Base
end
end

tokenizer :scan_reserved do
if @input.skip(/^Domain not available/)
@ast["status:reserved"] = true
end
end

tokenizer :scan_disclaimer do
if @input.match?(/^More information/)
@ast["field:disclaimer"] = @input.scan_until(/(.*)\n\n/).strip
Expand Down
48 changes: 48 additions & 0 deletions spec/fixtures/responses/whois.fi/status_reserved.expected
@@ -0,0 +1,48 @@
#disclaimer
%s == "More information is available at https://domain.fi/\nCopyright (c) Finnish Communications Regulatory Authority"


#domain
%s == nil

#domain_id
%s %ERROR{AttributeNotSupported}


#status
%s == :reserved

#available?
%s == false

#reserved?
%s == true


#created_on
%s == nil

#updated_on
%s == nil

#expires_on
%s == nil


#registrar
%s %ERROR{AttributeNotSupported}

#registrant_contacts
%s %CLASS{array}
%s == []

#admin_contacts
%s %ERROR{AttributeNotSupported}

#technical_contacts
%s %ERROR{AttributeNotSupported}


#nameservers
%s %CLASS{array}
%s == []
6 changes: 6 additions & 0 deletions spec/fixtures/responses/whois.fi/status_reserved.txt
@@ -0,0 +1,6 @@

Domain not available

More information is available at https://domain.fi/
Copyright (c) Finnish Communications Regulatory Authority

@@ -0,0 +1,96 @@
# encoding: utf-8

# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/fixtures/responses/whois.fi/status_reserved.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#

require 'spec_helper'
require 'whois/record/parser/whois.fi.rb'

describe Whois::Record::Parser::WhoisFi, "status_reserved.expected" do

subject do
file = fixture("responses", "whois.fi/status_reserved.txt")
part = Whois::Record::Part.new(body: File.read(file))
described_class.new(part)
end

describe "#disclaimer" do
it do
expect(subject.disclaimer).to eq("More information is available at https://domain.fi/\nCopyright (c) Finnish Communications Regulatory Authority")
end
end
describe "#domain" do
it do
expect(subject.domain).to eq(nil)
end
end
describe "#domain_id" do
it do
expect { subject.domain_id }.to raise_error(Whois::AttributeNotSupported)
end
end
describe "#status" do
it do
expect(subject.status).to eq(:reserved)
end
end
describe "#available?" do
it do
expect(subject.available?).to eq(false)
end
end
describe "#reserved?" do
it do
expect(subject.reserved?).to eq(true)
end
end
describe "#created_on" do
it do
expect(subject.created_on).to eq(nil)
end
end
describe "#updated_on" do
it do
expect(subject.updated_on).to eq(nil)
end
end
describe "#expires_on" do
it do
expect(subject.expires_on).to eq(nil)
end
end
describe "#registrar" do
it do
expect { subject.registrar }.to raise_error(Whois::AttributeNotSupported)
end
end
describe "#registrant_contacts" do
it do
expect(subject.registrant_contacts).to be_a(Array)
expect(subject.registrant_contacts).to eq([])
end
end
describe "#admin_contacts" do
it do
expect { subject.admin_contacts }.to raise_error(Whois::AttributeNotSupported)
end
end
describe "#technical_contacts" do
it do
expect { subject.technical_contacts }.to raise_error(Whois::AttributeNotSupported)
end
end
describe "#nameservers" do
it do
expect(subject.nameservers).to be_a(Array)
expect(subject.nameservers).to eq([])
end
end
end

0 comments on commit 46adf58

Please sign in to comment.