diff options
author | bronzdoc <lsagastume1990@gmail.com> | 2020-04-19 08:18:29 -0600 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-08 07:38:50 +0900 |
commit | 0e85a39dc70328641c3155f66568feedbe6dd15f (patch) | |
tree | ceca5a76908cfc7c25b0b10e70aa2273f5070556 /lib | |
parent | 7db538a7c92bcbcccb97d2ffcf505bee4d85e7d3 (diff) | |
download | ruby-0e85a39dc70328641c3155f66568feedbe6dd15f.tar.gz |
[rubygems/rubygems] Restore and deprecate old deprecate method
https://github.com/rubygems/rubygems/commit/024267fa60
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/deprecate.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 5f2140c0a3..31981b15b3 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -49,6 +49,31 @@ module Gem::Deprecate # 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 + # year/month that it is planned to go away. + + def deprecate(name, repl, year, month) + 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 #{repl} instead", + ". It will be removed on or after %4d-%02d-01." % [year, month], + "\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}", + ] + warn "Gem::Deprecate#deprecate has been deprecated with no replacement and it will be removed in Rubygems 4.\n" unless Gem::Deprecate.skip + 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 + # telling the user of +repl+ (unless +repl+ is :none) and the # Rubygems version that it is planned to go away. def rubygems_deprecate(name, replacement=:none) |