aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/commands/update_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands/update_command.rb')
-rw-r--r--lib/rubygems/commands/update_command.rb58
1 files changed, 22 insertions, 36 deletions
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index d63b943c56..02f9657435 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -1,10 +1,12 @@
require 'rubygems/command'
require 'rubygems/command_manager'
+require 'rubygems/dependency_installer'
require 'rubygems/install_update_options'
require 'rubygems/local_remote_options'
require 'rubygems/spec_fetcher'
require 'rubygems/version_option'
-require 'rubygems/commands/install_command'
+require 'rubygems/install_message' # must come before rdoc for messaging
+require 'rubygems/rdoc'
class Gem::Commands::UpdateCommand < Gem::Command
@@ -13,11 +15,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
include Gem::VersionOption
def initialize
- super 'update',
- 'Update the named gems (or all installed gems) in the local repository',
- :generate_rdoc => true,
- :generate_ri => true,
- :force => false
+ super 'update', 'Update installed gems to the latest version',
+ :document => %w[rdoc ri],
+ :force => false
add_install_update_options
@@ -37,6 +37,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
add_local_remote_options
add_platform_option
add_prerelease_option "as update targets"
+
+ @updated = []
+ @installer = Gem::DependencyInstaller.new options
end
def arguments # :nodoc:
@@ -44,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
def defaults_str # :nodoc:
- "--rdoc --ri --no-force --install-dir #{Gem.dir}"
+ "--document --no-force --install-dir #{Gem.dir}"
end
def usage # :nodoc:
@@ -52,9 +55,6 @@ class Gem::Commands::UpdateCommand < Gem::Command
end
def execute
- @installer = Gem::DependencyInstaller.new options
- @updated = []
-
hig = {}
if options[:system] then
@@ -79,21 +79,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
if updated.empty? then
say "Nothing to update"
else
- say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}"
-
- if options[:generate_ri] then
- updated.each do |gem|
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
- end
-
- Gem::DocManager.update_ri_cache
- end
-
- if options[:generate_rdoc] then
- updated.each do |gem|
- Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
- end
- end
+ say "Gems updated: #{updated.map { |spec| spec.name }.join ' '}"
end
end
@@ -112,7 +98,6 @@ class Gem::Commands::UpdateCommand < Gem::Command
@installer.installed_gems.each do |spec|
@updated << spec
- say "Successfully installed #{spec.full_name}" if success
end
end
@@ -178,8 +163,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
args = []
args << '--prefix' << Gem.prefix if Gem.prefix
- args << '--no-rdoc' unless options[:generate_rdoc]
- args << '--no-ri' unless options[:generate_ri]
+ # TODO use --document for >= 1.9 , --no-rdoc --no-ri < 1.9
+ args << '--no-rdoc' unless options[:document].include? 'rdoc'
+ args << '--no-ri' unless options[:document].include? 'ri'
args << '--no-format-executable' if options[:no_format_executable]
update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
@@ -205,20 +191,20 @@ class Gem::Commands::UpdateCommand < Gem::Command
gem_names.all? { |name| /#{name}/ !~ l_spec.name }
dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}"
+ dependency.prerelease = options[:prerelease]
fetcher = Gem::SpecFetcher.fetcher
- spec_tuples = fetcher.find_matching dependency
- matching_gems = spec_tuples.select do |(name, _, platform),|
- name == l_name and Gem::Platform.match platform
+ spec_tuples, _ = fetcher.search_for_dependency dependency
+
+ matching_gems = spec_tuples.select do |g,_|
+ g.name == l_name and g.match_platform?
end
- highest_remote_gem = matching_gems.sort_by do |(_, version),|
- version
- end.last
+ highest_remote_gem = matching_gems.sort_by { |g,_| g.version }.last
- highest_remote_gem ||= [[nil, Gem::Version.new(0), nil]] # "null" object
- highest_remote_ver = highest_remote_gem.first[1]
+ highest_remote_gem ||= [Gem::NameTuple.null]
+ highest_remote_ver = highest_remote_gem.first.version
if system or (l_spec.version < highest_remote_ver) then
result << [l_spec.name, [l_spec.version, highest_remote_ver].max]