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 28 28: def initialize(options={}) 29: # TODO: nuke these options 30: @command_manager_class = options[:command_manager] || Gem::CommandManager 31: @config_file_class = options[:config_file] || Gem::ConfigFile 32: @doc_manager_class = options[:doc_manager] || Gem::DocManager 33: end
Run the gem command with the following arguments.
# File lib/rubygems/gem_runner.rb, line 38 38: def run(args) 39: start_time = Time.now 40: 41: if args.include?('--') 42: # We need to preserve the original ARGV to use for passing gem options 43: # to source gems. If there is a -- in the line, strip all options after 44: # it...its for the source building process. 45: build_args = args[args.index("--") + 1...args.length] 46: args = args[0...args.index("--")] 47: end 48: 49: Gem::Command.build_args = build_args if build_args 50: 51: do_configuration args 52: cmd = @command_manager_class.instance 53: 54: cmd.command_names.each do |command_name| 55: config_args = Gem.configuration[command_name] 56: config_args = case config_args 57: when String 58: config_args.split ' ' 59: else 60: Array(config_args) 61: end 62: Gem::Command.add_specific_extra_args command_name, config_args 63: end 64: 65: cmd.run Gem.configuration.args 66: end_time = Time.now 67: 68: if Gem.configuration.benchmark then 69: printf "\nExecution time: %0.2f seconds.\n", end_time - start_time 70: puts "Press Enter to finish" 71: STDIN.gets 72: end 73: end