Skip to content

Commit

Permalink
whois.nic.cz should support multiple status (closes GH-190).
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Oct 22, 2012
1 parent 34c00cb commit 5f27dd1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@


- FIXED: whois.nic.cz should support status `To be deleted`. - FIXED: whois.nic.cz should support status `To be deleted`.


- FIXED: whois.nic.cz should support multiple status (GH-190).



## Release 2.7.0 ## Release 2.7.0


Expand Down
11 changes: 7 additions & 4 deletions lib/whois/record/parser/base_whoisd.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ class BaseWhoisd < Base




property_supported :status do property_supported :status do
node('status') do |string| node('status') do |value|
string = string.first if string.is_a?(Array) values = Array.wrap(value)
self.class.status_mapping[string.downcase] || status = values.each do |s|
Whois.bug!(ParserError, "Unknown status `#{string}'.") v = self.class.status_mapping[s.downcase]
break v if v
end
status || Whois.bug!(ParserError, "Unknown status `#{string}'.")
end || :available end || :available
end end


Expand Down
6 changes: 4 additions & 2 deletions lib/whois/record/parser/whois.nic.cz.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class Parser
# The Example parser for the list of all available methods. # The Example parser for the list of all available methods.
# #
class WhoisNicCz < BaseWhoisd class WhoisNicCz < BaseWhoisd
self.status_mapping.merge!({ self.status_mapping = {
'paid and in zone' => :registered,
'update prohibited' => :registered, 'update prohibited' => :registered,
'expired' => :expired,
'to be deleted' => :expired, 'to be deleted' => :expired,
}) }
end end


end end
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@
#status
should: %s == :expired

#available?
should: %s == false

#registered?
should: %s == true
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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.nic.cz/property_status_expired_and_more.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#

require 'spec_helper'
require 'whois/record/parser/whois.nic.cz.rb'

describe Whois::Record::Parser::WhoisNicCz, "property_status_expired_and_more.expected" do

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

describe "#status" do
it do
subject.status.should == :expired
end
end
describe "#available?" do
it do
subject.available?.should == false
end
end
describe "#registered?" do
it do
subject.registered?.should == true
end
end
end

0 comments on commit 5f27dd1

Please sign in to comment.