Class: Gem::UninstallCommand

Inherits:
Command
  • Object
show all
Includes:
CommandAids, VersionOption
Defined in:
lib/rubygems/gem_commands.rb

Instance Attribute Summary

Attributes inherited from Command

#command, #defaults, #options, #program_name, #summary

Instance Method Summary collapse

Methods included from CommandAids

#begins?, #get_all_gem_names, #get_one_gem_name, #get_one_optional_argument

Methods included from VersionOption

#add_version_option

Methods inherited from Command

add_common_option, #add_option, add_specific_extra_args, common_options, extra_args, extra_args=, #handles?, #invoke, #merge_options, #remove_option, #show_help, specific_extra_args, specific_extra_args_hash, #when_invoked

Methods included from DefaultUserInteraction

#ui, ui, #ui=, ui=, #use_ui, use_ui

Constructor Details

#initializeUninstallCommand

Returns a new instance of UninstallCommand.



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/rubygems/gem_commands.rb', line 419

def initialize
  super('uninstall', 'Uninstall gems from the local repository',
        { :version => "> 0" })

  add_option('-a', '--[no-]all',
    'Uninstall all matching versions'
    ) do |value, options|
    options[:all] = value
  end

    add_option('-i', '--[no-]ignore-dependencies',
               'Ignore dependency requirements while',
               'uninstalling') do |value, options|
    options[:ignore] = value
  end

    add_option('-x', '--[no-]executables',
               'Uninstall applicable executables without',
               'confirmation') do |value, options|
    options[:executables] = value
  end

  add_version_option('uninstall')
end

Instance Method Details

#argumentsObject



452
453
454
# File 'lib/rubygems/gem_commands.rb', line 452

def arguments
  "GEMNAME   name of gem to uninstall"
end

#defaults_strObject



444
445
446
# File 'lib/rubygems/gem_commands.rb', line 444

def defaults_str
  "--version '> 0' --no-force"
end

#executeObject



456
457
458
459
460
# File 'lib/rubygems/gem_commands.rb', line 456

def execute
  get_all_gem_names.each do |gem_name|
    Gem::Uninstaller.new(gem_name, options).uninstall
  end
end

#usageObject



448
449
450
# File 'lib/rubygems/gem_commands.rb', line 448

def usage
  "#{program_name} GEMNAME [GEMNAME ...]"
end