mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Import RubyGems 1.1.0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dc8359969e
commit
8cc45aae94
82 changed files with 5776 additions and 2928 deletions
|
@ -1,8 +1,10 @@
|
|||
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'
|
||||
|
||||
class Gem::Commands::UpdateCommand < Gem::Command
|
||||
|
||||
|
@ -45,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|||
|
||||
def execute
|
||||
if options[:system] then
|
||||
say "Updating RubyGems..."
|
||||
say "Updating RubyGems"
|
||||
|
||||
unless options[:args].empty? then
|
||||
fail "No gem names are allowed with the --system option"
|
||||
|
@ -53,10 +55,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|||
|
||||
options[:args] = ["rubygems-update"]
|
||||
else
|
||||
say "Updating installed gems..."
|
||||
say "Updating installed gems"
|
||||
end
|
||||
|
||||
hig = highest_installed_gems = {}
|
||||
hig = {}
|
||||
|
||||
Gem::SourceIndex.from_installed_gems.each do |name, spec|
|
||||
if hig[spec.name].nil? or hig[spec.name].version < spec.version then
|
||||
|
@ -64,25 +66,28 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|||
end
|
||||
end
|
||||
|
||||
remote_gemspecs = Gem::SourceInfoCache.search(//)
|
||||
pattern = if options[:args].empty? then
|
||||
//
|
||||
else
|
||||
Regexp.union(*options[:args])
|
||||
end
|
||||
|
||||
gems_to_update = if options[:args].empty? then
|
||||
which_to_update(highest_installed_gems, remote_gemspecs)
|
||||
else
|
||||
options[:args]
|
||||
end
|
||||
remote_gemspecs = Gem::SourceInfoCache.search pattern
|
||||
|
||||
options[:domain] = :remote # install from remote source
|
||||
gems_to_update = which_to_update hig, remote_gemspecs
|
||||
|
||||
updated = []
|
||||
|
||||
# HACK use the real API
|
||||
install_command = Gem::CommandManager.instance['install']
|
||||
|
||||
gems_to_update.uniq.sort.each do |name|
|
||||
say "Attempting remote update of #{name}"
|
||||
options[:args] = [name]
|
||||
options[:ignore_dependencies] = true # HACK skip seen gems instead
|
||||
install_command.merge_options(options)
|
||||
install_command.execute
|
||||
next if updated.any? { |spec| spec.name == name }
|
||||
say "Updating #{name}"
|
||||
installer = Gem::DependencyInstaller.new options
|
||||
installer.install name
|
||||
installer.installed_gems.each do |spec|
|
||||
updated << spec
|
||||
say "Successfully installed #{spec.full_name}"
|
||||
end
|
||||
end
|
||||
|
||||
if gems_to_update.include? "rubygems-update" then
|
||||
|
@ -97,12 +102,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|||
|
||||
say "RubyGems system software updated" if installed
|
||||
else
|
||||
updated = gems_to_update.uniq.sort.collect { |g| g.to_s }
|
||||
|
||||
if updated.empty? then
|
||||
say "Nothing to update"
|
||||
else
|
||||
say "Gems updated: #{updated.join ', '}"
|
||||
say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue