mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Make the deprecate method recieve a Rubygems version instead of a date
https://github.com/rubygems/rubygems/commit/f0e098a1b7
This commit is contained in:
parent
1fe2b7f41c
commit
2f7865bb6e
Notes:
git
2020-05-08 07:39:30 +09:00
1 changed files with 24 additions and 0 deletions
|
@ -41,6 +41,30 @@ module Gem::Deprecate
|
|||
Gem::Deprecate.skip = original
|
||||
end
|
||||
|
||||
##
|
||||
# Simple deprecation method that deprecates +name+ by wrapping it up
|
||||
# in a dummy method. It warns on each call to the dummy method
|
||||
# telling the user of +repl+ (unless +repl+ is :none) and the
|
||||
#Rubygems version that it is planned to go away.
|
||||
|
||||
def deprecate(name:, replacement:, rubygems_version:)
|
||||
class_eval do
|
||||
old = "_deprecated_#{name}"
|
||||
alias_method old, name
|
||||
define_method name do |*args, &block|
|
||||
klass = self.kind_of? Module
|
||||
target = klass ? "#{self}." : "#{self.class}#"
|
||||
msg = [ "NOTE: #{target}#{name} is deprecated",
|
||||
repl == :none ? " with no replacement" : "; use #{replacement} instead",
|
||||
". It will be removed in Rubygems #{rubygems_version}",
|
||||
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
|
||||
]
|
||||
warn "#{msg.join}." unless Gem::Deprecate.skip
|
||||
send old, *args, &block
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Simple deprecation method that deprecates +name+ by wrapping it up
|
||||
# in a dummy method. It warns on each call to the dummy method
|
||||
|
|
Loading…
Reference in a new issue