class Gem::Commands::ExecCommand

Public Class Methods

new ()
Calls superclass method Gem::Command::new
# File lib/rubygems/commands/exec_command.rb, line 12
def initialize
  super "exec", "Run a command from a gem", {
    version: Gem::Requirement.default,
  }

  add_version_option
  add_prerelease_option "to be installed"

  add_option "-g", "--gem GEM", "run the executable from the given gem" do |value, options|
    options[:gem_name] = value
  end

  add_option(:"Install/Update", "--conservative",
    "Prefer the most recent installed version, ",
    "rather than the latest version overall") do |_value, options|
    options[:conservative] = true
  end
end

Public Instance Methods

execute ()
# File lib/rubygems/commands/exec_command.rb, line 59
def execute
  check_executable

  print_command
  if options[:gem_name] == "gem" && options[:executable] == "gem"
    set_gem_exec_install_paths
    Gem::GemRunner.new.run options[:args]
    return
  elsif options[:conservative]
    install_if_needed
  else
    install
    activate!
  end

  load!
end