aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/commands
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-14 03:30:02 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-14 03:30:02 +0000
commit4de117a61517e839f2c45eaf45d56fc243d6d5b2 (patch)
tree7cb5af7a7eb513e5dddf5e343746b1611e628387 /lib/rubygems/commands
parente548c09d429a5136285ea81aed418685359ed124 (diff)
downloadruby-4de117a61517e839f2c45eaf45d56fc243d6d5b2.tar.gz
* lib/rubygems: Update to RubyGems 2.4.1 master(713ab65)
Complete history at: https://github.com/rubygems/rubygems/blob/master/History.txt#L3-L216 * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r--lib/rubygems/commands/cert_command.rb24
-rw-r--r--lib/rubygems/commands/cleanup_command.rb4
-rw-r--r--lib/rubygems/commands/contents_command.rb25
-rw-r--r--lib/rubygems/commands/dependency_command.rb4
-rw-r--r--lib/rubygems/commands/environment_command.rb7
-rw-r--r--lib/rubygems/commands/help_command.rb219
-rw-r--r--lib/rubygems/commands/install_command.rb58
-rw-r--r--lib/rubygems/commands/list_command.rb4
-rw-r--r--lib/rubygems/commands/open_command.rb74
-rw-r--r--lib/rubygems/commands/owner_command.rb4
-rw-r--r--lib/rubygems/commands/search_command.rb10
-rw-r--r--lib/rubygems/commands/setup_command.rb2
-rw-r--r--lib/rubygems/commands/uninstall_command.rb14
-rw-r--r--lib/rubygems/commands/update_command.rb23
-rw-r--r--lib/rubygems/commands/yank_command.rb21
15 files changed, 408 insertions, 85 deletions
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index e417193bca..a920e7fcc3 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -129,23 +129,21 @@ class Gem::Commands::CertCommand < Gem::Command
end
def build_key # :nodoc:
- if options[:key] then
- options[:key]
- else
- passphrase = ask_for_password 'Passphrase for your Private Key:'
- say "\n"
+ return options[:key] if options[:key]
- passphrase_confirmation = ask_for_password 'Please repeat the passphrase for your Private Key:'
- say "\n"
+ passphrase = ask_for_password 'Passphrase for your Private Key:'
+ say "\n"
- raise Gem::CommandLineError,
- "Passphrase and passphrase confirmation don't match" unless passphrase == passphrase_confirmation
+ passphrase_confirmation = ask_for_password 'Please repeat the passphrase for your Private Key:'
+ say "\n"
- key = Gem::Security.create_key
- key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase
+ raise Gem::CommandLineError,
+ "Passphrase and passphrase confirmation don't match" unless passphrase == passphrase_confirmation
- return key, key_path
- end
+ key = Gem::Security.create_key
+ key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase
+
+ return key, key_path
end
def certificates_matching filter
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index c8f0082bfb..69975640fe 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -67,10 +67,10 @@ If no gems are named all gems in GEM_HOME are cleaned.
say "Clean Up Complete"
- if Gem.configuration.really_verbose then
+ verbose do
skipped = @default_gems.map { |spec| spec.full_name }
- say "Skipped default gems: #{skipped.join ', '}"
+ "Skipped default gems: #{skipped.join ', '}"
end
end
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index 603f1d072a..15657f31a2 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -8,7 +8,8 @@ class Gem::Commands::ContentsCommand < Gem::Command
def initialize
super 'contents', 'Display the contents of the installed gems',
- :specdirs => [], :lib_only => false, :prefix => true
+ :specdirs => [], :lib_only => false, :prefix => true,
+ :show_install_dir => false
add_version_option
@@ -32,6 +33,11 @@ class Gem::Commands::ContentsCommand < Gem::Command
options[:prefix] = prefix
end
+ add_option( '--[no-]show-install-dir',
+ 'Show only the gem install dir') do |show, options|
+ options[:show_install_dir] = show
+ end
+
@path_kind = nil
@spec_dirs = nil
@version = nil
@@ -65,7 +71,12 @@ prefix or only the files that are requireable.
names = gem_names
names.each do |name|
- found = gem_contents name
+ found =
+ if options[:show_install_dir] then
+ gem_install_dir name
+ else
+ gem_contents name
+ end
terminate_interaction 1 unless found or names.length > 1
end
@@ -115,6 +126,16 @@ prefix or only the files that are requireable.
true
end
+ def gem_install_dir name
+ spec = spec_for name
+
+ return false unless spec
+
+ say spec.gem_dir
+
+ true
+ end
+
def gem_names # :nodoc:
if options[:all] then
Gem::Specification.map(&:name)
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index c5d6dd7d70..4a54a3e385 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -31,7 +31,7 @@ class Gem::Commands::DependencyCommand < Gem::Command
end
def arguments # :nodoc:
- "GEMNAME name of gem to show dependencies for"
+ "REGEXP show dependencies for gems whose names start with REGEXP"
end
def defaults_str # :nodoc:
@@ -50,7 +50,7 @@ use with other commands.
end
def usage # :nodoc:
- "#{program_name} GEMNAME"
+ "#{program_name} REGEXP"
end
def fetch_remote_specs dependency # :nodoc:
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index d32d12b757..067d0b1607 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -28,8 +28,9 @@ The RubyGems environment can be controlled through command line arguments,
gemrc files, environment variables and built-in defaults.
Command line argument defaults and some RubyGems defaults can be set in a
-~/.gemrc file for individual users and a /etc/gemrc for all users. These
-files are YAML files with the following YAML keys:
+~/.gemrc file for individual users and a gemrc in the SYSTEM CONFIGURATION
+DIRECTORY for all users. These files are YAML files with the following YAML
+keys:
:sources: A YAML array of remote gem repositories to install gems from
:verbose: Verbosity of the gem command. false, true, and :really are the
@@ -120,6 +121,8 @@ lib/rubygems/defaults/operating_system.rb
out << " - SPEC CACHE DIRECTORY: #{Gem.spec_cache_dir}\n"
+ out << " - SYSTEM CONFIGURATION DIRECTORY: #{Gem::ConfigFile::SYSTEM_CONFIG_PATH}\n"
+
out << " - RUBYGEMS PLATFORMS:\n"
Gem.platforms.each do |platform|
out << " - #{platform}\n"
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index ed7be903ac..ed81ad6e25 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -52,6 +52,183 @@ Some examples of 'gem' usage.
gem update --system
EOF
+ GEM_DEPENDENCIES = <<-EOF
+A gem dependencies file allows installation of a consistent set of gems across
+multiple environments. The RubyGems implementation is designed to be
+compatible with Bundler's Gemfile format. You can see additional
+documentation on the format at:
+
+ http://bundler.io
+
+RubyGems automatically looks for these gem dependencies files:
+
+* gem.deps.rb
+* Gemfile
+* Isolate
+
+These files are looked up automatically using `gem install -g`, or you can
+specify a custom file.
+
+When the RUBYGEMS_GEMDEPS environment variable is set to a gem dependencies
+file the gems from that file will be activated at startup time. Set it to a
+specific filename or to "-" to have RubyGems automatically discover the gem
+dependencies file by walking up from the current directory.
+
+You can also activate gem dependencies at program startup using
+Gem.use_gemdeps.
+
+NOTE: Enabling automatic discovery on multiuser systems can lead to execution
+of arbitrary code when used from directories outside your control.
+
+Gem Dependencies
+================
+
+Use #gem to declare which gems you directly depend upon:
+
+ gem 'rake'
+
+To depend on a specific set of versions:
+
+ gem 'rake', '~> 10.3', '>= 10.3.2'
+
+RubyGems will require the gem name when activating the gem using
+the RUBYGEMS_GEMDEPS environment variable or Gem::use_gemdeps. Use the
+require: option to override this behavior if the gem does not have a file of
+that name or you don't want to require those files:
+
+ gem 'my_gem', require: 'other_file'
+
+To prevent RubyGems from requiring any files use:
+
+ gem 'my_gem', require: false
+
+To load dependencies from a .gemspec file:
+
+ gemspec
+
+RubyGems looks for the first .gemspec file in the current directory. To
+override this use the name: option:
+
+ gemspec name: 'specific_gem'
+
+To look in a different directory use the path: option:
+
+ gemspec name: 'specific_gem', path: 'gemspecs'
+
+To depend on a gem unpacked into a local directory:
+
+ gem 'modified_gem', path: 'vendor/modified_gem'
+
+To depend on a gem from git:
+
+ gem 'private_gem', git: 'git@my.company.example:private_gem.git'
+
+To depend on a gem from github:
+
+ gem 'private_gem', github: 'my_company/private_gem'
+
+To depend on a gem from a github gist:
+
+ gem 'bang', gist: '1232884'
+
+Git, github and gist support the ref:, branch: and tag: options to specify a
+commit reference or hash, branch or tag respectively to use for the gem.
+
+Setting the submodules: option to true for git, github and gist dependencies
+causes fetching of submodules when fetching the repository.
+
+You can depend on multiple gems from a single repository with the git method:
+
+ git 'https://github.com/rails/rails.git' do
+ gem 'activesupport'
+ gem 'activerecord'
+ end
+
+Gem Sources
+===========
+
+RubyGems uses the default sources for regular `gem install` for gem
+dependencies files. Unlike bundler, you do need to specify a source.
+
+You can override the sources used for downloading gems with:
+
+ source 'https://gem_server.example'
+
+You may specify multiple sources. Unlike bundler the prepend: option is not
+supported. Sources are used in-order, to prepend a source place it at the
+front of the list.
+
+Gem Platform
+============
+
+You can restrict gem dependencies to specific platforms with the #platform
+and #platforms methods:
+
+ platform :ruby_21 do
+ gem 'debugger'
+ end
+
+See the bundler Gemfile manual page for a list of platforms supported in a gem
+dependencies file.:
+
+ http://bundler.io/v1.6/man/gemfile.5.html
+
+Ruby Version and Engine Dependency
+==================================
+
+You can specifiy the version, engine and engine version of ruby to use with
+your gem dependencies file. If you are not running the specified version
+RubyGems will raise an exception.
+
+To depend on a specific version of ruby:
+
+ ruby '2.1.2'
+
+To depend on a specific ruby engine:
+
+ ruby '1.9.3', engine: 'jruby'
+
+To depend on a specific ruby engine version:
+
+ ruby '1.9.3', engine: 'jruby', engine_version: '1.7.11'
+
+Grouping Dependencies
+=====================
+
+Gem dependencies may be placed in groups that can be excluded from install.
+Dependencies required for development or testing of your code may be excluded
+when installed in a production environment.
+
+A #gem dependency may be placed in a group using the group: option:
+
+ gem 'minitest', group: :test
+
+To install dependencies from a gemfile without specific groups use the
+`--without` option for `gem install -g`:
+
+ $ gem install -g --without test
+
+The group: option also accepts multiple groups if the gem fits in multiple
+categories.
+
+Multiple groups may be excluded during install by comma-separating the groups for `--without` or by specifying `--without` multiple times.
+
+The #group method can also be used to place gems in groups:
+
+ group :test do
+ gem 'minitest'
+ gem 'minitest-emoji'
+ end
+
+The #group method allows multiple groups.
+
+The #gemspec development dependencies are placed in the :development group by
+default. This may be overriden with the :development_group option:
+
+ gemspec development_group: :other
+
+ EOF
+
PLATFORMS = <<-'EOF'
RubyGems platforms are composed of three parts, a CPU, an OS, and a
version. These values are taken from values in rbconfig.rb. You can view
@@ -90,6 +267,16 @@ When building platform gems, set the platform in the gem specification to
Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's
platform.
EOF
+
+ # NOTE when updating also update Gem::Command::HELP
+
+ SUBCOMMANDS = [
+ ["commands", :show_commands],
+ ["options", Gem::Command::HELP],
+ ["examples", EXAMPLES],
+ ["gem_dependencies", GEM_DEPENDENCIES],
+ ["platforms", PLATFORMS],
+ ]
# :startdoc:
def initialize
@@ -98,15 +285,6 @@ platform.
@command_manager = Gem::CommandManager.instance
end
- def arguments # :nodoc:
- args = <<-EOF
- commands List all 'gem' commands
- examples Show examples of 'gem' usage
- <command> Show specific help for <command>
- EOF
- return args.gsub(/^\s+/, '')
- end
-
def usage # :nodoc:
"#{program_name} ARGUMENT"
end
@@ -114,19 +292,20 @@ platform.
def execute
arg = options[:args][0]
- if begins? "commands", arg then
- show_commands
-
- elsif begins? "options", arg then
- say Gem::Command::HELP
-
- elsif begins? "examples", arg then
- say EXAMPLES
+ _, help = SUBCOMMANDS.find do |command,|
+ begins? command, arg
+ end
- elsif begins? "platforms", arg then
- say PLATFORMS
+ if help then
+ if Symbol === help then
+ send help
+ else
+ say help
+ end
+ return
+ end
- elsif options[:help] then
+ if options[:help] then
show_help
elsif arg then
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 8219eef6ea..1bf5928ebb 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -21,6 +21,8 @@ class Gem::Commands::InstallCommand < Gem::Command
def initialize
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
:format_executable => false,
+ :lock => true,
+ :suggest_alternate => true,
:version => Gem::Requirement.default,
:without_groups => [],
})
@@ -69,6 +71,16 @@ class Gem::Commands::InstallCommand < Gem::Command
o[:explain] = v
end
+ add_option(:"Install/Update", '--[no-]lock',
+ 'Create a lock file (when used with -g/--file)') do |v,o|
+ o[:lock] = v
+ end
+
+ add_option(:"Install/Update", '--[no-]suggestions',
+ 'Suggest alternates when gems are not found') do |v,o|
+ o[:suggest_alternate] = v
+ end
+
@installed_specs = []
end
@@ -78,7 +90,7 @@ class Gem::Commands::InstallCommand < Gem::Command
def defaults_str # :nodoc:
"--both --version '#{Gem::Requirement.default}' --document --no-force\n" +
- "--install-dir #{Gem.dir}"
+ "--install-dir #{Gem.dir} --lock"
end
def description # :nodoc:
@@ -92,6 +104,25 @@ The wrapper allows you to choose among alternate gem versions using _version_.
For example `rake _0.7.3_ --version` will run rake version 0.7.3 if a newer
version is also installed.
+Gem Dependency Files
+====================
+
+RubyGems can install a consistent set of gems across multiple environments
+using `gem install -g` when a gem dependencies file (gem.deps.rb, Gemfile or
+Isolate) is present. If no explicit file is given RubyGems attempts to find
+one in the current directory.
+
+When the RUBYGEMS_GEMDEPS environment variable is set to a gem dependencies
+file the gems from that file will be activated at startup time. Set it to a
+specific filename or to "-" to have RubyGems automatically discover the gem
+dependencies file by walking up from the current directory.
+
+NOTE: Enabling automatic discovery on multiuser systems can lead to
+execution of arbitrary code when used from directories outside your control.
+
+Extension Install Failures
+==========================
+
If an extension fails to compile during gem installation the gem
specification is not written out, but the gem remains unpacked in the
repository. You may need to specify the path to the library's headers and
@@ -204,23 +235,20 @@ to write the specification by hand. For example:
install_gem_without_dependencies name, req
else
inst = Gem::DependencyInstaller.new options
+ request_set = inst.resolve_dependencies name, req
if options[:explain]
- request_set = inst.resolve_dependencies name, req
-
puts "Gems to install:"
- request_set.specs.map { |s| s.full_name }.sort.each do |s|
- puts " #{s}"
+ request_set.sorted_requests.each do |s|
+ puts " #{s.full_name}"
end
return
else
- inst.install name, req
+ @installed_specs.concat request_set.install options
end
- @installed_specs.push(*inst.installed_gems)
-
show_install_errors inst.errors
end
end
@@ -250,6 +278,14 @@ to write the specification by hand. For example:
inst = Gem::Installer.new gem, options
inst.install
+ require 'rubygems/dependency_installer'
+ dinst = Gem::DependencyInstaller.new options
+ dinst.installed_gems.replace [inst.spec]
+
+ Gem.done_installing_hooks.each do |hook|
+ hook.call dinst, [inst.spec]
+ end unless Gem.done_installing_hooks.empty?
+
@installed_specs.push(inst.spec)
end
@@ -264,8 +300,10 @@ to write the specification by hand. For example:
rescue Gem::InstallError => e
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
- rescue Gem::GemNotFoundException => e
- show_lookup_failure e.name, e.version, e.errors, options[:domain]
+ rescue Gem::GemNotFoundException, Gem::UnsatisfiableDependencyError => e
+ domain = options[:domain]
+ domain = :local unless options[:suggest_alternate]
+ show_lookup_failure e.name, e.version, e.errors, domain
exit_code |= 2
end
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index 4edeabef02..c6ff237311 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -8,13 +8,13 @@ require 'rubygems/commands/query_command'
class Gem::Commands::ListCommand < Gem::Commands::QueryCommand
def initialize
- super 'list', 'Display local gems whose name starts with STRING'
+ super 'list', 'Display local gems whose name matches REGEXP'
remove_option('--name-matches')
end
def arguments # :nodoc:
- "STRING start of gem name to look for"
+ "REGEXP regexp to look for in gem name"
end
def defaults_str # :nodoc:
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
new file mode 100644
index 0000000000..91963bba73
--- /dev/null
+++ b/lib/rubygems/commands/open_command.rb
@@ -0,0 +1,74 @@
+require 'English'
+require 'rubygems/command'
+require 'rubygems/version_option'
+require 'rubygems/util'
+
+class Gem::Commands::OpenCommand < Gem::Command
+
+ include Gem::VersionOption
+
+ def initialize
+ super 'open', 'Open gem sources in editor'
+
+ add_option('-e', '--editor EDITOR', String,
+ "Opens gem sources in EDITOR") do |editor, options|
+ options[:editor] = editor || get_env_editor
+ end
+ end
+
+ def arguments # :nodoc:
+ "GEMNAME name of gem to open in editor"
+ end
+
+ def defaults_str # :nodoc:
+ "-e #{get_env_editor}"
+ end
+
+ def description # :nodoc:
+ <<-EOF
+ The open command opens gem in editor and changes current path
+ to gem's source directory. Editor can be specified with -e option,
+ otherwise rubygems will look for editor in $EDITOR, $VISUAL and
+ $GEM_EDITOR variables.
+ EOF
+ end
+
+ def usage # :nodoc:
+ "#{program_name} GEMNAME [-e EDITOR]"
+ end
+
+ def get_env_editor
+ ENV['GEM_EDITOR'] ||
+ ENV['VISUAL'] ||
+ ENV['EDITOR'] ||
+ 'vi'
+ end
+
+ def execute
+ @version = options[:version] || Gem::Requirement.default
+ @editor = options[:editor] || get_env_editor
+
+ found = open_gem(get_one_gem_name)
+
+ terminate_interaction 1 unless found
+ end
+
+ def open_gem name
+ spec = spec_for name
+ return false unless spec
+
+ open_editor(spec.full_gem_path)
+ end
+
+ def open_editor path
+ system(*@editor.split(/\s+/) + [path])
+ end
+
+ def spec_for name
+ spec = Gem::Specification.find_all_by_name(name, @version).last
+
+ return spec if spec
+
+ say "Unable to find gem '#{name}'"
+ end
+end
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 13b8793021..322bf6590a 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -86,7 +86,9 @@ permission to.
request.add_field "Authorization", api_key
end
- with_response response, "Removing #{owner}"
+ action = method == :delete ? "Removing" : "Adding"
+
+ with_response response, "#{action} #{owner}"
rescue
# ignore
end
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index 5809690735..a1e2c1a00e 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -4,7 +4,7 @@ require 'rubygems/commands/query_command'
class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
def initialize
- super 'search', 'Display remote gems whose name contains STRING'
+ super 'search', 'Display remote gems whose name matches REGEXP'
remove_option '--name-matches'
@@ -12,7 +12,7 @@ class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
end
def arguments # :nodoc:
- "STRING fragment of gem name to search for"
+ "REGEXP regexp to search for in gem name"
end
def defaults_str # :nodoc:
@@ -21,8 +21,8 @@ class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
def description # :nodoc:
<<-EOF
-The search command displays remote gems whose name contains the given
-string.
+The search command displays remote gems whose name matches the given
+regexp.
The --details option displays additional details from the gem but will
take a little longer to complete as it must download the information
@@ -33,7 +33,7 @@ To list local gems use the list command.
end
def usage # :nodoc:
- "#{program_name} [STRING]"
+ "#{program_name} [REGEXP]"
end
end
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 681db0dc1d..6617396780 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -446,7 +446,7 @@ abort "#{deprecation_message}"
history.force_encoding Encoding::UTF_8 if
Object.const_defined? :Encoding
- history = history.sub(/^# coding:.*?^=/m, '')
+ history = history.sub(/^# coding:.*?(?=^=)/m, '')
text = history.split(HISTORY_HEADER)
text.shift # correct an off-by-one generated by split
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index e62095a336..71ffdc89fc 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -15,7 +15,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
def initialize
super 'uninstall', 'Uninstall gems from the local repository',
:version => Gem::Requirement.default, :user_install => true,
- :check_dev => false
+ :check_dev => false, :vendor => false
add_option('-a', '--[no-]all',
'Uninstall all matching versions'
@@ -76,6 +76,18 @@ class Gem::Commands::UninstallCommand < Gem::Command
add_version_option
add_platform_option
+
+ add_option('--vendor',
+ 'Uninstall gem from the vendor directory.',
+ 'Only for use by gem repackagers.') do |value, options|
+ unless Gem.vendor_dir then
+ raise OptionParser::InvalidOption.new 'your platform is not supported'
+ end
+
+ alert_warning 'Use your OS package manager to uninstall vendor gems'
+ options[:vendor] = true
+ options[:install_dir] = Gem.vendor_dir
+ end
end
def arguments # :nodoc:
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index b4ee59b3bb..9e9bd088f2 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -16,6 +16,8 @@ class Gem::Commands::UpdateCommand < Gem::Command
attr_reader :installer # :nodoc:
+ attr_reader :updated # :nodoc:
+
def initialize
super 'update', 'Update installed gems to the latest version',
:document => %w[rdoc ri],
@@ -45,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
def arguments # :nodoc:
- "GEMNAME name of gem to update"
+ "REGEXP regexp to search for in gem name"
end
def defaults_str # :nodoc:
@@ -56,13 +58,13 @@ class Gem::Commands::UpdateCommand < Gem::Command
<<-EOF
The update command will update your gems to the latest version.
-The update comamnd does not remove the previous version. Use the cleanup
+The update command does not remove the previous version. Use the cleanup
command to remove old versions.
EOF
end
def usage # :nodoc:
- "#{program_name} GEMNAME [GEMNAME ...]"
+ "#{program_name} REGEXP [REGEXP ...]"
end
def check_latest_rubygems version # :nodoc:
@@ -97,10 +99,14 @@ command to remove old versions.
updated = update_gems gems_to_update
+ updated_names = updated.map { |spec| spec.name }
+ not_updated_names = options[:args].uniq - updated_names
+
if updated.empty? then
say "Nothing to update"
else
- say "Gems updated: #{updated.map { |spec| spec.name }.join ' '}"
+ say "Gems updated: #{updated_names.join(' ')}"
+ say "Gems already up-to-date: #{not_updated_names.join(' ')}" unless not_updated_names.empty?
end
end
@@ -199,15 +205,11 @@ command to remove old versions.
@installer ||= Gem::DependencyInstaller.new options
- success = false
-
say "Updating #{name}"
begin
@installer.install name, Gem::Requirement.new(version)
- success = true
- rescue Gem::InstallError => e
+ rescue Gem::InstallError, Gem::DependencyError => e
alert_error "Error installing #{name}:\n\t#{e.message}"
- success = false
end
@installer.installed_gems.each do |spec|
@@ -259,7 +261,7 @@ command to remove old versions.
highest_installed_gems.each do |l_name, l_spec|
next if not gem_names.empty? and
- gem_names.all? { |name| /#{name}/ !~ l_spec.name }
+ gem_names.none? { |name| name == l_spec.name }
highest_remote_ver = highest_remote_version l_spec
@@ -272,4 +274,3 @@ command to remove old versions.
end
end
-
diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb
index 2285bb4017..3c7859e763 100644
--- a/lib/rubygems/commands/yank_command.rb
+++ b/lib/rubygems/commands/yank_command.rb
@@ -44,10 +44,7 @@ as the reason for the removal request.
options[:undo] = true
end
- add_option('-k', '--key KEY_NAME',
- 'Use API key from your gem credentials file') do |value, options|
- options[:key] = value
- end
+ add_key_option
end
def execute
@@ -55,14 +52,12 @@ as the reason for the removal request.
version = get_version_from_requirements(options[:version])
platform = get_platform_from_requirements(options)
- api_key = Gem.configuration.rubygems_api_key
- api_key = Gem.configuration.api_keys[options[:key].to_sym] if options[:key]
if version then
if options[:undo] then
- unyank_gem(version, platform, api_key)
+ unyank_gem(version, platform)
else
- yank_gem(version, platform, api_key)
+ yank_gem(version, platform)
end
else
say "A version argument is required: #{usage}"
@@ -70,19 +65,19 @@ as the reason for the removal request.
end
end
- def yank_gem(version, platform, api_key)
+ def yank_gem(version, platform)
say "Yanking gem from #{self.host}..."
- yank_api_request(:delete, version, platform, "api/v1/gems/yank", api_key)
+ yank_api_request(:delete, version, platform, "api/v1/gems/yank")
end
- def unyank_gem(version, platform, api_key)
+ def unyank_gem(version, platform)
say "Unyanking gem from #{host}..."
- yank_api_request(:put, version, platform, "api/v1/gems/unyank", api_key)
+ yank_api_request(:put, version, platform, "api/v1/gems/unyank")
end
private
- def yank_api_request(method, version, platform, api, api_key)
+ def yank_api_request(method, version, platform, api)
name = get_one_gem_name
response = rubygems_api_request(method, api) do |request|
request.add_field("Authorization", api_key)