End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Gem::Deprecate.rubygems_deprecate
rubygems_deprecate(name, replacement=:none)
lib/rubygems/deprecate.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/rubygems/deprecate.rb, line 126
def rubygems_deprecate(name, replacement=:none)
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",
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
". 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
send old, *args, &block
end
ruby2_keywords name if respond_to?(:ruby2_keywords, true)
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 Rubygems version that it is planned to go away.
See also
#rubygems_deprecate
.rubygems_deprecate_command
.skip_during
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0