summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r--lib/rubygems/commands/owner_command.rb11
-rw-r--r--lib/rubygems/commands/pristine_command.rb2
-rw-r--r--lib/rubygems/commands/setup_command.rb4
-rw-r--r--lib/rubygems/commands/specification_command.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb51
5 files changed, 29 insertions, 41 deletions
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 0a5665228f..42b0d79135 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -12,7 +12,12 @@ class Gem::Commands::OwnerCommand < Gem::Command
def description # :nodoc:
<<-EOF
The owner command lets you add and remove owners of a gem on a push
-server (the default is https://rubygems.org).
+server (the default is https://rubygems.org). Multiple owners can be
+added or removed at the same time, if the flag is given multiple times.
+
+The supported user identifiers are dependant on the push server.
+For rubygems.org, both e-mail and handle are supported, even though the
+user identifier field is called "email".
The owner of a gem has the permission to push new versions, yank existing
versions or edit the HTML page of the gem. Be careful of who you give push
@@ -35,11 +40,11 @@ permission to.
add_otp_option
defaults.merge! :add => [], :remove => []
- add_option '-a', '--add EMAIL', 'Add an owner' do |value, options|
+ add_option '-a', '--add NEW_OWNER', 'Add an owner by user identifier' do |value, options|
options[:add] << value
end
- add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options|
+ add_option '-r', '--remove OLD_OWNER', 'Remove an owner by user identifier' do |value, options|
options[:remove] << value
end
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 3cf496ba5b..030c1bffce 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -113,7 +113,7 @@ extensions will be restored.
end.flatten
end
- specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
+ specs = specs.select {|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
if specs.to_a.empty?
raise Gem::Exception,
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 01714f0342..84e9210cfb 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -341,7 +341,7 @@ By default, this RubyGems will install gem as:
fake_spec = Gem::Specification.new 'rubygems', Gem::VERSION
def fake_spec.full_gem_path
- File.expand_path '../../../..', __FILE__
+ File.expand_path '../../..', __dir__
end
generate_ri = options[:document].include? 'ri'
@@ -475,7 +475,7 @@ By default, this RubyGems will install gem as:
def files_in(dir)
Dir.chdir dir do
Dir.glob(File.join('**', '*'), File::FNM_DOTMATCH).
- select{|f| !File.directory?(f) }
+ select {|f| !File.directory?(f) }
end
end
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 6f24787962..6fba3a36ec 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -129,7 +129,7 @@ Specific fields in the specification can be extracted in YAML format:
platform = get_platform_from_requirements(options)
if platform
- specs = specs.select{|s| s.platform.to_s == platform }
+ specs = specs.select {|s| s.platform.to_s == platform }
end
unless options[:all]
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 42d6f6046b..422fdd4e81 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -162,21 +162,17 @@ command to remove old versions.
def highest_remote_name_tuple(spec) # :nodoc:
spec_tuples = fetch_remote_gems spec
- matching_gems = spec_tuples.select do |g,_|
- g.name == spec.name and g.match_platform?
- end
-
- highest_remote_gem = matching_gems.max
-
- highest_remote_gem ||= [Gem::NameTuple.null]
+ highest_remote_gem = spec_tuples.max
+ return unless highest_remote_gem
highest_remote_gem.first
end
- def install_rubygems(version) # :nodoc:
+ def install_rubygems(spec) # :nodoc:
args = update_rubygems_arguments
+ version = spec.version
- update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
+ update_dir = File.join spec.base_dir, 'gems', "rubygems-update-#{version}"
Dir.chdir update_dir do
say "Installing RubyGems #{version}" unless options[:silent]
@@ -213,30 +209,22 @@ command to remove old versions.
version = options[:system]
update_latest = version == true
- if update_latest
- version = Gem::Version.new Gem::VERSION
- requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
- else
+ unless update_latest
version = Gem::Version.new version
requirement = Gem::Requirement.new version
+
+ return version, requirement
end
+ version = Gem::Version.new Gem::VERSION
+ requirement = Gem::Requirement.new ">= #{Gem::VERSION}"
+
rubygems_update = Gem::Specification.new
rubygems_update.name = 'rubygems-update'
rubygems_update.version = version
- hig = {
- 'rubygems-update' => rubygems_update,
- }
-
- gems_to_update = which_to_update hig, options[:args], :system
- up_ver = gems_to_update.first.version
-
- target = if update_latest
- up_ver
- else
- version
- end
+ highest_remote_tup = highest_remote_name_tuple(rubygems_update)
+ target = highest_remote_tup ? highest_remote_tup.version : version
return target, requirement
end
@@ -290,9 +278,7 @@ command to remove old versions.
installed_gems = update_gem('rubygems-update', version) if installed_gems.empty? || installed_gems.first.version != version
return if installed_gems.empty?
- version = installed_gems.first.version
-
- install_rubygems version
+ install_rubygems installed_gems.first
end
def update_rubygems_arguments # :nodoc:
@@ -307,7 +293,7 @@ command to remove old versions.
args
end
- def which_to_update(highest_installed_gems, gem_names, system = false)
+ def which_to_update(highest_installed_gems, gem_names)
result = []
highest_installed_gems.each do |l_name, l_spec|
@@ -315,12 +301,9 @@ command to remove old versions.
gem_names.none? {|name| name == l_spec.name }
highest_remote_tup = highest_remote_name_tuple l_spec
- highest_remote_ver = highest_remote_tup.version
- highest_installed_ver = l_spec.version
+ next unless highest_remote_tup
- if system or (highest_installed_ver < highest_remote_ver)
- result << Gem::NameTuple.new(l_spec.name, [highest_installed_ver, highest_remote_ver].max, highest_remote_tup.platform)
- end
+ result << highest_remote_tup
end
result