I've released another library just in time for the new year. The new library is called Domainatrix and she's used for parsing domain names, canonicalizing URLs, and a few other things. It uses the list of domain names from the Public Suffix List to know what constitutes a subdomain, domain, and public suffix.
Usage couldn't be simpler.
url = Domainatrix.parse("http://www.pauldix.net")
url.public_suffix # => "net"
url.domain # => "pauldix"
url.canonical # => "net.pauldix"
url = Domainatrix.parse("http://foo.bar.pauldix.co.uk/asdf.html?q=arg")
url.public_suffix # => "co.uk"
url.domain # => "pauldix"
url.subdomain # => "foo.bar"
url.path # => "/asdf.html?q=arg"
url.canonical # => "uk.co.pauldix.bar.foo/asdf.html?q=arg"
It's simple, but I think quite useful. Enjoy!