Whois 0.8.1 is now available. The new version of the GEM includes the compatibility with the new Denic response format and a small features to check whether the current answer supports a specific property.
For instance, let's suppose you want to create a basic whois interface and you need to display the creation and expiration dates for any domain entered by the user. Some whois responses don't provide the registration date and if you try to access the created_on
property the library will raise a PropertyNotSupported
error.
a = Whois.query "google.be"
a.created_on
>> a.created_on
Whois::PropertyNotSupported: Unable to find a parser for `created_on'
from /Library/Ruby/Gems/1.8/gems/whois-0.8.1/lib/whois/answer/parser.rb:73:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/whois-0.8.1/lib/whois/answer.rb:125:in `send'
from /Library/Ruby/Gems/1.8/gems/whois-0.8.1/lib/whois/answer.rb:125:in `method_missing'
from (irb):8
Prior to Whois 0.8.1 you would have to rescue the exception and the final code can get pretty messy. Now all you have to do is to check whether the answer supports the property with the supported?
method.
a = Whois.query "google.be"
if a.supported? :created_on
a.created_on
end
As usual, you can install/upgrade the library via RubyGems.
gem install whois