Class: Gem::Commands::ExecCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::ExecCommand
- Includes:
- VersionOption
- Defined in:
- lib/rubygems/commands/exec_command.rb
Instance Attribute Summary
Attributes inherited from Gem::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ ExecCommand
constructor
A new instance of ExecCommand.
-
#usage ⇒ Object
:nodoc:.
Methods included from VersionOption
#add_platform_option, #add_prerelease_option, #add_version_option, #get_platform_from_requirements
Methods inherited from Gem::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #begins?, build_args, build_args=, #check_deprecated_options, common_options, #deprecate_option, #deprecated?, extra_args, extra_args=, #extract_gem_name_and_version, #get_all_gem_names, #get_all_gem_names_and_versions, #get_one_gem_name, #get_one_optional_argument, #handles?, #invoke, #invoke_with_build_args, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #when_invoked
Methods included from UserInteraction
#alert, #alert_error, #alert_warning, #ask, #ask_for_password, #ask_yes_no, #choose_from_list, #say, #terminate_interaction, #verbose
Methods included from DefaultUserInteraction
ui, #ui, ui=, #ui=, use_ui, #use_ui
Methods included from Text
#clean_text, #format_text, #levenshtein_distance, #min3, #truncate_text
Constructor Details
#initialize ⇒ ExecCommand
Returns a new instance of ExecCommand.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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, | [:gem_name] = value end add_option(:"Install/Update", "--conservative", "Prefer the most recent installed version, ", "rather than the latest version overall") do |_value, | [:conservative] = true end end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
31 32 33 |
# File 'lib/rubygems/commands/exec_command.rb', line 31 def arguments # :nodoc: "COMMAND the executable command to run" end |
#defaults_str ⇒ Object
:nodoc:
35 36 37 |
# File 'lib/rubygems/commands/exec_command.rb', line 35 def defaults_str # :nodoc: "--version '#{Gem::Requirement.default}'" end |
#description ⇒ Object
:nodoc:
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubygems/commands/exec_command.rb', line 39 def description # :nodoc: <<-EOF The exec command handles installing (if necessary) and running an executable from a gem, regardless of whether that gem is currently installed. The exec command can be thought of as a shortcut to running `gem install` and then the executable from the installed gem. For example, `gem exec rails new .` will run `rails new .` in the current directory, without having to manually run `gem install rails`. Additionally, the exec command ensures the most recent version of the gem is used (unless run with `--conservative`), and that the gem is not installed to the same gem path as user-installed gems. EOF end |
#execute ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rubygems/commands/exec_command.rb', line 59 def execute check_executable print_command if [:gem_name] == "gem" && [:executable] == "gem" set_gem_exec_install_paths Gem::GemRunner.new.run [:args] return elsif [:conservative] install_if_needed else install activate! end load! end |
#usage ⇒ Object
:nodoc:
55 56 57 |
# File 'lib/rubygems/commands/exec_command.rb', line 55 def usage # :nodoc: "#{program_name} [options --] COMMAND [args]" end |