Class: Gem::Commands::RequireCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::RequireCommand
- Includes:
- InstallUpdateOptions, LocalRemoteOptions, VersionOption
- Defined in:
- lib/rubygems/commands/require_command.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ RequireCommand
constructor
A new instance of RequireCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ RequireCommand
Returns a new instance of RequireCommand.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rubygems/commands/require_command.rb', line 14 def initialize defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge( { :generate_rdoc => true, :generate_ri => true, :format_executable => false, :test => false, :version => Gem::Requirement.default, :latest => false, } ) super 'require', 'Install or update a gem', defaults add_option('--latest', 'Get the latest matching version') do |value, | [:latest] = true end add_version_option add_platform_option add_prerelease_option end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
42 43 44 |
# File 'lib/rubygems/commands/require_command.rb', line 42 def arguments # :nodoc: "GEMNAME name of required gem" end |
#defaults_str ⇒ Object
:nodoc:
46 47 48 49 |
# File 'lib/rubygems/commands/require_command.rb', line 46 def defaults_str # :nodoc: "--version '#{Gem::Requirement.default}' --rdoc --ri --no-force\n" \ "--no-test --install-dir #{Gem.dir}" end |
#description ⇒ Object
:nodoc:
51 52 53 54 55 56 |
# File 'lib/rubygems/commands/require_command.rb', line 51 def description # :nodoc: <<-EOF The require command checks whether the specified gems are installed, and installs them if necessary. EOF end |
#execute ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rubygems/commands/require_command.rb', line 62 def execute exit_code = 0 version = [:version] get_all_gem_names.each do |name| begin require_gem(name, version, ) rescue Gem::InstallError => e alert_error "Error installing #{name}:\n\t#{e.}" exit_code |= 1 rescue Gem::GemNotFoundException => e show_lookup_failure e.name, e.version, e.errors, [:domain] exit_code |= 2 end end exit(exit_code) end |
#usage ⇒ Object
:nodoc:
58 59 60 |
# File 'lib/rubygems/commands/require_command.rb', line 58 def usage # :nodoc: "#{program_name} GEMNAME [GEMNAME ...] [options]" end |