[rubygems/rubygems] Simplify command loading

https://github.com/rubygems/rubygems/commit/95f60f0e60
This commit is contained in:
David Rodríguez 2024-09-26 15:52:04 +02:00 committed by Hiroshi SHIBATA
parent 3d1eb62bf3
commit 02d50d9cb1
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -230,18 +230,11 @@ class Gem::CommandManager
def load_and_instantiate(command_name) def load_and_instantiate(command_name)
command_name = command_name.to_s command_name = command_name.to_s
const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase } << "Command" const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase } << "Command"
load_error = nil
begin
begin begin
require "rubygems/commands/#{command_name}_command" require "rubygems/commands/#{command_name}_command"
rescue LoadError => e
load_error = e
end
Gem::Commands.const_get(const_name).new Gem::Commands.const_get(const_name).new
rescue StandardError => e rescue StandardError, LoadError => e
e = load_error if load_error
alert_error clean_text("Loading command: #{command_name} (#{e.class})\n\t#{e}") alert_error clean_text("Loading command: #{command_name} (#{e.class})\n\t#{e}")
ui.backtrace e ui.backtrace e
end end