1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rubygems/command_manager.rb (Gem#load_and_instantiate):

rescue only NameError from const_get.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-12-30 08:49:48 +00:00
parent 9004431714
commit 270ece8441
2 changed files with 8 additions and 4 deletions

View file

@ -1,4 +1,7 @@
Wed Dec 30 17:45:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Dec 30 17:49:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rubygems/command_manager.rb (Gem#load_and_instantiate):
rescue only NameError from const_get.
* lib/rubygems/source_index.rb (Gem#load_specification): don't use * lib/rubygems/source_index.rb (Gem#load_specification): don't use
RUBY_VERSION to branch. RUBY_VERSION to branch.

View file

@ -154,11 +154,12 @@ 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"
commands = Gem::Commands
retried = false retried = false
begin begin
const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase } commands.const_get(const_name)
Gem::Commands.const_get("#{const_name}Command").new
rescue NameError rescue NameError
if retried then if retried then
raise raise
@ -167,7 +168,7 @@ class Gem::CommandManager
require "rubygems/commands/#{command_name}_command" require "rubygems/commands/#{command_name}_command"
retry retry
end end
end end.new
end end
end end