ruby-changes:61068
From: bronzdoc <ko1@a...>
Date: Fri, 8 May 2020 07:39:38 +0900 (JST)
Subject: [ruby-changes:61068] 80163db936 (master): [rubygems/rubygems] Add next_rubygems_major_version method
https://git.ruby-lang.org/ruby.git/commit/?id=80163db936 From 80163db93662aa112d011f8fff8c17a1370538b4 Mon Sep 17 00:00:00 2001 From: bronzdoc <lsagastume1990@g...> Date: Mon, 30 Mar 2020 18:40:27 -0600 Subject: [rubygems/rubygems] Add next_rubygems_major_version method https://github.com/rubygems/rubygems/commit/db5bb65baf diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 57501e1..815d9dc 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -41,6 +41,10 @@ module Gem::Deprecate https://github.com/ruby/ruby/blob/trunk/lib/rubygems/deprecate.rb#L41 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/deprecate.rb#L52 # 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/deprecate.rb#L60 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/deprecate.rb#L71 # 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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/deprecate.rb#L78 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/