summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbronzdoc <lsagastume1990@gmail.com>2020-03-30 18:40:27 -0600
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 07:38:50 +0900
commit80163db93662aa112d011f8fff8c17a1370538b4 (patch)
tree4f17fca4f245ffd5af0e3f1c709c7831d9e598f6
parentff37dd7e9e80e7b8882f24b0e56c69674fb7bdb0 (diff)
[rubygems/rubygems] Add next_rubygems_major_version method
https://github.com/rubygems/rubygems/commit/db5bb65baf
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3087
-rw-r--r--lib/rubygems/deprecate.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
index 57501e1a2b..815d9dcdc1 100644
--- a/lib/rubygems/deprecate.rb
+++ b/lib/rubygems/deprecate.rb
@@ -41,6 +41,10 @@ module Gem::Deprecate
Gem::Deprecate.skip = original
end
+ def self.next_rubygems_major_version # :nodoc:
+ Gem::Version.new(Gem.rubygems_version.segments.first).bump
+ end
+
##
# Simple deprecation method that deprecates +name+ by wrapping it up
# in a dummy method. It warns on each call to the dummy method
@@ -48,9 +52,6 @@ module Gem::Deprecate
# Rubygems version that it is planned to go away.
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
old = "_deprecated_#{name}"
alias_method old, name
@@ -59,7 +60,7 @@ module Gem::Deprecate
target = klass ? "#{self}." : "#{self.class}#"
msg = [ "NOTE: #{target}#{name} is deprecated",
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
- ". It will be removed in Rubygems #{next_rubygems_major_version}",
+ ". It will be removed in Rubygems #{Gem::Deprecate.next_rubygems_major_version}",
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
]
warn "#{msg.join}." unless Gem::Deprecate.skip
@@ -70,9 +71,6 @@ module Gem::Deprecate
# Deprecation method to deprecate Rubygems commands
def deprecate_command
- current_major = Gem::Version.new(Gem.rubygems_version.segments.first)
- next_rubygems_major_version = current_major.bump
-
class_eval do
define_method "deprecated?" do
true
@@ -80,7 +78,7 @@ module Gem::Deprecate
define_method "deprecation_warning" do
msg = [ "#{self.command} command is deprecated",
- ". It will be removed in Rubygems #{next_rubygems_major_version}.\n",
+ ". It will be removed in Rubygems #{Gem::Deprecate.next_rubygems_major_version}.\n",
]
alert_warning "#{msg.join}" unless Gem::Deprecate.skip