Package: ruby-dbi / 0.4.5-1

0004-update-to-deprecated-3.0.0.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
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
--