Skip to content

Commit 4d26ccd

Browse files
committed
[rubygems/rubygems] Allow to use Gem::Deprecate#rubygems_deprecate and rubygems_deprecate_command without rubygems.rb
rubygems/rubygems@4925403686
1 parent 052b38a commit 4d26ccd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/rubygems/deprecate.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ def deprecate(name, repl, year, month)
126126
# telling the user of +repl+ (unless +repl+ is :none) and the
127127
# Rubygems version that it is planned to go away.
128128

129-
def rubygems_deprecate(name, replacement=:none, version=Gem::Deprecate.next_rubygems_major_version)
129+
def rubygems_deprecate(name, replacement=:none, version=nil)
130130
class_eval do
131131
old = "_deprecated_#{name}"
132132
alias_method old, name
133133
define_method name do |*args, &block|
134134
klass = is_a? Module
135135
target = klass ? "#{self}." : "#{self.class}#"
136+
version ||= Gem::Deprecate.next_rubygems_major_version
136137
msg = [
137138
"NOTE: #{target}#{name} is deprecated",
138139
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
@@ -147,13 +148,14 @@ def rubygems_deprecate(name, replacement=:none, version=Gem::Deprecate.next_ruby
147148
end
148149

149150
# Deprecation method to deprecate Rubygems commands
150-
def rubygems_deprecate_command(version = Gem::Deprecate.next_rubygems_major_version)
151+
def rubygems_deprecate_command(version = nil)
151152
class_eval do
152153
define_method "deprecated?" do
153154
true
154155
end
155156

156157
define_method "deprecation_warning" do
158+
version ||= Gem::Deprecate.next_rubygems_major_version
157159
msg = [
158160
"#{command} command is deprecated",
159161
". It will be removed in Rubygems #{version}.\n",

0 commit comments

Comments
 (0)