Class | Gem::GemRunner |
In: |
lib/rubygems/gem_runner.rb
|
Parent: | Object |
Run an instance of the gem program.
Gem::GemRunner is only intended for internal use by RubyGems itself. It does not form any public API and may change at any time for any reason.
If you would like to duplicate functionality of `gem` commands, use the classes they call directly.
# File lib/rubygems/gem_runner.rb, line 22 22: def initialize(options={}) 23: @command_manager_class = options[:command_manager] || Gem::CommandManager 24: @config_file_class = options[:config_file] || Gem::ConfigFile 25: @doc_manager_class = options[:doc_manager] || Gem::DocManager 26: end
Run the gem command with the following arguments.
# File lib/rubygems/gem_runner.rb, line 31 31: def run(args) 32: start_time = Time.now 33: 34: if args.include?('--') 35: # We need to preserve the original ARGV to use for passing gem options 36: # to source gems. If there is a -- in the line, strip all options after 37: # it...its for the source building process. 38: build_args = args[args.index("--") + 1...args.length] 39: args = args[0...args.index("--")] 40: end 41: 42: Gem::Command.build_args = build_args if build_args 43: 44: do_configuration args 45: cmd = @command_manager_class.instance 46: 47: cmd.command_names.each do |command_name| 48: config_args = Gem.configuration[command_name] 49: config_args = case config_args 50: when String 51: config_args.split ' ' 52: else 53: Array(config_args) 54: end 55: Gem::Command.add_specific_extra_args command_name, config_args 56: end 57: 58: cmd.run Gem.configuration.args 59: end_time = Time.now 60: 61: if Gem.configuration.benchmark then 62: printf "\nExecution time: %0.2f seconds.\n", end_time - start_time 63: puts "Press Enter to finish" 64: STDIN.gets 65: end 66: end