Permalink
Browse files

Removed Deprecated compatibility layer to Whois 0.4.2

  • Loading branch information...
1 parent 75d3c8f commit 0a628258fe50f86cd923339dbc0861a15bdd0d45 @weppos committed Feb 6, 2010
Showing with 10 additions and 233 deletions.
  1. +3 −1 CHANGELOG.rdoc
  2. +6 −13 README.rdoc
  3. +1 −1 Rakefile
  4. +0 −1 lib/whois.rb
  5. +0 −185 lib/whois/whois.rb
  6. +0 −32 test/whois_test.rb
View
@@ -133,7 +133,9 @@
* CHANGED: Increased DEFAULT_TIMEOUT to 10 seconds
-* REMOVED: Deprecated #supported? method
+* REMOVED: Removed Deprecated #supported? method
+
+* REMOVED: Removed Deprecated compatibility layer to Whois 0.4.2
== Release 0.9.0
View
@@ -128,30 +128,23 @@ Off course, you can customize the timeout value setting a different value. If ti
== Acknowledgments
-First of all, I would like to express my most sincere thanks to Cyril Mougel, the author of the first Ruby Whois GEM that has been available since 2007. Cyril has been kind enough to yield me the privilege of using the RubyForge Whois project and the Whois package name to publish this library.
-To express all my gratitude, the Release 0.5.0 of the new Ruby Whois is 100% compatible with Cyril's Whois (as of release 0.4.2).
+First of all, I would like to express my most sincere thanks to Cyril Mougel, the author of the first Ruby Whois GEM that has been available since 2007. Cyril has been kind enough to yield me the privilege of using the RubyForge Whois project and the Whois package name to publish this library. To express all my gratitude, the release 0.5.0 and all sub sequential versions of the new Whois up to 0.9.x are 100% compatible with Cyril's Whois.
-Whois is largely inspired by other notable Whois projects, most of all the Debian Whois library written and mainained by Marco D'Itri. Other good ideas and design decisions come from the PERL Net::DRI package.
+Whois is largely inspired by other notable Whois projects, most of all the Debian Whois library written and maintained by Marco D'Itri. Other good ideas and design decisions come from the PERL Net::DRI package.
I would lie if I say I'm completely unaware of the other Ruby Whois projects. Before starting this Ruby Whois library I deeply investigated the available resources and, despite none of them was a good candidate for a refactoring, some of them expose a really cool API.
They didn't directly influence this library or any design decision, but they have been a really interesting code-reading.
-The parser architecture (yet to come) has been inspired by the PHPWhois[http://phpwhois.sourceforge.net/] project. The authors puts lot of effort to create whois-specific parsers normalizing the different responses in a single tree-based structure. So far, this is the only one opensource project that offers such this feature in all the programming language ecosystem.
+The parser architecture has been inspired by the PHPWhois[http://phpwhois.sourceforge.net/] project. The authors puts lot of effort to create whois-specific parsers normalizing the different responses in a single tree-based structure. So far, this is the only one opensource project that offers such this feature in all the programming language ecosystem.
Despite I spent weeks reading source code from the available whois libraries, Ruby Whois has been built from scratch trying to focus on long-term maintainability and flexibility and cannot be considered a Ruby port of any of other existing Whois libraries.
-== Notice for users of Whois 0.4 (or previous version)
+== Note for Whois 0.4 users
As of release 0.5.0, the Whois GEM has been completely rewritten. As I explained in the Acknowledgment section, Cyril Mougel (the author of the original Whois package) yield me the privilege to use the Whois RubyForge project for my new Whois client.
-My Whois client provides all the features offered by Cyril's library, with some nice additions like the ability to get top level domain query information. All existing users won't be affected by this change since the new Whois library comes with a compatibility adapter that translates all the requests from the deprecated interface to the new one.
-
-The adapter will be removed in a future version so make sure to check your application for deprecation warnings and fix them before upgrading to a newest release that doesn't belong to the 0.5.x series.
-
-Ruby Whois 0.4.2 is released under the MIT license.
-
-Copyright (c) 2007 by Cyril Mougel (cyril.mougel@gmail.com)
+All versions between Whois 0.5.0 and 0.9.x include a compatibility adapter and the corresponding deprecation warnings to help you migrate to the new API. Starting from Whois 1.0.0, the library is no longer backward compatible with Cyril's Whois.
== Author
@@ -178,7 +171,7 @@ Bug reports and Feature suggestions {are welcomed}[http://github.com/weppos/whoi
* {Homepage}[http://ruby-whois.org]
* {GitHub Repository}[http://github.com/weppos/whois]
-* {API Documentation}[http://whois.rubyforge.org/]
+* {API Documentation}[http://whois.rubyforge.org]
* {Discussion Group}[http://groups.google.com/group/ruby-whois]
View
@@ -1,9 +1,9 @@
$:.unshift(File.dirname(__FILE__) + "/lib")
+require 'whois'
require 'rubygems'
require 'rake'
require 'echoe'
-require 'whois'
require 'rake/rdoctask'
require 'hanna/rdoctask'
View
@@ -19,7 +19,6 @@
require 'whois/client'
require 'whois/server'
require 'whois/answer'
-require 'whois/whois'
module Whois
View
@@ -1,185 +0,0 @@
-#
-# = Ruby Whois
-#
-# An intelligent pure Ruby WHOIS client and parser.
-#
-#
-# Category:: Net
-# Package:: Whois
-# Author:: Simone Carletti <weppos@weppos.net>
-# License:: MIT License
-#
-#--
-#
-#++
-
-
-require 'resolv'
-
-
-module Whois
-
- class WhoisException < Exception # :nodoc
- def initialize(message)
- ::Whois.deprecate "WhoisException is deprecated as of 0.5.0 and will be removed in a future release along with Whois::Whois class."
- super
- end
- end
-
- class WhoisExceptionError < WhoisException # :nodoc
- def initialize(message)
- super("Report a bug with error #{message} to http://rubyforge.org/projects/whois/")
- end
- end
-
-
- # This class exists to ensure this GEM is compatible
- # with the original Ruby Whois release 0.4.2
- # developed by Cyril Mougel.
- #
- # It exposes the same Ruby WHOIS 0.4.2 interface
- # and echoes deprecation warning for all those features
- # that are going to be removed in a next version.
- #
- # Here's a standard Ruby WHOIS 0.4.2 example usage.
- #
- # w = Whois::Whois.new '72.14.207.99'
- # w.search_whois
- #
- # # All return of request
- # w.all
- #
- # # The ip return with object IPAddr
- # w.ip
- #
- # # The server where the request has send
- # w.server
- #
- # # The host of this IPv4
- # w.host
- #
- # WARNING: The Whois::Whois class will be removed in a future release.
- # You should update your code to the new interface offered by <tt>Whois::Client</tt>.
- # If you want to save keystrokes, you can even use the handy <tt>Whois.query</tt> method.
- #
- # Whois.query '72.14.207.99'
- # # => whois answer
- #
- class Whois # :nodoc
-
- attr_reader :ip
- attr_reader :host
- attr_accessor :host_search
-
- def initialize(request, host_search = false)
- ::Whois.deprecate "Whois::Whois class is deprecated as of 0.5.0 and will be removed in a future release. Use Whois.query('#{request.to_s}') instead."
-
- @host_search = host_search
- @host = nil
- @client = Client.new
-
- @ip = if request.instance_of? IPAddr
- request
- elsif Resolv::IPv4::Regex =~ request
- IPAddr.new(request)
- elsif Resolv::IPv6::Regex =~ request
- IPAddr.new(request)
- else
- begin
- @ip = IPAddr.new(Resolv.getaddress(request))
- @host = request
- rescue Resolv::ResolvError
- raise WhoisException.new("host #{request} has no DNS result")
- end
- end
-
- @host || search_host
- rescue ServerNotFound => e
- raise WhoisException.new("no server found for #{request}")
- end
-
- def search_whois
- @all = @client.query(@ip.to_s)
- end
-
- def search_host
- ::Whois.deprecate "#search_host will be removed in a future release. Use Resolv.getname(#{@ip.to_s}) in your application to get the same feature."
- @host = if @host_search
- Resolv.getname(@ip.to_s)
- else
- nil
- end
- rescue Resolv::ResolvError
- @host = nil
- end
-
- def all
- ::Whois.deprecate "#all will be removed in a future release. You are responsible for storing the whois answer in a custom variable."
- @all
- end
-
- def server
- ::Whois.deprecate "#server will be removed in a future release. No replacement has been planned for the immediate future."
- if server = @client.instance_variable_get(:"@server")
- Server::Server.lookup(server.host)
- end
- end
-
- end
-
- class Server # :nodoc
-
- class Server # :nodoc
- @@definitions = [
- ['whois.afrinic.net' , 'Afrinic' ],
- ['whois.ripe.net' , 'Ripe' ],
- ['whois.apnic.net' , 'Apnic' ],
- ['whois.arin.net' , 'Arin' ],
- ['whois.lacnic.net' , 'Lacnic' ],
- ['whois.nic.or.kr' , 'Nicor' ],
- ['whois.nic.ad.jp' , 'Nicad' ],
- ['whois.nic.br' , 'Nicbr' ],
- [nil , 'Teredo' ],
- [nil , 'Ipv6ToIpv4' ],
- ['whois.v6nic.net' , 'V6nic' ],
- ['whois.twnic.net' , 'Twnic' ],
- ['whois.6bone.net' , 'Ipv6Bone' ],
- ['rwhois.gin.ntt.net' , 'Ginntt' ],
- ]
-
- attr_reader :server
-
- def initialize(server)
- @server = server
- end
-
- def self.lookup(host)
- @@definitions.each do |server, klassname|
- if !server.nil? && server == host
- klass = ::Whois::Server.const_get(klassname)
- return klass.new(server)
- end
- end
- nil
- end
- end
-
- Afrinic = Class.new(Server)
- Ripe = Class.new(Server)
- Apnic = Class.new(Server)
- Arin = Class.new(Server)
- Lacnic = Class.new(Server)
- Nicor = Class.new(Server)
- Nicad = Class.new(Server)
- Nicbr = Class.new(Server)
- Teredo = Class.new(Server)
- Ipv6ToIpv4 = Class.new(Server)
- V6nic = Class.new(Server)
- Twnic = Class.new(Server)
- Verio = Class.new(Server)
- Ipv6Bone = Class.new(Server)
- Ginntt = Class.new(Server)
-
- end
-
-end
View
@@ -1,32 +0,0 @@
-require 'test_helper'
-
-class WhoisTest < Test::Unit::TestCase
-
- def setup
- @server = Whois::Server.factory(:tld, ".it", "whois.nic.it")
- @answer = Whois::Answer.new("", @server)
- end
-
- def test_query
- Whois::Client.any_instance.expects(:query).with("foo.com")
- Whois.query("foo.com")
- end
-
- def test_whois
- Whois::Client.any_instance.expects(:query).with("foo.com")
- Whois.whois("foo.com")
- end
-
- def test_available_question
- @answer.expects(:available?).returns(true)
- Whois::Client.any_instance.expects(:query).with("foo.com").returns(@answer)
- assert Whois.available?("foo.com")
- end
-
- def test_registered_question
- @answer.expects(:registered?).returns(true)
- Whois::Client.any_instance.expects(:query).with("foo.com").returns(@answer)
- assert Whois.registered?("foo.com")
- end
-
-end

0 comments on commit 0a62825

Please sign in to comment.