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