diff options
-rw-r--r-- | lib/rubygems/commands/update_command.rb | 57 |
1 files changed, 35 insertions, 22 deletions
@@ -2,7 +2,7 @@ require 'rubygems/command' require 'rubygems/command_manager' require 'rubygems/install_update_options' require 'rubygems/local_remote_options' -require 'rubygems/source_info_cache' require 'rubygems/version_option' require 'rubygems/commands/install_command' @@ -15,11 +15,10 @@ class Gem::Commands::UpdateCommand < Gem::Command def initialize super 'update', 'Update the named gems (or all installed gems) in the local repository', - :generate_rdoc => true, - :generate_ri => true, - :force => false, - :test => false, - :install_dir => Gem.dir add_install_update_options @@ -60,21 +59,13 @@ class Gem::Commands::UpdateCommand < Gem::Command hig = {} # highest installed gems - Gem::SourceIndex.from_installed_gems.each do |name, spec| if hig[spec.name].nil? or hig[spec.name].version < spec.version then hig[spec.name] = spec end end - pattern = if options[:args].empty? then - // - else - Regexp.union(*options[:args]) - end - - remote_gemspecs = Gem::SourceInfoCache.search pattern - - gems_to_update = which_to_update hig, remote_gemspecs updated = [] @@ -135,20 +126,42 @@ class Gem::Commands::UpdateCommand < Gem::Command end end - def which_to_update(highest_installed_gems, remote_gemspecs) result = [] highest_installed_gems.each do |l_name, l_spec| - matching_gems = remote_gemspecs.select do |spec| - spec.name == l_name and Gem.platforms.any? do |platform| - platform == spec.platform end end - highest_remote_gem = matching_gems.sort_by { |spec| spec.version }.last if highest_remote_gem and - l_spec.version < highest_remote_gem.version then result << l_name end end |