diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-25 10:13:50 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-25 10:13:50 +0000 |
commit | d478c7a7342478847cc1148f4134b5f0db04e1d9 (patch) | |
tree | 3bfca425683a94d1360ecdf5857d741b8eaac213 /lib/rubygems/commands/update_command.rb | |
parent | 788001a9c8473130bd357846785838045387b060 (diff) | |
download | ruby-d478c7a7342478847cc1148f4134b5f0db04e1d9.tar.gz |
Update to RubyGems 1.3.0 r1891
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/update_command.rb')
-rw-r--r-- | lib/rubygems/commands/update_command.rb | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index 78baa8ba56..4490f385dc 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -45,6 +45,8 @@ class Gem::Commands::UpdateCommand < Gem::Command end def execute + hig = {} + if options[:system] then say "Updating RubyGems" @@ -52,16 +54,22 @@ class Gem::Commands::UpdateCommand < Gem::Command fail "No gem names are allowed with the --system option" end - options[:args] = ["rubygems-update"] + spec = Gem::Specification.new + spec.name = 'rubygems-update' + spec.version = Gem::Version.new Gem::RubyGemsVersion + spec.version = Gem::Version.new '1.1.1' + hig['rubygems-update'] = spec + + options[:user_install] = false else say "Updating installed gems" - end - hig = {} # highest installed gems + hig = {} # highest installed gems - Gem.source_index.each do |name, spec| - if hig[spec.name].nil? or hig[spec.name].version < spec.version then - hig[spec.name] = spec + Gem.source_index.each do |name, spec| + if hig[spec.name].nil? or hig[spec.name].version < spec.version then + hig[spec.name] = spec + end end end @@ -84,14 +92,14 @@ class Gem::Commands::UpdateCommand < Gem::Command end if gems_to_update.include? "rubygems-update" then - latest_ruby_gem = remote_gemspecs.select do |s| - s.name == 'rubygems-update' - end + Gem.source_index.refresh! + + update_gems = Gem.source_index.search 'rubygems-update' - latest_ruby_gem = latest_ruby_gem.sort_by { |s| s.version }.last + latest_update_gem = update_gems.sort_by { |s| s.version }.last - say "Updating version of RubyGems to #{latest_ruby_gem.version}" - installed = do_rubygems_update latest_ruby_gem.version + say "Updating RubyGems to #{latest_update_gem.version}" + installed = do_rubygems_update latest_update_gem.version say "RubyGems system software updated" if installed else @@ -103,6 +111,9 @@ class Gem::Commands::UpdateCommand < Gem::Command end end + ## + # Update the RubyGems software to +version+. + def do_rubygems_update(version) args = [] args.push '--prefix', Gem.prefix unless Gem.prefix.nil? @@ -112,8 +123,6 @@ class Gem::Commands::UpdateCommand < Gem::Command update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}" - success = false - Dir.chdir update_dir do say "Installing RubyGems #{version}" setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}" |