mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[rubygems/rubygems] Allow to use Gem::Deprecate#rubygems_deprecate and rubygems_deprecate_command without rubygems.rb
4925403686
This commit is contained in:
parent
052b38a5d9
commit
4d26ccd2af
1 changed files with 4 additions and 2 deletions
|
@ -126,13 +126,14 @@ module Gem
|
||||||
# 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 rubygems_deprecate(name, replacement=:none, version=Gem::Deprecate.next_rubygems_major_version)
|
def rubygems_deprecate(name, replacement=:none, version=nil)
|
||||||
class_eval do
|
class_eval do
|
||||||
old = "_deprecated_#{name}"
|
old = "_deprecated_#{name}"
|
||||||
alias_method old, name
|
alias_method old, name
|
||||||
define_method name do |*args, &block|
|
define_method name do |*args, &block|
|
||||||
klass = is_a? Module
|
klass = is_a? Module
|
||||||
target = klass ? "#{self}." : "#{self.class}#"
|
target = klass ? "#{self}." : "#{self.class}#"
|
||||||
|
version ||= Gem::Deprecate.next_rubygems_major_version
|
||||||
msg = [
|
msg = [
|
||||||
"NOTE: #{target}#{name} is deprecated",
|
"NOTE: #{target}#{name} is deprecated",
|
||||||
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
|
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
|
||||||
|
@ -147,13 +148,14 @@ module Gem
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deprecation method to deprecate Rubygems commands
|
# Deprecation method to deprecate Rubygems commands
|
||||||
def rubygems_deprecate_command(version = Gem::Deprecate.next_rubygems_major_version)
|
def rubygems_deprecate_command(version = nil)
|
||||||
class_eval do
|
class_eval do
|
||||||
define_method "deprecated?" do
|
define_method "deprecated?" do
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
define_method "deprecation_warning" do
|
define_method "deprecation_warning" do
|
||||||
|
version ||= Gem::Deprecate.next_rubygems_major_version
|
||||||
msg = [
|
msg = [
|
||||||
"#{command} command is deprecated",
|
"#{command} command is deprecated",
|
||||||
". It will be removed in Rubygems #{version}.\n",
|
". It will be removed in Rubygems #{version}.\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue