<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Simone Carletti&#039;s Blog &#187; rubywhois</title>
	<atom:link href="http://www.simonecarletti.com/blog/tags/rubywhois/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonecarletti.com/blog</link>
	<description>Simone Carletti&#039;s personal ramblings on programming, syndication, search engines &#38; marketing.</description>
	<lastBuildDate>Tue, 07 Feb 2012 08:48:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Whois 2.0</title>
		<link>http://www.simonecarletti.com/blog/2011/03/whois-2-0/</link>
		<comments>http://www.simonecarletti.com/blog/2011/03/whois-2-0/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 20:58:19 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Hosting / Domains]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=1417</guid>
		<description><![CDATA[I'm very proud to announce the immediate availability of Whois 2.0.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-606" title="Whois" src="http://www.simonecarletti.com/blog/wp-content/uploads/2009/09/whois-150x150.png" alt="" width="150" height="150" />One year after the <a title="Ruby Whois 1.0 is here!" href="http://www.simonecarletti.com/blog/2010/02/ruby-whois-1-0-is-here/">first major release</a>, almost 2 years after the first commit, 1k commits and 59 versions after, I&#8217;m very proud to announce the immediate availability of <strong>Whois 2.0</strong>.</p>
<p><a title="Ruby Whois - Ruby Whois Gem" href="http://www.ruby-whois.org/">Whois</a> is an intelligent, pure Ruby, <strong>WHOIS client and parser</strong>. It provides a flexible and programmable API to query WHOIS servers and look up IP, TLD, and domain WHOIS information. It also offers command-line interface to run WHOIS queries from the console.</p>
<p>This second major release, the 60th since I released the gem, is a very important milestones. I started working on this project with the idea of <strong>creating a Ruby parser for each TLD available and it took me two years and countless hours to reach this goal</strong>.<span id="more-1417"></span></p>
<h2>Some stats</h2>
<p>To give you a rough idea about the complexity of this project, here&#8217;s a few numbers about Whois 2.0.</p>
<ul>
<li>866,706 different WHOIS records (~3.3 GB of data) analyzed as of March 16th, 2011</li>
<li>425 RSpec test files</li>
<li>444 fixture files extracted from real WHOIS records</li>
<li>3787 RSpec examples and an unknown number of matches (sorry, I stopped keeping track of them when they reached 15k assertions) that probably makes this project one of the gems with the largest RSpec test suite</li>
<li>~20.000 lines of code, including the test files</li>
<li>168 different WHOIS parsers</li>
</ul>
<p>Oh, man. You can&#8217;t believe the amount of work required to cover all the existing WHOIS servers, their features and especially their whims.</p>
<h2>New and Notable</h2>
<p>The increasing support for all existing TLD servers is probably one of the most important changes for this milestone. But the CHANGELOG is very huge and there are a few other changes that are worth a mention.</p>
<p>I already blogged about a few of them.</p>
<ul>
<li>The <a href="http://www.simonecarletti.com/blog/2011/03/new-in-whois-nameservers-are-now-nameserver/"><code>#nameservers</code> property now returns a Nameserver object</a>. This change allows the parser to also extract name server IPv4 and IPv6 addresses.</li>
<li>A <a href="http://www.simonecarletti.com/blog/2011/02/new-in-whois-improved-caching/">new caching mechanism</a> reduces the number of instance variables created.</li>
<li>The library now supports the <a href="http://www.simonecarletti.com/blog/2011/02/new-in-whois-gem-testers/">Gem Testers project</a>.</li>
<li>You can now bind a different address or port to the WHOIS socket request.</li>
</ul>
<p>Last but not least, the <code>Whois::Answer</code> class has been renamed to <code>Whois::Record</code>.</p>
<p>There are a couple of backwards-incompatible changes to the API. These changes were necessary to evolve the API to better reflect the representation of the existing WHOIS responses.</p>
<h2>What&#8217;s Next?</h2>
<p>The Whois library is pretty stable. It is now used in production for several big projects.</p>
<p>The API is mature. A few changes have been made in this major release to support additional WHOIS properties, however I don&#8217;t expect big changes in the future.</p>
<p>The following releases will focus on increasing the list of supported properties for each parser, as well closing some of the <a href="https://github.com/weppos/whois/issues">existing issues</a>.</p>
<p>The biggest change in the API in the near future is likely to be the <a href="https://github.com/weppos/whois/issues#issue/2">standardization of the status property</a>.</p>
<p>In the last months I received some great feedback from people using my library with other platforms, such as Java and .NET. This is amazing.</p>
<p>If you have any case study, case history or feedback, please let me know. I would love to learn more about how you use the library.</p>
<h2>How to Upgrade</h2>
<p>To upgrade to Whois 2.0 please follow the instructions in the <a href="http://www.ruby-whois.org/manual/upgrading.html">documentation page</a>.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/12/whois-0-9-0/' rel='bookmark' title='Whois 0.9.0: WHOIS parsers, CLI and performances'>Whois 0.9.0: WHOIS parsers, CLI and performances</a></li>
<li><a href='http://www.simonecarletti.com/blog/2010/01/new-in-whois-principle-of-least-surprise/' rel='bookmark' title='New in Whois: Applying the Principle of Least Surprise'>New in Whois: Applying the Principle of Least Surprise</a></li>
<li><a href='http://www.simonecarletti.com/blog/2010/01/new-in-whois-property-is-set/' rel='bookmark' title='New in Whois: property is set?'>New in Whois: property is set?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2011/03/whois-2-0/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>New in Whois: #nameservers are now Nameserver</title>
		<link>http://www.simonecarletti.com/blog/2011/03/new-in-whois-nameservers-are-now-nameserver/</link>
		<comments>http://www.simonecarletti.com/blog/2011/03/new-in-whois-nameservers-are-now-nameserver/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 08:58:51 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=1368</guid>
		<description><![CDATA[In the new Whois version the property #nameservers returns an array of Nameserver object, containing DNS name, ipv4 and ipv6 addresses.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time for another update on Ruby <a href="http://www.ruby-whois.org/">Whois library</a>. Let&#8217;s talk about <a title="Name server - Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Name_server">name servers</a>.</p>
<p>The most part of WHOIS servers follow the &#8220;convention&#8221; to include the name server list of a domain in the WHOIS record.</p>
<p>A name server is represented by a DNS name, which is a string.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ns1.google.com<br />
ns2.google.com</div></td></tr></tbody></table></div>
<p>The DNS name resolves to an IPv4 IP address.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ns1.google.com =&gt; 216.239.32.10<br />
ns2.google.com =&gt; 216.239.34.10</div></td></tr></tbody></table></div>
<p>Optionally, the DNS name can resolve to an IPv6 IP address.git</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ns1.nic.fr =&gt; 2001:660:3003:2::4:1<br />
ns2.nic.fr =&gt; 2001:660:3005:1::1:2</div></td></tr></tbody></table></div>
<p>Each WHOIS server arbitrary choses the amount of information to store and return in a WHOIS record. Some registries returns only the DNS name, other registries include IP addresses as well.<span id="more-1368"></span></p>
<p>In the current WHOIS version, the list of name servers is accessible through the <code>#nameservers</code> property.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">r = Whois.<span style="color:#9900CC;">query</span> <span style="color:#996600;">&quot;google.com&quot;</span><br />
r.<span style="color:#9900CC;">nameservers</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; [&quot;ns1.google.com&quot;, &quot;ns2.google.com&quot;]</span></div></td></tr></tbody></table></div>
<p>The method returns an <code>Array</code> of <code>String</code>. This is a lossy implementation because it completely ignores the IPv4 and IPv6 details.</p>
<p>The new Whois version solves this problem by introducing a new <code>Whois::Answer::Nameserver</code> object. This object is a <code>Struct</code> composed by three attributes: <code>name</code>, <code>ipv4</code> and <code>ipv6</code>.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ns = Nameserver.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><br />
&nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;ns1.nic.fr&quot;</span>,<br />
&nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:ipv4</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;192.134.4.1&quot;</span>,<br />
&nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:ipv6</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;2001:660:3003:2::4:1&quot;</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
ns.<span style="color:#9900CC;">name</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; &quot;ns1.nic.fr&quot;</span><br />
ns.<span style="color:#9900CC;">ipv4</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; &quot;192.134.4.1&quot;</span><br />
ns.<span style="color:#9900CC;">ipv6</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; &quot;2001:660:3003:2::4:1&quot;</span></div></td></tr></tbody></table></div>
<p>In the new Whois version, the <code>#nameservers</code> implementation has been changed to return an array of <code>Nameserver</code> instead of a simple <code>String</code>.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">r = Whois.<span style="color:#9900CC;">query</span> <span style="color:#996600;">&quot;nic.fr&quot;</span><br />
r.<span style="color:#9900CC;">nameservers</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; [</span><br />
<span style="color:#008000; font-style:italic;"># &nbsp; &nbsp; #&lt;struct Whois::Answer::Nameserver name=&quot;ns1.nic.fr&quot;, ipv4=&quot;192.134.4.1&quot;, ipv6=&quot;2001:660:3003:2::4:1&quot;&gt;,</span><br />
<span style="color:#008000; font-style:italic;"># &nbsp; &nbsp; #&lt;struct Whois::Answer::Nameserver name=&quot;ns2.nic.fr&quot;, ipv4=&quot;192.93.0.4&quot;, ipv6=&quot;2001:660:3005:1::1:2&quot;&gt;,</span><br />
<span style="color:#008000; font-style:italic;"># &nbsp; &nbsp; ...</span><br />
<span style="color:#008000; font-style:italic;"># &nbsp; &nbsp;]</span></div></td></tr></tbody></table></div>
<p>It&#8217;s important to know that this change can break backwards compatibility. In order to minimize the impact, <code>Nameserver#to_s</code> returns the <code>String</code> value of the <code>name</code> attribute.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Nameserver.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;ns1.nic.fr&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:ipv4</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;192.134.4.1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_s</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; &quot;ns1.nic.fr&quot;</span></div></td></tr></tbody></table></div>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2010/02/ruby-whois-1-0-is-here/' rel='bookmark' title='Ruby Whois 1.0 is here!'>Ruby Whois 1.0 is here!</a></li>
<li><a href='http://www.simonecarletti.com/blog/2011/03/whois-2-0/' rel='bookmark' title='Whois 2.0'>Whois 2.0</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/08/ruby-has-a-new-whois-library/' rel='bookmark' title='Ruby has a new WHOIS library'>Ruby has a new WHOIS library</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2011/03/new-in-whois-nameservers-are-now-nameserver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New in Whois: improved caching</title>
		<link>http://www.simonecarletti.com/blog/2011/02/new-in-whois-improved-caching/</link>
		<comments>http://www.simonecarletti.com/blog/2011/02/new-in-whois-improved-caching/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 11:15:45 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=1279</guid>
		<description><![CDATA[Today, I'm very happy to report that this week I introduced a completely new caching system for the Whois::Answer::Parser.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working very hard to include some of the most important features in the new version of the <a title="Ruby Whois - Ruby Whois Gem" href="http://www.ruby-whois.org/">Ruby Whois library</a>.</p>
<p>Today, I&#8217;m very happy to report that this week I closed the <a href="https://github.com/weppos/whois/issues/18">issue #18</a> which introduces a completely new caching system for the <code>Whois::Answer::Parser</code>.</p>
<p>The way <code>Whois</code> parsers currently work, is to extract a property only the very first time it is requested.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">r = Whois.<span style="color:#9900CC;">query</span> <span style="color:#996600;">&quot;weppos.it&quot;</span><br />
<br />
<span style="color:#008000; font-style:italic;"># the property has never been requested before</span><br />
<span style="color:#008000; font-style:italic;"># the value is computed, cached and returned</span><br />
r.<span style="color:#9900CC;">status</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; :ok</span><br />
<br />
<span style="color:#008000; font-style:italic;"># the property has been requested before</span><br />
<span style="color:#008000; font-style:italic;"># the value is returned without further elaborations</span><br />
r.<span style="color:#9900CC;">status</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; :ok</span></div></td></tr></tbody></table></div>
<p>So far, so good.</p>
<p>The way the system works under the hood, is to create a parser instance variable for every single requested property.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">r = Whois.<span style="color:#9900CC;">query</span> <span style="color:#996600;">&quot;weppos.it&quot;</span><br />
<br />
<span style="color:#008000; font-style:italic;"># get the first parser</span><br />
<span style="color:#008000; font-style:italic;"># because</span><br />
<span style="color:#008000; font-style:italic;"># &nbsp; r.status relies on</span><br />
<span style="color:#008000; font-style:italic;"># a</span><br />
<span style="color:#008000; font-style:italic;"># &nbsp; r.parser.parsers.first.status</span><br />
<span style="color:#CC0066; font-weight:bold;">p</span> = r.<span style="color:#9900CC;">parser</span>.<span style="color:#9900CC;">parsers</span>.<span style="color:#9900CC;">first</span><br />
<br />
<span style="color:#008000; font-style:italic;"># value is not cached</span><br />
<span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">instance_variable_get</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;@status&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; nil</span><br />
<br />
<span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">status</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; :ok</span><br />
<br />
<span style="color:#008000; font-style:italic;"># value is cached</span><br />
<span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">instance_variable_get</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;@status&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#008000; font-style:italic;"># =&gt; :ok</span></div></td></tr></tbody></table></div>
<p>So far, quite good. This approach has a couple of drawbacks.</p>
<p><span id="more-1279"></span>First, it creates an instance variable for every single property. Because of the large (and increasing) <a href="http://www.ruby-whois.org/manual/parser-properties.html">number of properties</a>, the parser object space counts a large number of instance variables. This makes it hard, for instance, to sweep the cache because you have to loop through all instance variables and remove each one.</p>
<p>Second, there&#8217;s a small inefficiency here. Because in Ruby you don&#8217;t have to define variables, an undefined instance variable is <code>nil</code>. But <code>nil</code> is actually a value and properties can have a <code>nil</code> value. In this implementation, you don&#8217;t have a way to distinguish when a value is nil and when it hasn&#8217;t been elaborated yet, thus <code>nil</code> properties will never hit the cache.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> created_on<br />
&nbsp; <span style="color:#0066ff; font-weight:bold;">@created_on</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#9966CC; font-weight:bold;">if</span> very_expensive_scan<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>created_on<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># ... set the value</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># calling #created_on several times will continue to perform</span><br />
<span style="color:#008000; font-style:italic;"># the very_expensive_scan as long as the value != nil.</span></div></td></tr></tbody></table></div>
<p>The new approach uses a single instance variable called <code>@cached_properties</code> as cache. The variable contains a <code>Hash&lt;:key =&gt; value&gt;</code>, where the key is the property and the value the cached result.</p>
<p>If the cache doesn&#8217;t contain any key for given property, then the method hasn&#8217;t been executed yet. Cached <code>nil</code> properties will return <code>nil</code> without further elaboration.</p>
<p>The method <code>#cached_properties_fetch</code> takes care of everything.</p>
<div class="codecolorer-container ruby default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> created_on<br />
&nbsp; cached_properties_fetch<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:created_on</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">nil</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># value is cached and returned</span><br />
created_on<br />
<span style="color:#008000; font-style:italic;"># =&gt; nil</span><br />
<br />
<span style="color:#008000; font-style:italic;"># the request hits the cache</span><br />
created_on<br />
<span style="color:#008000; font-style:italic;"># =&gt; nil</span></div></td></tr></tbody></table></div>
<p>If you need to sweep the cache, reset <code>@cached_properties</code> to an empty <code>Hash</code>.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2010/01/new-in-whois-property-is-set/' rel='bookmark' title='New in Whois: property is set?'>New in Whois: property is set?</a></li>
<li><a href='http://www.simonecarletti.com/blog/2010/01/new-in-whois-principle-of-least-surprise/' rel='bookmark' title='New in Whois: Applying the Principle of Least Surprise'>New in Whois: Applying the Principle of Least Surprise</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/10/ruby-whois-0-8-1/' rel='bookmark' title='Ruby Whois 0.8.1'>Ruby Whois 0.8.1</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2011/02/new-in-whois-improved-caching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New in Whois: Gem Testers</title>
		<link>http://www.simonecarletti.com/blog/2011/02/new-in-whois-gem-testers/</link>
		<comments>http://www.simonecarletti.com/blog/2011/02/new-in-whois-gem-testers/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 16:18:37 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=1283</guid>
		<description><![CDATA[The new Whois version now includes support for gem test.]]></description>
			<content:encoded><![CDATA[<p>At the beginning of February, <a title="Introducing Gem Testers | Engine Yard Ruby on Rails Blog" href="http://www.engineyard.com/blog/2011/introducing-gem-testers/">Engine Yard announced</a> a very interesting project called <a title="Gem Testers" href="http://gem-testers.org/">Gem Testers</a>.</p>
<blockquote><p>Gem Testers was built to make it easier for gem developers to write gems that run everywhere. This is split into two pieces:</p>
<ol>
<li><a title="rubygems-test | RubyGems.org | your community gem host" href="http://rubygems.org/gems/rubygems-test">rubygems-test</a> is a Rubygems plugin which automatically runs the test suite of a specified gem on install.</li>
<li><a title="Gem Testers" href="http://gem-testers.org/">Gem-testers.org</a> is a central repository for test data. Test results are organized primarily by Ruby version and operating system.</li>
</ol>
</blockquote>
<p>I believe this is a wonderful project and it can have a very good impact on the quality of the available Ruby gems.</p>
<p><a href="http://www.ruby-whois.org/">Whois</a> currently counts <strong>211 RSpec examples</strong> and <strong>1899 tests</strong> with <strong>8674 assertions</strong>. This is a very huge test suite which is able to provide an immediate feedback on existing bugs.</p>
<p><span id="more-1283"></span>The new Whois version now includes support for <code>gem test</code>. You can decide to run the tests automatically when installing the gem or run them later by executing</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>gem <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #c20cb9; font-weight: bold;">whois</span></div></td></tr></tbody></table></div>
<p>Read <a href="https://github.com/rubygems/rubygems-test/blob/master/README.txt">rubygems-test README</a> for further information.</p>
<p>Unfortunately, this feature forced me to re-include all the test fixtures and files into the packaged <code>.gem</code>. It means the size of <code>.gem</code> file will be bigger than previous releases.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2011/03/whois-2-0/' rel='bookmark' title='Whois 2.0'>Whois 2.0</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/08/ruby-has-a-new-whois-library/' rel='bookmark' title='Ruby has a new WHOIS library'>Ruby has a new WHOIS library</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/09/ruby-whois-preview-answer-and-parser/' rel='bookmark' title='Ruby Whois preview: WHOIS answer and parser'>Ruby Whois preview: WHOIS answer and parser</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2011/02/new-in-whois-gem-testers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New in Whois: Goodbye RDoc, Welcome Yardoc</title>
		<link>http://www.simonecarletti.com/blog/2010/12/new-in-whois-goodbye-rdoc-welcome-yardoc/</link>
		<comments>http://www.simonecarletti.com/blog/2010/12/new-in-whois-goodbye-rdoc-welcome-yardoc/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 09:08:35 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[rdoc]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[yardoc]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=1211</guid>
		<description><![CDATA[The new version of the Whois library will entirely be documented with YARD]]></description>
			<content:encoded><![CDATA[<p><a href="http://yardoc.org/">YARD</a> is a documentation generation tool for the Ruby programming language.  It is a very powerful alternative to RDoc, actively developed and maintained by <a href="http://gnuu.org/">Loren Segal</a>.</p>
<p>YARD allows you to use Markdown or Textile to write your documentations, provides structured tags to better describe your methods and has a very advanced parsing mechanism. It also under active development, which is a very good sign of interest.</p>
<p>Back in September I asked for feedback about <a href="http://twitter.com/#!/weppos/status/25407638358">using Yardoc over Rdoc</a> and YARD won with full consensus.</p>
<p>I&#8217;m now proud to say that <a href="http://github.com/weppos/whois">the master branch of the Whois library</a> is now entirely documented with YARD. It took several weeks, but I’m really satisfied with the result. I also had the chance to fix several documentation errors an increase documentation coverage.</p>
<div class="wp-caption aligncenter" style="width: 610px"><img title="Yardoc for Whois" src="http://share.weppos.net/simonecarletti/skitched-20101209-122209.png" alt="" width="600" height="436" /><p class="wp-caption-text">The result of Yardoc for Whois README</p></div>
<p><span id="more-1211"></span>The Yardoc documentation will eventually replace the current <a href="http://www.ruby-whois.org/api/">Whois RDoc documentation</a>. I&#8217;m sure that it will be an awesome integration to the existing <a href="http://www.ruby-whois.org/manual/index.html">Whois manual</a>.</p>
<p>In the meantime, you can try it yourself by downloading the library from Github and using the <a href="http://gnuu.org/2010/08/29/announcing-yard-0-6-0/">YARD server</a>, an other awesome YARD feature.</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ gem install yard<br />
$ git clone https://github.com/weppos/whois.git<br />
$ cd whois<br />
$ yard server --reload</div></td></tr></tbody></table></div>
<div class="wp-caption aligncenter" style="width: 610px"><img title="Yardoc for Whois" src="http://share.weppos.net/simonecarletti/skitched-20101209-123749.png" alt="" width="600" height="436" /><p class="wp-caption-text">The result of Yardoc for Whois::Answer</p></div>
<p>I already converted the <a href="http://www.simonecarletti.com/code/public_suffix_service/">Public Suffix Service</a> <a href="http://www.simonecarletti.com/code/public_suffix_service/api/">API documentation</a> to YARD a few weeks ago.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2011/02/new-in-whois-gem-testers/' rel='bookmark' title='New in Whois: Gem Testers'>New in Whois: Gem Testers</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/09/ruby-whois-preview-answer-and-parser/' rel='bookmark' title='Ruby Whois preview: WHOIS answer and parser'>Ruby Whois preview: WHOIS answer and parser</a></li>
<li><a href='http://www.simonecarletti.com/blog/2010/02/ruby-whois-moved-to-ruby-whois-org/' rel='bookmark' title='Ruby Whois moved to ruby-whois.org'>Ruby Whois moved to ruby-whois.org</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2010/12/new-in-whois-goodbye-rdoc-welcome-yardoc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Whois 1.0 is here!</title>
		<link>http://www.simonecarletti.com/blog/2010/02/ruby-whois-1-0-is-here/</link>
		<comments>http://www.simonecarletti.com/blog/2010/02/ruby-whois-1-0-is-here/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 12:54:32 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Hosting / Domains]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=986</guid>
		<description><![CDATA[Whois 1.0 is now available: Whois is an intelligent pure Ruby WHOIS client and parser.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ruby-whois.org/">Whois</a> is an intelligent <strong>pure Ruby WHOIS client and parser</strong>.</p>
<p>It is a OS-independent library and doesn’t require external C libraries or Gems: it is a 100% Ruby software with all the advantages and disadvantages that it involves. This software was developed to power RoboDomain and it eventually become a standalone library.</p>
<p>Whois provides the following key features:</p>
<ul>
<li>Ability to query registry data for <a href="http://www.ruby-whois.org/manual/usage.html#usage-objects">IPv4, IPv6, TLDs, and domain names</a></li>
<li>Ability to <a href="http://www.ruby-whois.org/manual/parser.html">parse WHOIS responses</a></li>
<li>Flexible and extensible interface (e.g. You can define <a href="http://www.ruby-whois.org/manual/server.html">custom servers</a> on the fly)</li>
<li>Object oriented design, featuring 10 different design patterns</li>
<li>Pure Ruby library, without any external dependency other than Ruby itself</li>
<li>Compatible with <a href="http://www.ruby-whois.org/manual/installation.html#installation-requirements">Ruby 1.8.6 and greater</a>, including Ruby 1.9 branch</li>
<li>Successfully tested against several <a href="http://www.ruby-whois.org/manual/interpreters.html">Ruby implementations</a>, including Ruby, Ruby Enterprise Edition, JRuby, and MacRuby</li>
</ul>
<h2><span id="more-986"></span>Whois 1.0</h2>
<p>Whois 1.0 is the first major release since <a title="Ruby has a new WHOIS library  –  Simone Carletti's Blog" href="http://www.simonecarletti.com/blog/2009/08/ruby-has-a-new-whois-library/">I started working on the library one year ago</a>. It reached an high level of maturity and stability and you can safely consider it production ready.</p>
<p><a href="http://github.com/weppos/whois/compare/release-0.9.0...release-1.0.0">Compared with previous version</a>, Whois 1.0 includes a really huge CHANGELOG (more than 100 lines!). The most important features are:</p>
<ul>
<li>Updates to existing definitions</li>
<li>48 New WHOIS Parsers</li>
<li>Ability to check <a title="New in Whois: property is set?  –  Simone Carletti's Blog" href="http://www.simonecarletti.com/blog/2010/01/new-in-whois-property-is-set/">whether a property is set</a></li>
<li><a title="New in Whois: command line improvements  –  Simone Carletti's Blog" href="http://www.simonecarletti.com/blog/2010/02/new-in-whois-command-line-improvements/">Command Line Improvements</a></li>
<li><a title="New in Whois: Applying the Principle of Least Surprise  –  Simone Carletti's Blog" href="http://www.simonecarletti.com/blog/2010/01/new-in-whois-principle-of-least-surprise/">Changes to the internal Answer/Parser architecture</a> to improve usability</li>
</ul>
<p>Last but not least, <a title="Ruby Whois moved to ruby-whois.org  –  Simone Carletti's Blog" href="http://www.simonecarletti.com/blog/2010/02/ruby-whois-moved-to-ruby-whois-org/">a dedicated site</a> is now available at <a title="Ruby Whois - Ruby Whois Gem" href="http://www.ruby-whois.org/">ruby-whois.org</a>.</p>
<h2>A Retrospective</h2>
<p>Whois 1.0 is a really important milestone. The <a title="Ruby has a new WHOIS library  –  Simone Carletti's Blog" href="http://www.simonecarletti.com/blog/2009/08/ruby-has-a-new-whois-library/">first Whois release</a> was just another WHOIS library. Yes, it offered support for all existing TLDs, but that was just the beginning. My idea was to creare a library to be able to parse and access all WHOIS responses with a single, standardized, object oriented API.</p>
<p>The current Whois library perfectly fit this milestone. Unfortunately, there&#8217;s still a big number of unsupported server, but I&#8217;m working really hard to reduce the gap. Also, in the last months a small number of users contributed back with servers, patches, changes and I&#8217;m really grateful to them.</p>
<p>If you look at the CHANGELOG, Whois has improved day after day.</p>
<h2>The Client side</h2>
<p>Whois 1.0 is a pure Ruby WHOIS client. It means you can install and use it on any platform where Ruby is supported, including (but not limited to) Microsoft Windows, Linux, MacOSX and Solaris.</p>
<p>This is one of the most important feature, compared with other WHOIS libraries. Whois is shipped with a Command Line Interface you can use to lookup a domain.</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ ruby-whois google.com</div></td></tr></tbody></table></div>
<p>And this works on Windows too!</p>
<p>Whois is an intelligent Whois client. It means, you don&#8217;t need to know anything about WHOIS, Dns or TLD. Simply feed the client with the domain you want to lookup, and wait for the response.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">require 'rubygems'<br />
require 'whois'<br />
<br />
a = Whois.query &quot;google.com&quot;<br />
puts a</div></td></tr></tbody></table></div>
<p>Whois will automatically choose the best WHOIS server according to the given query. If the query is a domain, Whois will try to find a server for the corresponding TLD. If the query is an IPv4 or IPv6, Whois will send the request to the corresponding management authority.</p>
<p>TLD and IP definitions are included in the package and read when the library is loaded. You can always update/change them at runtime.</p>
<h2>The Parser side</h2>
<p>Until now, Whois just seems to be an other powerful-but-standard WHOIS client. But this is not true.</p>
<p>The biggest difference between Whois and other WHOIS libraries, is that Whois can parse and decompose a raw WHOIS response into a powerful Ruby object.<br />
This means, you can access WHOIS property calling a simple method rather than dealing with complex regular expressions in order to extract the data you need.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">require 'rubygems'<br />
require 'whois'<br />
<br />
a = Whois.query &quot;google.it&quot;<br />
puts a.available?<br />
# =&gt; false<br />
<br />
a.nameservers.each do |nameserver|<br />
&nbsp; puts nameserver<br />
end<br />
# =&gt; ns1.google.com<br />
# =&gt; ns4.google.com<br />
# =&gt; ns2.google.com<br />
# =&gt; ns3.google.com<br />
<br />
puts a.created_on<br />
# =&gt; Fri Dec 10 00:00:00 +0100 1999<br />
puts a.expires_on<br />
# =&gt; Sat Nov 27 00:00:00 +0100 2010</div></td></tr></tbody></table></div>
<p>You can read more at <a title="Ruby Whois - Ruby Whois Gem" href="http://www.ruby-whois.org/">ruby-whois.org</a>.</p>
<h2>RoboDomain</h2>
<p>Whois library has been creates to power RoboDomain project. With Robodomain you can <strong>keep track of any domain in one single place</strong>: log transactions, store notes, check domain status and enjoy our network tools.</p>
<p>Be sure to signup for an <a title="RoboDomain" href="http://www.robodomain.com/">invitation code</a> if you want to join the beta program.</p>
<h2>Contribute</h2>
<p>Whois is an <a title="weppos's whois at master - GitHub" href="http://github.com/weppos/whois">open source project</a> and released under the terms of the MIT license.</p>
<p>You can contribute <a title="Issues - weppos/whois - GitHub" href="http://github.com/weppos/whois/issues">by suggesting new features and reporting bugs</a> or you can fork away the project and submit your changes.</p>
<p>Do you have a question? Need an help with the library? <a title="Ruby Whois |   Google Groups" href="http://groups.google.com/group/ruby-whois">Join the discussion group</a>.</p>
<p>Enjoy Ruby Whois 1.0.</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ gem install whois</div></td></tr></tbody></table></div>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/09/ruby-whois-preview-answer-and-parser/' rel='bookmark' title='Ruby Whois preview: WHOIS answer and parser'>Ruby Whois preview: WHOIS answer and parser</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/12/whois-0-9-0/' rel='bookmark' title='Whois 0.9.0: WHOIS parsers, CLI and performances'>Whois 0.9.0: WHOIS parsers, CLI and performances</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/09/ruby-whois-0-8-0/' rel='bookmark' title='Ruby Whois 0.8.0'>Ruby Whois 0.8.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2010/02/ruby-whois-1-0-is-here/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New in Whois: command line improvements</title>
		<link>http://www.simonecarletti.com/blog/2010/02/new-in-whois-command-line-improvements/</link>
		<comments>http://www.simonecarletti.com/blog/2010/02/new-in-whois-command-line-improvements/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 20:18:26 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Hosting / Domains]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=950</guid>
		<description><![CDATA[The new Whois version comes with an improved CLI with better error handling.]]></description>
			<content:encoded><![CDATA[<p>Whois 0.8.0 was released with a <a href="http://www.simonecarletti.com/blog/2009/12/whois-0-9-0/">new command line tool</a> to perform one-line WHOIS queries.</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ ruby-whois google.com</div></td></tr></tbody></table></div>
<p>WHOIS requests can fail and, unfortunately, the existing version of the CLI doesn&#8217;t handle this case very well. When an exception is raised, the CLI exits printing an unfriendly Ruby stack trace.<span id="more-950"></span></p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ ruby-whois karnaugh.za.net<br />
/Users/weppos/.rvm/ruby-1.8.7-p174/lib/ruby/1.8/timeout.rb:60:in `ask_the_socket': execution expired (Timeout::Error)<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:77:in `query_the_socket'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/standard.rb:34:in `request'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:52:in `query'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:66:in `with_buffer'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/server/adapters/base.rb:51:in `query'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/client.rb:72:in `query'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/lib/whois/client.rb:70:in `query'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/gems/whois-0.8.1/bin/ruby-whois:37<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/bin/ruby-whois:19:in `load'<br />
&nbsp; &nbsp; from /Users/weppos/.rvm/gems/ruby/1.8.7/bin/ruby-whois:19</div></td></tr></tbody></table></div>
<p>I&#8217;m happy to say that now his is just a bad memory. In case of error, the new CLI writes the error message to <code>STDERR</code> then terminates the execution and sets the <a href="http://www.faqs.org/docs/abs/HTML/exit-status.html">exit status</a> to <code>1</code>.</p>
<div class="codecolorer-container text default code-bash" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ ruby-whois karnaugh.za.net<br />
Request Timeout<br />
<br />
$ ruby-whois google.es<br />
This TLD has no whois server, but you can access the whois database at `https://www.nic.es/'</div></td></tr></tbody></table></div>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/08/ruby-has-a-new-whois-library/' rel='bookmark' title='Ruby has a new WHOIS library'>Ruby has a new WHOIS library</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/09/ruby-whois-preview-answer-and-parser/' rel='bookmark' title='Ruby Whois preview: WHOIS answer and parser'>Ruby Whois preview: WHOIS answer and parser</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/12/whois-0-9-0/' rel='bookmark' title='Whois 0.9.0: WHOIS parsers, CLI and performances'>Whois 0.9.0: WHOIS parsers, CLI and performances</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2010/02/new-in-whois-command-line-improvements/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby Whois moved to ruby-whois.org</title>
		<link>http://www.simonecarletti.com/blog/2010/02/ruby-whois-moved-to-ruby-whois-org/</link>
		<comments>http://www.simonecarletti.com/blog/2010/02/ruby-whois-moved-to-ruby-whois-org/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 19:08:44 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Hosting / Domains]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=974</guid>
		<description><![CDATA[The Whois 1.0 release is just around the corner and to celebrate the first major release the library is changing home from my Codestuff site to www.ruby-whois.org.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.simonecarletti.com/blog/tags/rubywhois/">Whois 1.0 release</a> is just around the corner and to celebrate the first major release the library is changing home from <a href="http://code.simonecarletti.com/">my Codestuff site</a> to <a href="http://www.ruby-whois.org">ruby-whois.org</a>.</p>
<p>The repository is still hosted on GitHub and in the next days I&#8217;ll probably migrate the issue management as well.</p>
<p>The design of the new Whois website is clearly influenced by this website and <a href="http://tomayko.com/src/rack-cache/">Rack::Cache</a>. All HTML files are automatically generated using <a href="http://github.com/mojombo/jekyll">Jekyll</a>. The new site contains all the existing documentation published on the legacy wiki, reorganized and updated. As soon as Whois 1.0 will be available, I promise to spend some time writing more details about the advanced features such as creating WHOIS parsers and using the answer object.</p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2009/08/ruby-has-a-new-whois-library/' rel='bookmark' title='Ruby has a new WHOIS library'>Ruby has a new WHOIS library</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/09/ruby-whois-preview-answer-and-parser/' rel='bookmark' title='Ruby Whois preview: WHOIS answer and parser'>Ruby Whois preview: WHOIS answer and parser</a></li>
<li><a href='http://www.simonecarletti.com/blog/2010/02/ruby-whois-1-0-is-here/' rel='bookmark' title='Ruby Whois 1.0 is here!'>Ruby Whois 1.0 is here!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2010/02/ruby-whois-moved-to-ruby-whois-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New in Whois: property is set?</title>
		<link>http://www.simonecarletti.com/blog/2010/01/new-in-whois-property-is-set/</link>
		<comments>http://www.simonecarletti.com/blog/2010/01/new-in-whois-property-is-set/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 22:46:21 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Hosting / Domains]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=937</guid>
		<description><![CDATA[The new Ruby Whois version will offer the ability to check whether a property is set using the standard method? Ruby convention.]]></description>
			<content:encoded><![CDATA[<p>The new <a href="http://code.simonecarletti.com/whois">Ruby Whois</a> version <a href="http://github.com/weppos/whois/commit/9f5132c2a70b1736799b2bb79b3c6b3f3c778c61">will offer</a> the ability to check whether a property is set using the standard <code>method?</code> Ruby convention. This means, you no longer need to check whether a property is supported, get the property value and compare it to <code>nil</code>.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a = Whois.query &quot;google.it&quot;<br />
a.created_on?<br />
# =&gt; true<br />
<br />
a = Whois.query &quot;notregistered.it&quot;<br />
a.created_on?<br />
# =&gt; false</div></td></tr></tbody></table></div>
<p><span id="more-937"></span>Two important aspects to keep in mind. First, this method works only at answer level.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a = Whois.query &quot;google.it&quot;<br />
a.created_on?<br />
# =&gt; true<br />
a.parser.created_on?<br />
# =&gt; NoMethodError</div></td></tr></tbody></table></div>
<p>Second, this method doesn&#8217;t care whether the property is supported or not. It returns <code>false</code> either if the property is not supported or the value is <code>nil</code>.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a = Whois.query &quot;notregistered.it&quot;<br />
<br />
# created_on is a property supported<br />
# by .it TLD parser and empty for this<br />
# specific query<br />
a.created_on?<br />
# =&gt; false<br />
<br />
# domain_is is not a property supported<br />
# by .it TLD parser<br />
a.domain_id?<br />
# =&gt; false</div></td></tr></tbody></table></div>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2010/01/new-in-whois-principle-of-least-surprise/' rel='bookmark' title='New in Whois: Applying the Principle of Least Surprise'>New in Whois: Applying the Principle of Least Surprise</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/10/ruby-whois-0-8-1/' rel='bookmark' title='Ruby Whois 0.8.1'>Ruby Whois 0.8.1</a></li>
<li><a href='http://www.simonecarletti.com/blog/2011/02/new-in-whois-improved-caching/' rel='bookmark' title='New in Whois: improved caching'>New in Whois: improved caching</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2010/01/new-in-whois-property-is-set/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New in Whois: Applying the Principle of Least Surprise</title>
		<link>http://www.simonecarletti.com/blog/2010/01/new-in-whois-principle-of-least-surprise/</link>
		<comments>http://www.simonecarletti.com/blog/2010/01/new-in-whois-principle-of-least-surprise/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 12:28:01 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Hosting / Domains]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubywhois]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=939</guid>
		<description><![CDATA[Changes to the Whois::Answer object API.]]></description>
			<content:encoded><![CDATA[<p>In the past weeks I&#8217;ve been working to improve the <a href="http://code.simonecarletti.com/whois">Ruby Whois Gem</a>. While most of the effort is actually focused on creating new WHOIS parsers for the existing registries which are more than 400, I also took the time to add some new features.</p>
<p>One important change is strictly focused on applying the <a href="http://en.wikipedia.org/wiki/Ruby_%28programming_language%29#Philosophy">principle of least surprise</a> in the <code>Whois::Answer</code> design. Prior the changes, calling a method on a <code>Whois::Answer</code> instance to read a property value might result in 3 different behaviors:</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># the property is supported, return the value<br />
a = Whois.query &quot;google.it&quot;<br />
a.created_on?<br />
# =&gt; Fri Dec 10 00:00:00 +0100 1999<br />
<br />
# the property is supported but blank, return the value<br />
a = Whois.query &quot;notregistered.it&quot;<br />
a.created_on?<br />
# =&gt; nil<br />
<br />
# the property is not supported, raise an exception<br />
a = Whois.query &quot;google.it&quot;<br />
a.domain_id?<br />
# =&gt; PropertyNotSupported</div></td></tr></tbody></table></div>
<p><span id="more-939"></span>Whether the parser supports a property depends on the WHOIS record. For instance, a <code>.name</code> WHOIS response doesn&#8217;t contain the domain expiration thus the property <code>expires_on</code> is not supported. Contrariwise, the <code>.it</code> WHOIS response contains that value thus you can safely call <code>expires_on</code> to get the property value.</p>
<p>How do you deal with supported/unsupported properties? With the old Whois version you would have to check whether a property is supported before actually calling the getter method.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># the property is supported, return the value<br />
a = Whois.query &quot;google.it&quot;<br />
if a.property_supported?(:domain_id)<br />
&nbsp; a.domain_id<br />
end</div></td></tr></tbody></table></div>
<p>That worked well but was&#8230; horrible. <a href="http://blog.stackoverflow.com/2010/01/eating-our-own-careers-dogfood/">Dogfooding</a> the library working on <a href="http://www.robodomain.com/">RoboDomain</a> I ended up with the conclusion this wasn&#8217;t the behavior an user would expect. For this reason, the new Whois version returns the value if the property is supported, <code>nil</code> otherwise regardless property status.</p>
<p><a href="http://github.com/weppos/whois/commit/d0ed5877d05cd9ccd288fbac52fd80ba65b943db">This change</a> only affects the answer object. If for some reason you need to know whether a property is supported, you can always use the <code>property_supported?</code> method or access the underlying parser implementation.</p>
<div class="codecolorer-container text default code-ruby" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a = Whois.query &quot;google.it&quot;<br />
<br />
a.domain_id<br />
# =&gt; nil<br />
<br />
a.supported?(:domain_id)<br />
# =&gt; false<br />
<br />
a.parser.domain_id<br />
# =&gt; PropertyNotSupported</div></td></tr></tbody></table></div>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2010/01/new-in-whois-property-is-set/' rel='bookmark' title='New in Whois: property is set?'>New in Whois: property is set?</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/10/ruby-whois-0-8-1/' rel='bookmark' title='Ruby Whois 0.8.1'>Ruby Whois 0.8.1</a></li>
<li><a href='http://www.simonecarletti.com/blog/2009/09/ruby-whois-0-8-0/' rel='bookmark' title='Ruby Whois 0.8.0'>Ruby Whois 0.8.0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2010/01/new-in-whois-principle-of-least-surprise/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

