mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Use the next major version as default for deprecations
b679ab27af
This commit is contained in:
parent
feb2974000
commit
42c91de9ce
Notes:
git
2020-05-08 07:39:29 +09:00
1 changed files with 9 additions and 4 deletions
|
@ -47,7 +47,10 @@ module Gem::Deprecate
|
||||||
# telling the user of +repl+ (unless +repl+ is :none) and the
|
# telling the user of +repl+ (unless +repl+ is :none) and the
|
||||||
# Rubygems version that it is planned to go away.
|
# Rubygems version that it is planned to go away.
|
||||||
|
|
||||||
def deprecate(name:, replacement:)
|
def deprecate(name, replacement=:none)
|
||||||
|
current_major = Gem::Version.new(Gem.rubygems_version.segments.first)
|
||||||
|
next_rubygems_major_version = current_major.bump
|
||||||
|
|
||||||
class_eval do
|
class_eval do
|
||||||
old = "_deprecated_#{name}"
|
old = "_deprecated_#{name}"
|
||||||
alias_method old, name
|
alias_method old, name
|
||||||
|
@ -55,8 +58,8 @@ module Gem::Deprecate
|
||||||
klass = self.kind_of? Module
|
klass = self.kind_of? Module
|
||||||
target = klass ? "#{self}." : "#{self.class}#"
|
target = klass ? "#{self}." : "#{self.class}#"
|
||||||
msg = [ "NOTE: #{target}#{name} is deprecated",
|
msg = [ "NOTE: #{target}#{name} is deprecated",
|
||||||
repl == :none ? " with no replacement" : "; use #{replacement} instead",
|
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
|
||||||
". It will be removed in Rubygems #{rubygems_version}",
|
". It will be removed in Rubygems #{next_rubygems_major_version}",
|
||||||
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
|
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
|
||||||
]
|
]
|
||||||
warn "#{msg.join}." unless Gem::Deprecate.skip
|
warn "#{msg.join}." unless Gem::Deprecate.skip
|
||||||
|
@ -67,7 +70,9 @@ module Gem::Deprecate
|
||||||
|
|
||||||
# Deprecation method to deprecate Rubygems commands
|
# Deprecation method to deprecate Rubygems commands
|
||||||
def deprecate_command
|
def deprecate_command
|
||||||
next_rubygems_major_version = Gem.rubygems_version + 1
|
current_major = Gem::Version.new(Gem.rubygems_version.segments.first)
|
||||||
|
next_rubygems_major_version = current_major.bump
|
||||||
|
|
||||||
class_eval do
|
class_eval do
|
||||||
define_method "deprecated?" do
|
define_method "deprecated?" do
|
||||||
true
|
true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue