14
# extend Gem::Deprecate
15
15
# deprecate :instance_method, "X.z", 2011, 4
18
# extend Gem::Deprecate
19
19
# deprecate :klass_method, :none, 2011, 4
25
def self.skip # :nodoc:
29
def self.skip= v # :nodoc:
34
# Temporarily turn off warnings. Intended for tests only.
37
Deprecate.skip, original = true, Deprecate.skip
40
Deprecate.skip = original
44
# Simple deprecation method that deprecates +name+ by wrapping it up
45
# in a dummy method. It warns on each call to the dummy method
46
# telling the user of +repl+ (unless +repl+ is :none) and the
47
# year/month that it is planned to go away.
49
def deprecate name, repl, year, month
51
old = "_deprecated_#{name}"
52
alias_method old, name
53
define_method name do |*args, &block| # TODO: really works on 1.8.7?
54
klass = self.kind_of? Module
55
target = klass ? "#{self}." : "#{self.class}#"
56
msg = [ "NOTE: #{target}#{name} is deprecated",
57
repl == :none ? " with no replacement" : ", use #{repl}",
58
". It will be removed on or after %4d-%02d-01." % [year, month],
59
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
61
warn "#{msg.join}." unless Deprecate.skip
62
send old, *args, &block
67
module_function :deprecate, :skip_during
26
def self.skip # :nodoc:
30
def self.skip= v # :nodoc:
35
# Temporarily turn off warnings. Intended for tests only.
38
Gem::Deprecate.skip, original = true, Gem::Deprecate.skip
41
Gem::Deprecate.skip = original
45
# Simple deprecation method that deprecates +name+ by wrapping it up
46
# in a dummy method. It warns on each call to the dummy method
47
# telling the user of +repl+ (unless +repl+ is :none) and the
48
# year/month that it is planned to go away.
50
def deprecate name, repl, year, month
52
old = "_deprecated_#{name}"
53
alias_method old, name
54
define_method name do |*args, &block| # TODO: really works on 1.8.7?
55
klass = self.kind_of? Module
56
target = klass ? "#{self}." : "#{self.class}#"
57
msg = [ "NOTE: #{target}#{name} is deprecated",
58
repl == :none ? " with no replacement" : ", use #{repl}",
59
". It will be removed on or after %4d-%02d-01." % [year, month],
60
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
62
warn "#{msg.join}." unless Gem::Deprecate.skip
63
send old, *args, &block
68
module_function :deprecate, :skip_during