ruby-changes:61064
From: bronzdoc <ko1@a...>
Date: Fri, 8 May 2020 07:39:32 +0900 (JST)
Subject: [ruby-changes:61064] 2f7865bb6e (master): [rubygems/rubygems] Make the deprecate method recieve a Rubygems version instead of a date
https://git.ruby-lang.org/ruby.git/commit/?id=2f7865bb6e From 2f7865bb6e9eaadb86f159c220478adc73883a90 Mon Sep 17 00:00:00 2001 From: bronzdoc <lsagastume1990@g...> Date: Sun, 22 Mar 2020 18:34:19 -0600 Subject: [rubygems/rubygems] Make the deprecate method recieve a Rubygems version instead of a date https://github.com/rubygems/rubygems/commit/f0e098a1b7 diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 19c0aa0..3504dbe 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -45,6 +45,30 @@ module Gem::Deprecate https://github.com/ruby/ruby/blob/trunk/lib/rubygems/deprecate.rb#L45 # 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 + # 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) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/