deprecated 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/deprecated.rb +17 -15
- metadata +40 -32
data/lib/deprecated.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
#
|
2
|
-
#
|
2
|
+
# Deprecated - handle deprecating and executing deprecated code
|
3
3
|
#
|
4
|
-
# Version:: 2.0.
|
4
|
+
# Version:: 2.0.1
|
5
5
|
# Author:: Erik Hollensbe
|
6
6
|
# License:: BSD
|
7
7
|
# Copyright:: Copyright (c) 2006 Erik Hollensbe
|
8
8
|
# Contact:: erik@hollensbe.org
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# Deprecated is intended to ease the programmer's control over
|
11
11
|
# deprecating and handling deprecated code.
|
12
12
|
#
|
13
13
|
# Usage is simple:
|
14
14
|
#
|
15
15
|
# # require 'rubygems' if need be
|
16
|
-
# require '
|
16
|
+
# require 'deprecated'
|
17
17
|
#
|
18
18
|
# class Foo
|
19
19
|
# private
|
@@ -26,7 +26,7 @@
|
|
26
26
|
# deprecate :monkey, :private
|
27
27
|
# end
|
28
28
|
#
|
29
|
-
# The '
|
29
|
+
# The 'deprecated' call is injected into the 'Module' class at
|
30
30
|
# require-time. This allows all classes that are newly-created to
|
31
31
|
# access the 'deprecate' functionality. The deprecate definition must
|
32
32
|
# follow the method definition. You may only define one deprecated
|
@@ -46,7 +46,7 @@
|
|
46
46
|
# Note: It's highly recommended that you make your original methods
|
47
47
|
# private so that they cannot be accessed by outside code.
|
48
48
|
#
|
49
|
-
#
|
49
|
+
# Deprecated.set_action can change the default action (which is a
|
50
50
|
# warning printed to stderr) if you prefer. This is ideal for code
|
51
51
|
# sweeps where deprecated calls have to be removed. Please see the
|
52
52
|
# documentation for this method to get an idea of the options that are
|
@@ -79,7 +79,7 @@
|
|
79
79
|
#
|
80
80
|
#++
|
81
81
|
|
82
|
-
module
|
82
|
+
module Deprecated
|
83
83
|
|
84
84
|
#
|
85
85
|
# set_action defines the action that will be taken when code marked
|
@@ -106,10 +106,10 @@ module Deprecate
|
|
106
106
|
# Ex:
|
107
107
|
#
|
108
108
|
# # throws with the error message saying: "FIXME: Class#meth"
|
109
|
-
#
|
109
|
+
# Deprecated.set_action(:throw, "FIXME: %s")
|
110
110
|
#
|
111
111
|
# # emails your boss everytime you run deprecated code
|
112
|
-
#
|
112
|
+
# Deprecated.set_action proc do |msg|
|
113
113
|
# f = IO.popen('mail boss@company -s "Joe still hasn't fixed %s"' % msg, 'w')
|
114
114
|
# f.puts("Sorry, I still haven't fixed %s, please stop making me go to meetings.\n" % msg)
|
115
115
|
# f.close
|
@@ -118,11 +118,11 @@ module Deprecate
|
|
118
118
|
|
119
119
|
@@action = nil
|
120
120
|
|
121
|
-
def
|
121
|
+
def Deprecated.action
|
122
122
|
return @@action
|
123
123
|
end
|
124
124
|
|
125
|
-
def
|
125
|
+
def Deprecated.set_action(action, message="%s is deprecated.")
|
126
126
|
if action.kind_of? Proc
|
127
127
|
@@action = action
|
128
128
|
return
|
@@ -147,10 +147,10 @@ module Deprecate
|
|
147
147
|
end
|
148
148
|
|
149
149
|
#
|
150
|
-
# This is the class of the errors that the '
|
150
|
+
# This is the class of the errors that the 'Deprecated' module will
|
151
151
|
# throw if the action type is set to ':throw'.
|
152
152
|
#
|
153
|
-
# See
|
153
|
+
# See Deprecated.set_action for more information.
|
154
154
|
#
|
155
155
|
class DeprecatedError < Exception
|
156
156
|
attr_reader :message
|
@@ -176,7 +176,7 @@ Module.send(:define_method, :deprecate,
|
|
176
176
|
old_method = self.instance_method(sym)
|
177
177
|
|
178
178
|
define_method(sym) do |*sendparams|
|
179
|
-
|
179
|
+
Deprecated.action.call(self.class.to_s + '#' + sym.to_s)
|
180
180
|
new_method = self.class.instance_method(sym)
|
181
181
|
retval = old_method.bind(self).call(*sendparams)
|
182
182
|
new_method.bind(self)
|
@@ -194,4 +194,6 @@ Module.send(:define_method, :deprecate,
|
|
194
194
|
|
195
195
|
end)
|
196
196
|
|
197
|
-
|
197
|
+
Deprecated.set_action(:warn)
|
198
|
+
|
199
|
+
Deprecate = Deprecated
|
metadata
CHANGED
@@ -1,46 +1,54 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.11
|
3
|
-
specification_version: 1
|
4
2
|
name: deprecated
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 2.0.
|
7
|
-
date: 2006-05-17 00:00:00 -07:00
|
8
|
-
summary: An easy way to handle deprecating and conditionally running deprecated code
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: erik@hollensbe.org
|
12
|
-
homepage:
|
13
|
-
rubyforge_project: deprecated
|
14
|
-
description:
|
15
|
-
autorequire: deprecated
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 2.0.1
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
6
|
authors:
|
29
7
|
- Erik Hollensbe
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
test_files:
|
34
|
-
- test/deprecated.rb
|
35
|
-
rdoc_options: []
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
36
11
|
|
37
|
-
|
12
|
+
date: 2008-07-26 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
38
15
|
|
16
|
+
description:
|
17
|
+
email: erik@hollensbe.org
|
39
18
|
executables: []
|
40
19
|
|
41
20
|
extensions: []
|
42
21
|
|
43
|
-
|
22
|
+
extra_rdoc_files: []
|
44
23
|
|
45
|
-
|
24
|
+
files:
|
25
|
+
- lib/deprecated.rb
|
26
|
+
- test/deprecated.rb
|
27
|
+
has_rdoc: true
|
28
|
+
homepage:
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
46
31
|
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: "0"
|
39
|
+
version:
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
requirements: []
|
47
|
+
|
48
|
+
rubyforge_project: deprecated
|
49
|
+
rubygems_version: 1.1.1
|
50
|
+
signing_key:
|
51
|
+
specification_version: 2
|
52
|
+
summary: An easy way to handle deprecating and conditionally running deprecated code
|
53
|
+
test_files:
|
54
|
+
- test/deprecated.rb
|