From: Dmitry Borodaenko <angdraug@debian.org>
Date: Tue, 13 Sep 2011 17:54:28 +0300
Subject: update to deprecated-3.0.0

Update to use "deprecated" version 3.0.0 to get rid of "already
initialized constant Deprecate" warning.

rubygems defines its own Deprecate module in rubygems/deprecate.rb. This
causes a warning when deprecate 2.0.1 is required because it aliases the
Deprecated module to Deprecate. Version 3.0.0 no longer does this
aliasing and gets rid of the warning. Updating to 3.0.0 requires some
changes in how methods are deprecated, and how set_action is called.

Based on https://github.com/jinschoi/ruby-dbi/tree/deprecated-fixes
---
 build/Rakefile.dbi.rb      |    2 +-
 lib/dbi.rb                 |   27 +++++++++++----------------
 lib/dbi/columninfo.rb      |    4 ++--
 lib/dbi/utils/date.rb      |    3 ++-
 lib/dbi/utils/time.rb      |    3 ++-
 lib/dbi/utils/timestamp.rb |    4 +++-
 test/dbi/tc_date.rb        |    2 +-
 test/dbi/tc_time.rb        |    2 +-
 test/dbi/tc_timestamp.rb   |    2 +-
 9 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/build/Rakefile.dbi.rb b/build/Rakefile.dbi.rb
index 719de67..2d337f1 100644
--- a/build/Rakefile.dbi.rb
+++ b/build/Rakefile.dbi.rb
@@ -45,7 +45,7 @@ namespace :dbi do
     spec.files       = gem_files(code_files)
     spec.summary     = 'A vendor independent interface for accessing databases, similar to Perl\'s DBI'
     spec.description = 'A vendor independent interface for accessing databases, similar to Perl\'s DBI'
-    spec.add_dependency 'deprecated', '= 2.0.1'
+    spec.add_dependency 'deprecated', '= 3.0.0'
 
     build_package_tasks(spec, code_files)
 end
diff --git a/lib/dbi.rb b/lib/dbi.rb
index 9d0877f..3762204 100644
--- a/lib/dbi.rb
+++ b/lib/dbi.rb
@@ -63,24 +63,19 @@ class Class
     end
 end
 
-Deprecate.set_action(
-    proc do |call|
-        klass, meth = call.split(/[#.]/)
-        klass = klass.split(/::/).inject(Module) { |a,x| a.const_get(x) }
-
-        case klass
-        when DBI::Date, DBI::Time, DBI::Timestamp
-            warn "DBI::Date/Time/Timestamp are deprecated and will eventually be removed."
-        end
-
-        if klass.inherits_from?(DBI::ColumnInfo)
-            warn "ColumnInfo methods that do not match a component are deprecated and will eventually be removed"
-        end
+Deprecated.set_action() do |klass, meth, replacement|
+    case klass
+    when DBI::Date, DBI::Time, DBI::Timestamp
+        warn "DBI::Date/Time/Timestamp are deprecated and will eventually be removed."
+    end
 
-        warn "You may change the result of calling deprecated code via Deprecate.set_action; Trace follows:"
-        warn caller[2..-1].join("\n")
+    if klass.inherits_from?(DBI::ColumnInfo)
+        warn "ColumnInfo methods that do not match a component are deprecated and will eventually be removed"
     end
-)
+
+    warn "You may change the result of calling deprecated code via Deprecated.set_action; Trace follows:"
+    warn caller[2..-1].join("\n")
+end
 
 #++
 module DBI
diff --git a/lib/dbi/columninfo.rb b/lib/dbi/columninfo.rb
index cfff97b..e3baf02 100644
--- a/lib/dbi/columninfo.rb
+++ b/lib/dbi/columninfo.rb
@@ -17,7 +17,7 @@ module DBI
     # All of these forms have assignment forms as well.
     #
     class ColumnInfo < DelegateClass(Hash)
-
+        include Deprecated
         # Create a new ColumnInfo object.
         #
         # If no Hash is provided, one will be created for you. The hash will be
@@ -75,7 +75,7 @@ module DBI
         # Aliases - XXX soon to be deprecated
         def self.deprecated_alias(target, source) # :nodoc:
             define_method(target) { |*args| method_missing(source, *args) }
-            deprecate target 
+            deprecated target
         end
 
         deprecated_alias :is_nullable?, :nullable
diff --git a/lib/dbi/utils/date.rb b/lib/dbi/utils/date.rb
index cb93476..baf553f 100644
--- a/lib/dbi/utils/date.rb
+++ b/lib/dbi/utils/date.rb
@@ -5,6 +5,7 @@ module DBI
     # DEPRECATED: Please use a regular Date or DateTime object.
     #
     class Date
+        include Deprecated
         attr_accessor :year, :month, :day
 
         # Aliases
@@ -54,6 +55,6 @@ module DBI
 
         public
 
-        deprecate :initialize, :public
+        deprecated :initialize, :public
     end
 end
diff --git a/lib/dbi/utils/time.rb b/lib/dbi/utils/time.rb
index 18bd25d..bdf2681 100644
--- a/lib/dbi/utils/time.rb
+++ b/lib/dbi/utils/time.rb
@@ -4,6 +4,7 @@ module DBI
     #
     # DEPRECATED: Please use a regular Time or DateTime object.
    class Time
+      include Deprecated
       attr_accessor :hour, :minute, :second
 
       private
@@ -25,7 +26,7 @@ module DBI
 
       public
       
-      deprecate :initialize, :public
+      deprecated :initialize, :public
 
       alias :min :minute
       alias :min= :minute=
diff --git a/lib/dbi/utils/timestamp.rb b/lib/dbi/utils/timestamp.rb
index 6a6d355..1563bed 100644
--- a/lib/dbi/utils/timestamp.rb
+++ b/lib/dbi/utils/timestamp.rb
@@ -5,6 +5,8 @@ module DBI
     # DEPRECATED: Please use a regular DateTime object.
     #
    class Timestamp
+      include Deprecated
+
       attr_accessor :year, :month, :day
       attr_accessor :hour, :minute, :second
       attr_writer   :fraction
@@ -36,7 +38,7 @@ module DBI
 
       public
       
-      deprecate :initialize, :public
+      deprecated :initialize, :public
 
       # Returns true if +timestamp+ has a year, month, day, hour, minute,
       # second and fraction equal to the comparing object.
diff --git a/test/dbi/tc_date.rb b/test/dbi/tc_date.rb
index 8421c56..3306fac 100644
--- a/test/dbi/tc_date.rb
+++ b/test/dbi/tc_date.rb
@@ -13,7 +13,7 @@ require 'date'
 require 'dbi'
 require 'test/unit'
 
-Deprecate.set_action(proc { })
+Deprecated.set_action { }
 
 class TC_DBI_Date < Test::Unit::TestCase
    def setup
diff --git a/test/dbi/tc_time.rb b/test/dbi/tc_time.rb
index 514ff97..699b376 100644
--- a/test/dbi/tc_time.rb
+++ b/test/dbi/tc_time.rb
@@ -12,7 +12,7 @@ $LOAD_PATH.unshift("lib")
 require 'dbi'
 require 'test/unit'
 
-Deprecate.set_action(proc { })
+Deprecated.set_action { }
 
 class TC_DBI_Time < Test::Unit::TestCase
    def setup
diff --git a/test/dbi/tc_timestamp.rb b/test/dbi/tc_timestamp.rb
index bc418b3..38b55e2 100644
--- a/test/dbi/tc_timestamp.rb
+++ b/test/dbi/tc_timestamp.rb
@@ -14,7 +14,7 @@ require 'date'
 require 'dbi'
 require 'test/unit'
 
-Deprecate.set_action(proc { })
+Deprecated.set_action { }
 
 class TC_DBI_Date < Test::Unit::TestCase
    def setup
-- 
