summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-01 12:43:26 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-01 12:43:26 +0000
commita21d403f21473b21b5766c2483b4325240e9edda (patch)
treebd10197f9589251f35f0f9dc6fa387f0e298a6ef /lib/rubygems
parent94cfa2893ccab71341d4671201253339d56d6c97 (diff)
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.5.2.
It supports to enable frozen string literal and add `--norc` option for disable to `.gemrc` configuration. See 2.5.2 release notes for other fixes and enhancements. https://github.com/rubygems/rubygems/blob/a8aa3bac723f045c52471c7b9328310a048561e0/History.txt#L3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/available_set.rb2
-rw-r--r--lib/rubygems/basic_specification.rb9
-rw-r--r--lib/rubygems/command.rb10
-rw-r--r--lib/rubygems/command_manager.rb2
-rw-r--r--lib/rubygems/commands/build_command.rb6
-rw-r--r--lib/rubygems/commands/cert_command.rb2
-rw-r--r--lib/rubygems/commands/check_command.rb2
-rw-r--r--lib/rubygems/commands/cleanup_command.rb2
-rw-r--r--lib/rubygems/commands/contents_command.rb2
-rw-r--r--lib/rubygems/commands/dependency_command.rb6
-rw-r--r--lib/rubygems/commands/environment_command.rb7
-rw-r--r--lib/rubygems/commands/fetch_command.rb2
-rw-r--r--lib/rubygems/commands/generate_index_command.rb2
-rw-r--r--lib/rubygems/commands/help_command.rb2
-rw-r--r--lib/rubygems/commands/install_command.rb2
-rw-r--r--lib/rubygems/commands/list_command.rb2
-rw-r--r--lib/rubygems/commands/lock_command.rb2
-rw-r--r--lib/rubygems/commands/mirror_command.rb2
-rw-r--r--lib/rubygems/commands/open_command.rb2
-rw-r--r--lib/rubygems/commands/outdated_command.rb2
-rw-r--r--lib/rubygems/commands/owner_command.rb2
-rw-r--r--lib/rubygems/commands/pristine_command.rb2
-rw-r--r--lib/rubygems/commands/push_command.rb2
-rw-r--r--lib/rubygems/commands/query_command.rb18
-rw-r--r--lib/rubygems/commands/rdoc_command.rb2
-rw-r--r--lib/rubygems/commands/search_command.rb2
-rw-r--r--lib/rubygems/commands/server_command.rb2
-rw-r--r--lib/rubygems/commands/setup_command.rb2
-rw-r--r--lib/rubygems/commands/sources_command.rb2
-rw-r--r--lib/rubygems/commands/specification_command.rb2
-rw-r--r--lib/rubygems/commands/stale_command.rb2
-rw-r--r--lib/rubygems/commands/uninstall_command.rb2
-rw-r--r--lib/rubygems/commands/unpack_command.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb2
-rw-r--r--lib/rubygems/commands/which_command.rb2
-rw-r--r--lib/rubygems/commands/yank_command.rb27
-rw-r--r--lib/rubygems/compatibility.rb2
-rw-r--r--lib/rubygems/config_file.rb11
-rw-r--r--lib/rubygems/core_ext/kernel_gem.rb2
-rwxr-xr-xlib/rubygems/core_ext/kernel_require.rb2
-rw-r--r--lib/rubygems/defaults.rb2
-rw-r--r--lib/rubygems/dependency.rb6
-rw-r--r--lib/rubygems/dependency_installer.rb2
-rw-r--r--lib/rubygems/dependency_list.rb2
-rw-r--r--lib/rubygems/deprecate.rb2
-rw-r--r--lib/rubygems/doctor.rb2
-rw-r--r--lib/rubygems/errors.rb2
-rw-r--r--lib/rubygems/exceptions.rb5
-rw-r--r--lib/rubygems/ext.rb2
-rw-r--r--lib/rubygems/ext/build_error.rb2
-rw-r--r--lib/rubygems/ext/builder.rb2
-rw-r--r--lib/rubygems/ext/cmake_builder.rb2
-rw-r--r--lib/rubygems/ext/configure_builder.rb2
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb20
-rw-r--r--lib/rubygems/ext/rake_builder.rb2
-rw-r--r--lib/rubygems/gem_runner.rb2
-rw-r--r--lib/rubygems/gemcutter_utilities.rb13
-rw-r--r--lib/rubygems/indexer.rb2
-rw-r--r--lib/rubygems/install_default_message.rb2
-rw-r--r--lib/rubygems/install_message.rb2
-rw-r--r--lib/rubygems/install_update_options.rb7
-rw-r--r--lib/rubygems/installer.rb18
-rw-r--r--lib/rubygems/installer_test_case.rb2
-rw-r--r--lib/rubygems/local_remote_options.rb4
-rw-r--r--lib/rubygems/mock_gem_ui.rb2
-rw-r--r--lib/rubygems/name_tuple.rb4
-rw-r--r--lib/rubygems/package.rb6
-rw-r--r--lib/rubygems/package/digest_io.rb2
-rw-r--r--lib/rubygems/package/file_source.rb2
-rw-r--r--lib/rubygems/package/io_source.rb2
-rw-r--r--lib/rubygems/package/old.rb9
-rw-r--r--lib/rubygems/package/source.rb2
-rw-r--r--lib/rubygems/package/tar_header.rb2
-rw-r--r--lib/rubygems/package/tar_reader.rb2
-rw-r--r--lib/rubygems/package/tar_reader/entry.rb2
-rw-r--r--lib/rubygems/package/tar_test_case.rb2
-rw-r--r--lib/rubygems/package/tar_writer.rb2
-rw-r--r--lib/rubygems/package_task.rb2
-rw-r--r--lib/rubygems/path_support.rb21
-rw-r--r--lib/rubygems/platform.rb2
-rw-r--r--lib/rubygems/psych_additions.rb2
-rw-r--r--lib/rubygems/psych_tree.rb2
-rw-r--r--lib/rubygems/rdoc.rb2
-rw-r--r--lib/rubygems/remote_fetcher.rb2
-rw-r--r--lib/rubygems/request.rb6
-rw-r--r--lib/rubygems/request/connection_pools.rb2
-rw-r--r--lib/rubygems/request/http_pool.rb2
-rw-r--r--lib/rubygems/request/https_pool.rb2
-rw-r--r--lib/rubygems/request_set.rb23
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb61
-rw-r--r--lib/rubygems/request_set/lockfile.rb7
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb28
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb2
-rw-r--r--lib/rubygems/requirement.rb2
-rw-r--r--lib/rubygems/resolver.rb3
-rw-r--r--lib/rubygems/resolver/activation_request.rb24
-rw-r--r--lib/rubygems/resolver/api_set.rb2
-rw-r--r--lib/rubygems/resolver/api_specification.rb2
-rw-r--r--lib/rubygems/resolver/best_set.rb2
-rw-r--r--lib/rubygems/resolver/composed_set.rb2
-rw-r--r--lib/rubygems/resolver/conflict.rb2
-rw-r--r--lib/rubygems/resolver/current_set.rb2
-rw-r--r--lib/rubygems/resolver/dependency_request.rb2
-rw-r--r--lib/rubygems/resolver/git_set.rb2
-rw-r--r--lib/rubygems/resolver/git_specification.rb2
-rw-r--r--lib/rubygems/resolver/index_set.rb2
-rw-r--r--lib/rubygems/resolver/index_specification.rb2
-rw-r--r--lib/rubygems/resolver/installed_specification.rb2
-rw-r--r--lib/rubygems/resolver/installer_set.rb2
-rw-r--r--lib/rubygems/resolver/local_specification.rb2
-rw-r--r--lib/rubygems/resolver/lock_set.rb10
-rw-r--r--lib/rubygems/resolver/lock_specification.rb9
-rw-r--r--lib/rubygems/resolver/molinillo.rb2
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo.rb6
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb11
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb7
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb5
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb2
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb2
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb3
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb5
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/state.rb16
-rw-r--r--lib/rubygems/resolver/requirement_list.rb2
-rw-r--r--lib/rubygems/resolver/set.rb2
-rw-r--r--lib/rubygems/resolver/source_set.rb48
-rw-r--r--lib/rubygems/resolver/spec_specification.rb2
-rw-r--r--lib/rubygems/resolver/specification.rb2
-rw-r--r--lib/rubygems/resolver/stats.rb2
-rw-r--r--lib/rubygems/resolver/vendor_set.rb2
-rw-r--r--lib/rubygems/resolver/vendor_specification.rb2
-rw-r--r--lib/rubygems/security.rb2
-rw-r--r--lib/rubygems/security/policies.rb2
-rw-r--r--lib/rubygems/security/policy.rb5
-rw-r--r--lib/rubygems/security/signer.rb2
-rw-r--r--lib/rubygems/security/trust_dir.rb2
-rw-r--r--lib/rubygems/server.rb2
-rw-r--r--lib/rubygems/source.rb2
-rw-r--r--lib/rubygems/source/git.rb2
-rw-r--r--lib/rubygems/source/installed.rb2
-rw-r--r--lib/rubygems/source/local.rb2
-rw-r--r--lib/rubygems/source/lock.rb2
-rw-r--r--lib/rubygems/source/specific_file.rb2
-rw-r--r--lib/rubygems/source/vendor.rb2
-rw-r--r--lib/rubygems/source_list.rb4
-rw-r--r--lib/rubygems/source_local.rb2
-rw-r--r--lib/rubygems/source_specific_file.rb2
-rw-r--r--lib/rubygems/spec_fetcher.rb2
-rw-r--r--lib/rubygems/specification.rb18
-rw-r--r--lib/rubygems/stub_specification.rb2
-rw-r--r--lib/rubygems/syck_hack.rb2
-rw-r--r--lib/rubygems/test_case.rb19
-rw-r--r--lib/rubygems/test_utilities.rb2
-rw-r--r--lib/rubygems/text.rb3
-rw-r--r--lib/rubygems/uninstaller.rb2
-rw-r--r--lib/rubygems/uri_formatter.rb2
-rw-r--r--lib/rubygems/user_interaction.rb2
-rw-r--r--lib/rubygems/util.rb4
-rw-r--r--lib/rubygems/util/licenses.rb15
-rw-r--r--lib/rubygems/util/list.rb2
-rw-r--r--lib/rubygems/validator.rb2
-rw-r--r--lib/rubygems/version.rb7
-rw-r--r--lib/rubygems/version_option.rb2
162 files changed, 501 insertions, 289 deletions
diff --git a/lib/rubygems/available_set.rb b/lib/rubygems/available_set.rb
index da43cdf3fb..49b5d5fd06 100644
--- a/lib/rubygems/available_set.rb
+++ b/lib/rubygems/available_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
class Gem::AvailableSet
include Enumerable
diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb
index db962c6dcd..5c57076f91 100644
--- a/lib/rubygems/basic_specification.rb
+++ b/lib/rubygems/basic_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# BasicSpecification is an abstract class which implements some common code
# used by both Specification and StubSpecification.
@@ -125,9 +125,9 @@ class Gem::BasicSpecification
def full_name
if platform == Gem::Platform::RUBY or platform.nil? then
- "#{name}-#{version}".untaint
+ "#{name}-#{version}".dup.untaint
else
- "#{name}-#{version}-#{platform}".untaint
+ "#{name}-#{version}-#{platform}".dup.untaint
end
end
@@ -282,7 +282,7 @@ class Gem::BasicSpecification
self.require_paths.first
end
- "#{self.full_gem_path}/#{dirs}".untaint
+ "#{self.full_gem_path}/#{dirs}".dup.untaint
end
##
@@ -326,4 +326,3 @@ class Gem::BasicSpecification
end
end
-
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index 28af3d090c..5b41fc288e 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -154,7 +154,7 @@ class Gem::Command
def show_lookup_failure(gem_name, version, errors, domain)
if errors and !errors.empty?
- msg = "Could not find a valid gem '#{gem_name}' (#{version}), here is why:\n"
+ msg = "Could not find a valid gem '#{gem_name}' (#{version}), here is why:\n".dup
errors.each { |x| msg << " #{x.wordy}\n" }
alert_error msg
else
@@ -540,6 +540,11 @@ class Gem::Command
'Turn on Ruby debugging') do
end
+ add_common_option('--norc',
+ 'Avoid loading any .gemrc file') do
+ end
+
+
# :stopdoc:
HELP = <<-HELP
@@ -580,4 +585,3 @@ end
module Gem::Commands
end
-
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index 95e846e340..451b719c46 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index facc5226af..38c45e46f0 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/package'
@@ -42,6 +42,10 @@ with gem spec:
def execute
gemspec = get_one_gem_name
+ unless File.exist? gemspec
+ gemspec += '.gemspec' if File.exist? gemspec + '.gemspec'
+ end
+
if File.exist? gemspec then
spec = Gem::Specification.load gemspec
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index 073c6bd195..7adf5b01b1 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/security'
begin
diff --git a/lib/rubygems/commands/check_command.rb b/lib/rubygems/commands/check_command.rb
index 9d2b086951..818cb05f55 100644
--- a/lib/rubygems/commands/check_command.rb
+++ b/lib/rubygems/commands/check_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/validator'
diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb
index a0bb3d576a..46f89f1bb8 100644
--- a/lib/rubygems/commands/cleanup_command.rb
+++ b/lib/rubygems/commands/cleanup_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/dependency_list'
require 'rubygems/uninstaller'
diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb
index de756939c0..e0f2eedb5d 100644
--- a/lib/rubygems/commands/contents_command.rb
+++ b/lib/rubygems/commands/contents_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'English'
require 'rubygems/command'
require 'rubygems/version_option'
diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb
index b9e33a94e0..97fd812ffa 100644
--- a/lib/rubygems/commands/dependency_command.rb
+++ b/lib/rubygems/commands/dependency_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
@@ -100,7 +100,7 @@ use with other commands.
end
def display_readable specs, reverse # :nodoc:
- response = ''
+ response = String.new
specs.each do |spec|
response << print_dependencies(spec)
@@ -153,7 +153,7 @@ use with other commands.
end
def print_dependencies(spec, level = 0) # :nodoc:
- response = ''
+ response = String.new
response << ' ' * level + "Gem #{spec.full_name}\n"
unless spec.dependencies.empty? then
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb
index 47b62f03af..e825c761ad 100644
--- a/lib/rubygems/commands/environment_command.rb
+++ b/lib/rubygems/commands/environment_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
class Gem::Commands::EnvironmentCommand < Gem::Command
@@ -72,7 +72,7 @@ lib/rubygems/defaults/operating_system.rb
end
def execute
- out = ''
+ out = String.new
arg = options[:args][0]
out <<
case arg
@@ -104,7 +104,7 @@ lib/rubygems/defaults/operating_system.rb
end
def show_environment # :nodoc:
- out = "RubyGems Environment:\n"
+ out = "RubyGems Environment:\n".dup
out << " - RUBYGEMS VERSION: #{Gem::VERSION}\n"
@@ -158,4 +158,3 @@ lib/rubygems/defaults/operating_system.rb
end
end
-
diff --git a/lib/rubygems/commands/fetch_command.rb b/lib/rubygems/commands/fetch_command.rb
index 3aecdc3b08..19559a7774 100644
--- a/lib/rubygems/commands/fetch_command.rb
+++ b/lib/rubygems/commands/fetch_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
diff --git a/lib/rubygems/commands/generate_index_command.rb b/lib/rubygems/commands/generate_index_command.rb
index c0fadba64f..01f1f88405 100644
--- a/lib/rubygems/commands/generate_index_command.rb
+++ b/lib/rubygems/commands/generate_index_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/indexer'
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 4c176f372e..de3f175fad 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
class Gem::Commands::HelpCommand < Gem::Command
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 6e243df441..5f0934aa17 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/install_update_options'
require 'rubygems/dependency_installer'
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index 1f85cd3fcd..1acb49e5fb 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/commands/query_command'
diff --git a/lib/rubygems/commands/lock_command.rb b/lib/rubygems/commands/lock_command.rb
index 5a56e91933..3eebfadc05 100644
--- a/lib/rubygems/commands/lock_command.rb
+++ b/lib/rubygems/commands/lock_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
class Gem::Commands::LockCommand < Gem::Command
diff --git a/lib/rubygems/commands/mirror_command.rb b/lib/rubygems/commands/mirror_command.rb
index 3816876a92..801c9c8927 100644
--- a/lib/rubygems/commands/mirror_command.rb
+++ b/lib/rubygems/commands/mirror_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
unless defined? Gem::Commands::MirrorCommand
diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
index 63bff16db0..957d369b26 100644
--- a/lib/rubygems/commands/open_command.rb
+++ b/lib/rubygems/commands/open_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'English'
require 'rubygems/command'
require 'rubygems/version_option'
diff --git a/lib/rubygems/commands/outdated_command.rb b/lib/rubygems/commands/outdated_command.rb
index f7cfc08f70..70f6c02801 100644
--- a/lib/rubygems/commands/outdated_command.rb
+++ b/lib/rubygems/commands/outdated_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/spec_fetcher'
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index b002ff18d4..e507c988d6 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/gemcutter_utilities'
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 991272ae85..a5a348dc72 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/package'
require 'rubygems/installer'
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index a8e0819e82..035a03e5e7 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/gemcutter_utilities'
diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
index 4782eb98ef..d6196b44ed 100644
--- a/lib/rubygems/commands/query_command.rb
+++ b/lib/rubygems/commands/query_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/spec_fetcher'
@@ -50,6 +50,12 @@ class Gem::Commands::QueryCommand < Gem::Command
options[:all] = value
end
+ add_option('-e', '--exact',
+ 'Name of gem(s) to query on matches the',
+ 'provided STRING') do |value, options|
+ options[:exact] = value
+ end
+
add_option( '--[no-]prerelease',
'Display prerelease versions') do |value, options|
options[:prerelease] = value
@@ -79,7 +85,8 @@ is too hard to use.
elsif !options[:name].source.empty?
name = Array(options[:name])
else
- name = options[:args].to_a.map{|arg| /#{arg}/i }
+ args = options[:args].to_a
+ name = options[:exact] ? args : args.map{|arg| /#{arg}/i }
end
prerelease = options[:prerelease]
@@ -162,7 +169,7 @@ is too hard to use.
:latest
end
- if name.source.empty?
+ if name.respond_to?(:source) && name.source.empty?
spec_tuples = fetcher.detect(type) { true }
else
spec_tuples = fetcher.detect(type) do |name_tuple|
@@ -277,7 +284,7 @@ is too hard to use.
end
def spec_authors entry, spec
- authors = "Author#{spec.authors.length > 1 ? 's' : ''}: "
+ authors = "Author#{spec.authors.length > 1 ? 's' : ''}: ".dup
authors << spec.authors.join(', ')
entry << format_text(authors, 68, 4)
end
@@ -291,7 +298,7 @@ is too hard to use.
def spec_license entry, spec
return if spec.license.nil? or spec.license.empty?
- licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: "
+ licenses = "License#{spec.licenses.length > 1 ? 's' : ''}: ".dup
licenses << spec.licenses.join(', ')
entry << "\n" << format_text(licenses, 68, 4)
end
@@ -341,4 +348,3 @@ is too hard to use.
end
end
-
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index 72aa972017..6992040dca 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/rdoc'
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index 06cc997d4c..933436d84d 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/commands/query_command'
diff --git a/lib/rubygems/commands/server_command.rb b/lib/rubygems/commands/server_command.rb
index f41bda40da..245156d50d 100644
--- a/lib/rubygems/commands/server_command.rb
+++ b/lib/rubygems/commands/server_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/server'
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index d3ef9ef94e..ebb08d24d7 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
##
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index 0ff5e075f5..9832afd214 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/remote_fetcher'
require 'rubygems/spec_fetcher'
diff --git a/lib/rubygems/commands/specification_command.rb b/lib/rubygems/commands/specification_command.rb
index 4e291c6ab1..ad8840adc2 100644
--- a/lib/rubygems/commands/specification_command.rb
+++ b/lib/rubygems/commands/specification_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
diff --git a/lib/rubygems/commands/stale_command.rb b/lib/rubygems/commands/stale_command.rb
index 6930c1cfde..0524ee1e2b 100644
--- a/lib/rubygems/commands/stale_command.rb
+++ b/lib/rubygems/commands/stale_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
class Gem::Commands::StaleCommand < Gem::Command
diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb
index 52d4450bfb..fe97790194 100644
--- a/lib/rubygems/commands/uninstall_command.rb
+++ b/lib/rubygems/commands/uninstall_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/version_option'
require 'rubygems/uninstaller'
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index 08eaf01314..ffa429de6f 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/installer'
require 'rubygems/version_option'
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 8d76a8ce8e..d654a5fa4e 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/command_manager'
require 'rubygems/dependency_installer'
diff --git a/lib/rubygems/commands/which_command.rb b/lib/rubygems/commands/which_command.rb
index c01dc18ee0..c028d5d49f 100644
--- a/lib/rubygems/commands/which_command.rb
+++ b/lib/rubygems/commands/which_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
class Gem::Commands::WhichCommand < Gem::Command
diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb
index ec99bd7df6..0d6575b272 100644
--- a/lib/rubygems/commands/yank_command.rb
+++ b/lib/rubygems/commands/yank_command.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
require 'rubygems/local_remote_options'
require 'rubygems/version_option'
@@ -32,7 +32,7 @@ as the reason for the removal request.
end
def usage # :nodoc:
- "#{program_name} GEM -v VERSION [-p PLATFORM] [--undo] [--key KEY_NAME]"
+ "#{program_name} GEM -v VERSION [-p PLATFORM] [--key KEY_NAME] [--host HOST]"
end
def initialize
@@ -41,25 +41,25 @@ as the reason for the removal request.
add_version_option("remove")
add_platform_option("remove")
- add_option('--undo') do |value, options|
- options[:undo] = true
+ add_option('--host HOST',
+ 'Yank from another gemcutter-compatible host') do |value, options|
+ options[:host] = value
end
add_key_option
+ @host = nil
end
def execute
- sign_in
+ @host = options[:host]
+
+ sign_in @host
version = get_version_from_requirements(options[:version])
platform = get_platform_from_requirements(options)
if version then
- if options[:undo] then
- unyank_gem(version, platform)
- else
- yank_gem(version, platform)
- end
+ yank_gem(version, platform)
else
say "A version argument is required: #{usage}"
terminate_interaction
@@ -71,16 +71,11 @@ as the reason for the removal request.
yank_api_request(:delete, version, platform, "api/v1/gems/yank")
end
- def unyank_gem(version, platform)
- say "Unyanking gem from #{host}..."
- yank_api_request(:put, version, platform, "api/v1/gems/unyank")
- end
-
private
def yank_api_request(method, version, platform, api)
name = get_one_gem_name
- response = rubygems_api_request(method, api) do |request|
+ response = rubygems_api_request(method, api, host) do |request|
request.add_field("Authorization", api_key)
data = {
diff --git a/lib/rubygems/compatibility.rb b/lib/rubygems/compatibility.rb
index d09ddb6bf8..2056b5b53a 100644
--- a/lib/rubygems/compatibility.rb
+++ b/lib/rubygems/compatibility.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# :stopdoc:
#--
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 30f26db8c9..de90cbfd65 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -201,11 +201,12 @@ class Gem::ConfigFile
result.merge load_file file
end
-
@hash = operating_system_config.merge platform_config
- @hash = @hash.merge system_config
- @hash = @hash.merge user_config
- @hash = @hash.merge environment_config
+ unless arg_list.index '--norc'
+ @hash = @hash.merge system_config
+ @hash = @hash.merge user_config
+ @hash = @hash.merge environment_config
+ end
# HACK these override command-line args, which is bad
@backtrace = @hash[:backtrace] if @hash.key? :backtrace
diff --git a/lib/rubygems/core_ext/kernel_gem.rb b/lib/rubygems/core_ext/kernel_gem.rb
index 07376784e6..b0dd69bfcc 100644
--- a/lib/rubygems/core_ext/kernel_gem.rb
+++ b/lib/rubygems/core_ext/kernel_gem.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# RubyGems adds the #gem method to allow activation of specific gem versions
# and overrides the #require method on Kernel to make gems appear as if they
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 196db5b6ee..6c00f3fd9b 100755
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index c1d45c19e6..16fa96eb2d 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem
DEFAULT_HOST = "https://rubygems.org"
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index c0ab87d965..c7b2451c6a 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The Dependency class holds a Gem name and a Gem::Requirement.
@@ -307,9 +307,9 @@ class Gem::Dependency
if specs.empty?
total = Gem::Specification.to_a.size
- msg = "Could not find '#{name}' (#{requirement}) among #{total} total gem(s)\n"
+ msg = "Could not find '#{name}' (#{requirement}) among #{total} total gem(s)\n".dup
else
- msg = "Could not find '#{name}' (#{requirement}) - did find: [#{specs.join ','}]\n"
+ msg = "Could not find '#{name}' (#{requirement}) - did find: [#{specs.join ','}]\n".dup
end
msg << "Checked in 'GEM_PATH=#{Gem.path.join(File::PATH_SEPARATOR)}', execute `gem env` for more information"
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index 954e2bf984..28848f7373 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
require 'rubygems/dependency_list'
require 'rubygems/package'
diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
index 8e00dc94c8..35fe7c4c1a 100644
--- a/lib/rubygems/dependency_list.rb
+++ b/lib/rubygems/dependency_list.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb
index 54ab02830c..375194c1e8 100644
--- a/lib/rubygems/deprecate.rb
+++ b/lib/rubygems/deprecate.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Provides a single method +deprecate+ to be used to declare when
# something is going away.
diff --git a/lib/rubygems/doctor.rb b/lib/rubygems/doctor.rb
index 15f05f63fa..ec4a16c3f8 100644
--- a/lib/rubygems/doctor.rb
+++ b/lib/rubygems/doctor.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
require 'rubygems/user_interaction'
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb
index b22cd07706..8304647546 100644
--- a/lib/rubygems/errors.rb
+++ b/lib/rubygems/errors.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# This file contains all the various exceptions and other errors that are used
# inside of RubyGems.
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 0c741a2d01..9089eae4d5 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# TODO: the documentation in here is terrible.
#
# Each exception needs a brief description and the scenarios where it is
@@ -138,7 +138,7 @@ class Gem::ImpossibleDependenciesError < Gem::Exception
requester = requester ? requester.spec.full_name : 'The user'
dependency = @request.dependency
- message = "#{requester} requires #{dependency} but it conflicted:\n"
+ message = "#{requester} requires #{dependency} but it conflicted:\n".dup
@conflicts.each do |_, conflict|
message << conflict.explanation
@@ -268,4 +268,3 @@ end
# Backwards compatible typo'd exception class for early RubyGems 2.0.x
Gem::UnsatisfiableDepedencyError = Gem::UnsatisfiableDependencyError # :nodoc:
-
diff --git a/lib/rubygems/ext.rb b/lib/rubygems/ext.rb
index 4640b668f0..18d2bc233a 100644
--- a/lib/rubygems/ext.rb
+++ b/lib/rubygems/ext.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/ext/build_error.rb b/lib/rubygems/ext/build_error.rb
index 2098026b05..0b3c17a9a0 100644
--- a/lib/rubygems/ext/build_error.rb
+++ b/lib/rubygems/ext/build_error.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Raised when there is an error while building extensions.
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index d79b3a5901..699903ab0e 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/ext/cmake_builder.rb b/lib/rubygems/ext/cmake_builder.rb
index 7bf431c37e..efa3bd1d88 100644
--- a/lib/rubygems/ext/cmake_builder.rb
+++ b/lib/rubygems/ext/cmake_builder.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/command'
class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
diff --git a/lib/rubygems/ext/configure_builder.rb b/lib/rubygems/ext/configure_builder.rb
index b732cada57..8b42bf7ee9 100644
--- a/lib/rubygems/ext/configure_builder.rb
+++ b/lib/rubygems/ext/configure_builder.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index 2b50b08dc9..59e243b972 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -12,9 +12,20 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
FileEntry = FileUtils::Entry_ # :nodoc:
def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil)
- # relative path required as some versions of mktmpdir return an absolute
- # path which breaks make if it includes a space in the name
- tmp_dest = get_relative_path(Dir.mktmpdir(".gem.", "."))
+ tmp_dest = Dir.mktmpdir(".gem.", ".")
+
+ # Some versions of `mktmpdir` return absolute paths, which will break make
+ # if the paths contain spaces. However, on Ruby 1.9.x on Windows, relative
+ # paths cause all C extension builds to fail.
+ #
+ # As such, we convert to a relative path unless we are using Ruby 1.9.x on
+ # Windows. This means that when using Ruby 1.9.x on Windows, paths with
+ # spaces do not work.
+ #
+ # Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940
+ #
+ # TODO: Make this unconditional when rubygems no longer supports Ruby 1.9.x.
+ tmp_dest = get_relative_path(tmp_dest) unless Gem.win_platform? && RUBY_VERSION <= '2.0'
t = nil
Tempfile.open %w"siteconf .rb", "." do |siteconf|
@@ -81,4 +92,3 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
end
end
-
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 279117675a..682f1253e1 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/gem_runner.rb b/lib/rubygems/gem_runner.rb
index 2bf8ac68bf..fec9e403da 100644
--- a/lib/rubygems/gem_runner.rb
+++ b/lib/rubygems/gem_runner.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 98e78fe341..464993b11f 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/remote_fetcher'
##
@@ -69,9 +69,14 @@ module Gem::GemcutterUtilities
terminate_interaction 1 # TODO: question this
end
- if allowed_push_host and self.host != allowed_push_host
- alert_error "#{self.host.inspect} is not allowed by the gemspec, which only allows #{allowed_push_host.inspect}"
- terminate_interaction 1
+ if allowed_push_host
+ allowed_host_uri = URI.parse(allowed_push_host)
+ host_uri = URI.parse(self.host)
+
+ unless (host_uri.scheme == allowed_host_uri.scheme) && (host_uri.host == allowed_host_uri.host)
+ alert_error "#{self.host.inspect} is not allowed by the gemspec, which only allows #{allowed_push_host.inspect}"
+ terminate_interaction 1
+ end
end
uri = URI.parse "#{self.host}/#{path}"
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 21ccf0dfbb..871cc09d8d 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
require 'rubygems/package'
require 'time'
diff --git a/lib/rubygems/install_default_message.rb b/lib/rubygems/install_default_message.rb
index d20a6c71a3..dc73fd962b 100644
--- a/lib/rubygems/install_default_message.rb
+++ b/lib/rubygems/install_default_message.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
require 'rubygems/user_interaction'
diff --git a/lib/rubygems/install_message.rb b/lib/rubygems/install_message.rb
index da68b192b1..6880db583e 100644
--- a/lib/rubygems/install_message.rb
+++ b/lib/rubygems/install_message.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
require 'rubygems/user_interaction'
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index 0466583e42..26c5e84d1f 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -174,6 +174,11 @@ module Gem::InstallUpdateOptions
"meet version requirements") do |value, options|
options[:minimal_deps] = true
end
+
+ add_option(:"Install/Update", "--[no-]post-install-message",
+ "Print post install message") do |value, options|
+ options[:post_install_message] = value
+ end
end
##
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 7b4979d7ca..85358e0d1a 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -213,7 +213,13 @@ class Gem::Installer
next unless io.gets =~ /This file was generated by RubyGems/
ruby_executable = true
- existing = io.read.slice(/^gem (['"])(.*?)(\1),/, 2)
+ existing = io.read.slice(%r{
+ ^(
+ gem \s |
+ load \s Gem\.bin_path\(
+ )
+ (['"])(.*?)(\2),
+ }x, 3)
end
return if spec.name == existing
@@ -221,7 +227,7 @@ class Gem::Installer
# somebody has written to RubyGems' directory, overwrite, too bad
return if Gem.default_bindir != @bin_dir and not ruby_executable
- question = "#{spec.name}'s executable \"#{filename}\" conflicts with "
+ question = "#{spec.name}'s executable \"#{filename}\" conflicts with ".dup
if ruby_executable then
question << existing
@@ -297,7 +303,7 @@ class Gem::Installer
write_cache_file
end
- say spec.post_install_message unless spec.post_install_message.nil?
+ say spec.post_install_message if options[:post_install_message] && !spec.post_install_message.nil?
Gem::Installer.install_lock.synchronize { Gem::Specification.reset }
@@ -627,7 +633,8 @@ class Gem::Installer
:bin_dir => nil,
:env_shebang => false,
:force => false,
- :only_install_dir => false
+ :only_install_dir => false,
+ :post_install_message => true
}.merge options
@env_shebang = options[:env_shebang]
@@ -712,7 +719,6 @@ if ARGV.first
end
end
-gem '#{spec.name}', version
load Gem.bin_path('#{spec.name}', '#{bin_file_name}', version)
TEXT
end
diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb
index 7a1b0aa5f0..bdefedc9f6 100644
--- a/lib/rubygems/installer_test_case.rb
+++ b/lib/rubygems/installer_test_case.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems/installer'
diff --git a/lib/rubygems/local_remote_options.rb b/lib/rubygems/local_remote_options.rb
index 8d9e209771..597b87ea03 100644
--- a/lib/rubygems/local_remote_options.rb
+++ b/lib/rubygems/local_remote_options.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -24,7 +24,7 @@ module Gem::LocalRemoteOptions
raise OptionParser::InvalidArgument, value
end
- unless ['http', 'https', 'file'].include?(uri.scheme)
+ unless ['http', 'https', 'file', 's3'].include?(uri.scheme)
raise OptionParser::InvalidArgument, value
end
diff --git a/lib/rubygems/mock_gem_ui.rb b/lib/rubygems/mock_gem_ui.rb
index 32e154c8b3..0223f8c35d 100644
--- a/lib/rubygems/mock_gem_ui.rb
+++ b/lib/rubygems/mock_gem_ui.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'stringio'
require 'rubygems/user_interaction'
diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb
index 1dc7f74112..316329a0bd 100644
--- a/lib/rubygems/name_tuple.rb
+++ b/lib/rubygems/name_tuple.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
#
# Represents a gem of name +name+ at +version+ of +platform+. These
@@ -54,7 +54,7 @@ class Gem::NameTuple
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@platform}"
- end.untaint
+ end.dup.untaint
end
##
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 6b87475c78..35acec0bbb 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -1,5 +1,5 @@
+# frozen_string_literal: true
# -*- coding: utf-8 -*-
-# frozen_string_literal: false
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
@@ -59,7 +59,7 @@ class Gem::Package
if source
@path = source.path
- message << " in #{path}" if path
+ message = message + " in #{path}" if path
end
super message
@@ -383,7 +383,7 @@ EOM
FileUtils.chmod entry.header.mode, destination
end if entry.file?
- File.symlink(install_location(entry.header.linkname, destination_dir), destination) if entry.symlink?
+ File.symlink(entry.header.linkname, destination) if entry.symlink?
verbose destination
end
diff --git a/lib/rubygems/package/digest_io.rb b/lib/rubygems/package/digest_io.rb
index 47f76ec10d..4930c9aa7d 100644
--- a/lib/rubygems/package/digest_io.rb
+++ b/lib/rubygems/package/digest_io.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# IO wrapper that creates digests of contents written to the IO it wraps.
diff --git a/lib/rubygems/package/file_source.rb b/lib/rubygems/package/file_source.rb
index 4c2a7b9a4e..1a4dc4c824 100644
--- a/lib/rubygems/package/file_source.rb
+++ b/lib/rubygems/package/file_source.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The primary source of gems is a file on disk, including all usages
# internal to rubygems.
diff --git a/lib/rubygems/package/io_source.rb b/lib/rubygems/package/io_source.rb
index 16a6e4be8b..ee79a21083 100644
--- a/lib/rubygems/package/io_source.rb
+++ b/lib/rubygems/package/io_source.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Supports reading and writing gems from/to a generic IO object. This is
# useful for other applications built on top of rubygems, such as
diff --git a/lib/rubygems/package/old.rb b/lib/rubygems/package/old.rb
index 1f1f33b856..5e722baa35 100644
--- a/lib/rubygems/package/old.rb
+++ b/lib/rubygems/package/old.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -64,7 +64,7 @@ class Gem::Package::Old < Gem::Package
destination = install_location full_name, destination_dir
- file_data = ''
+ file_data = String.new
read_until_dashes io do |line|
file_data << line
@@ -95,7 +95,7 @@ class Gem::Package::Old < Gem::Package
# Reads the file list section from the old-format gem +io+
def file_list io # :nodoc:
- header = ''
+ header = String.new
read_until_dashes io do |line|
header << line
@@ -135,7 +135,7 @@ class Gem::Package::Old < Gem::Package
return @spec if @spec
- yaml = ''
+ yaml = String.new
@gem.with_read_io do |io|
skip_ruby io
@@ -176,4 +176,3 @@ class Gem::Package::Old < Gem::Package
end
end
-
diff --git a/lib/rubygems/package/source.rb b/lib/rubygems/package/source.rb
index 3dcce02a67..fe19776c38 100644
--- a/lib/rubygems/package/source.rb
+++ b/lib/rubygems/package/source.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
class Gem::Package::Source # :nodoc:
end
diff --git a/lib/rubygems/package/tar_header.rb b/lib/rubygems/package/tar_header.rb
index 71529ee978..4aa45d78d7 100644
--- a/lib/rubygems/package/tar_header.rb
+++ b/lib/rubygems/package/tar_header.rb
@@ -1,5 +1,5 @@
+# frozen_string_literal: true
# -*- coding: utf-8 -*-
-# frozen_string_literal: false
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
diff --git a/lib/rubygems/package/tar_reader.rb b/lib/rubygems/package/tar_reader.rb
index a1ea81cac4..d11bbe45f1 100644
--- a/lib/rubygems/package/tar_reader.rb
+++ b/lib/rubygems/package/tar_reader.rb
@@ -1,5 +1,5 @@
+# frozen_string_literal: true
# -*- coding: utf-8 -*-
-# frozen_string_literal: false
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
diff --git a/lib/rubygems/package/tar_reader/entry.rb b/lib/rubygems/package/tar_reader/entry.rb
index 59d167ee8e..3c4f52747a 100644
--- a/lib/rubygems/package/tar_reader/entry.rb
+++ b/lib/rubygems/package/tar_reader/entry.rb
@@ -1,5 +1,5 @@
+# frozen_string_literal: true
# -*- coding: utf-8 -*-
-# frozen_string_literal: false
#++
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
diff --git a/lib/rubygems/package/tar_test_case.rb b/lib/rubygems/package/tar_test_case.rb
index 3e494e5594..46ac949587 100644
--- a/lib/rubygems/package/tar_test_case.rb
+++ b/lib/rubygems/package/tar_test_case.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/test_case'
require 'rubygems/package'
diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb
index 6f1aab47a1..43a6e01d22 100644
--- a/lib/rubygems/package/tar_writer.rb
+++ b/lib/rubygems/package/tar_writer.rb
@@ -1,5 +1,5 @@
+# frozen_string_literal: true
# -*- coding: utf-8 -*-
-# frozen_string_literal: false
#--
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
diff --git a/lib/rubygems/package_task.rb b/lib/rubygems/package_task.rb
index 0c525ad517..d554e3697b 100644
--- a/lib/rubygems/package_task.rb
+++ b/lib/rubygems/package_task.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel
#
# Permission is hereby granted, free of charge, to any person obtaining
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb
index 0ec29f8b60..afb559d472 100644
--- a/lib/rubygems/path_support.rb
+++ b/lib/rubygems/path_support.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
#
# Gem::PathSupport facilitates the GEM_HOME and GEM_PATH environment settings
@@ -59,6 +59,9 @@ class Gem::PathSupport
gem_path = gpaths.dup
else
gem_path = gpaths.split(Gem.path_separator)
+ if gpaths.end_with?(Gem.path_separator)
+ gem_path += default_path
+ end
end
if File::ALT_SEPARATOR then
@@ -69,13 +72,19 @@ class Gem::PathSupport
gem_path << @home
else
- gem_path = Gem.default_path + [@home]
-
- if defined?(APPLE_GEM_HOME)
- gem_path << APPLE_GEM_HOME
- end
+ gem_path = default_path
end
@path = gem_path.uniq
end
+
+ # Return the default Gem path
+ def default_path
+ gem_path = Gem.default_path + [@home]
+
+ if defined?(APPLE_GEM_HOME)
+ gem_path << APPLE_GEM_HOME
+ end
+ gem_path
+ end
end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index cdc52cc9b3..d22d91ae54 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require "rubygems/deprecate"
##
diff --git a/lib/rubygems/psych_additions.rb b/lib/rubygems/psych_additions.rb
index 487b269903..1ddd74421c 100644
--- a/lib/rubygems/psych_additions.rb
+++ b/lib/rubygems/psych_additions.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# This exists just to satisfy bugs in marshal'd gemspecs that
# contain a reference to YAML::PrivateType. We prune these out
# in Specification._load, but if we don't have the constant, Marshal
diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb
index a5d306d769..41a7314b53 100644
--- a/lib/rubygems/psych_tree.rb
+++ b/lib/rubygems/psych_tree.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem
if defined? ::Psych::Visitors
class NoAliasYAMLTree < Psych::Visitors::YAMLTree
diff --git a/lib/rubygems/rdoc.rb b/lib/rubygems/rdoc.rb
index e9402ede76..7043bd2a31 100644
--- a/lib/rubygems/rdoc.rb
+++ b/lib/rubygems/rdoc.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
require 'rubygems/user_interaction'
require 'fileutils'
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index db1eed89d4..fda1e067ef 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
require 'rubygems/request'
require 'rubygems/uri_formatter'
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
index 3dfbc3d89c..7f2cb30e98 100644
--- a/lib/rubygems/request.rb
+++ b/lib/rubygems/request.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'net/http'
require 'thread'
require 'time'
@@ -156,7 +156,7 @@ class Gem::Request
if Net::HTTPOK === incomplete_response
reporter.fetch(file_name, incomplete_response.content_length)
downloaded = 0
- data = ''
+ data = String.new
incomplete_response.read_body do |segment|
data << segment
@@ -223,7 +223,7 @@ class Gem::Request
end
def user_agent
- ua = "RubyGems/#{Gem::VERSION} #{Gem::Platform.local}"
+ ua = "RubyGems/#{Gem::VERSION} #{Gem::Platform.local}".dup
ruby_version = RUBY_VERSION
ruby_version += 'dev' if RUBY_PATCHLEVEL == -1
diff --git a/lib/rubygems/request/connection_pools.rb b/lib/rubygems/request/connection_pools.rb
index d22e357257..31fc609800 100644
--- a/lib/rubygems/request/connection_pools.rb
+++ b/lib/rubygems/request/connection_pools.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'thread'
class Gem::Request::ConnectionPools # :nodoc:
diff --git a/lib/rubygems/request/http_pool.rb b/lib/rubygems/request/http_pool.rb
index ba3ab095bd..bfcd15399d 100644
--- a/lib/rubygems/request/http_pool.rb
+++ b/lib/rubygems/request/http_pool.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A connection "pool" that only manages one connection for now. Provides
# thread safe `checkout` and `checkin` methods. The pool consists of one
diff --git a/lib/rubygems/request/https_pool.rb b/lib/rubygems/request/https_pool.rb
index 3ab91faf61..e82c2440e1 100644
--- a/lib/rubygems/request/https_pool.rb
+++ b/lib/rubygems/request/https_pool.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
class Gem::Request::HTTPSPool < Gem::Request::HTTPPool # :nodoc:
private
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index b760a05d9b..5541e64b88 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'tsort'
##
@@ -78,6 +78,11 @@ class Gem::RequestSet
attr_reader :vendor_set # :nodoc:
##
+ # The set of source gems imported via load_gemdeps.
+
+ attr_reader :source_set
+
+ ##
# Creates a RequestSet for a list of Gem::Dependency objects, +deps+. You
# can then #resolve and #install the resolved list of dependencies.
#
@@ -106,6 +111,7 @@ class Gem::RequestSet
@sorted = nil
@specs = nil
@vendor_set = nil
+ @source_set = nil
yield self if block_given?
end
@@ -143,7 +149,6 @@ class Gem::RequestSet
return requests
end
- cache_dir = options[:cache_dir] || Gem.dir
@prerelease = options[:prerelease]
requests = []
@@ -158,13 +163,11 @@ class Gem::RequestSet
end
end
- path = req.download cache_dir
-
- inst = Gem::Installer.at path, options
-
- yield req, inst if block_given?
+ spec = req.spec.install options do |installer|
+ yield req, installer if block_given?
+ end
- requests << inst.install
+ requests << spec
end
return requests if options[:gemdeps]
@@ -272,10 +275,11 @@ class Gem::RequestSet
def load_gemdeps path, without_groups = [], installing = false
@git_set = Gem::Resolver::GitSet.new
@vendor_set = Gem::Resolver::VendorSet.new
+ @source_set = Gem::Resolver::SourceSet.new
@git_set.root_dir = @install_dir
- lock_file = "#{File.expand_path(path)}.lock".untaint
+ lock_file = "#{File.expand_path(path)}.lock".dup.untaint
begin
tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file
parser = tokenizer.make_parser self, []
@@ -339,6 +343,7 @@ class Gem::RequestSet
@sets << set
@sets << @git_set
@sets << @vendor_set
+ @sets << @source_set
set = Gem::Resolver.compose_sets(*@sets)
set.remote = @remote
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index 4927e5db6a..4b2699d7d2 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A semi-compatible DSL for the Bundler Gemfile and Isolate gem dependencies
# files.
@@ -205,6 +205,7 @@ class Gem::RequestSet::GemDependencyAPI
@installing = false
@requires = Hash.new { |h, name| h[name] = [] }
@vendor_set = @set.vendor_set
+ @source_set = @set.source_set
@gem_sources = {}
@without_groups = []
@@ -363,6 +364,7 @@ class Gem::RequestSet::GemDependencyAPI
source_set ||= gem_path name, options
source_set ||= gem_git name, options
source_set ||= gem_git_source name, options
+ source_set ||= gem_source name, options
duplicate = @dependencies.include? name
@@ -408,11 +410,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
pin_gem_source name, :git, repository
- reference = nil
- reference ||= options.delete :ref
- reference ||= options.delete :branch
- reference ||= options.delete :tag
- reference ||= 'master'
+ reference = gem_git_reference options
submodules = options.delete :submodules
@@ -421,6 +419,36 @@ Gem dependencies file #{@path} requires #{name} more than once.
true
end
+ ##
+ # Handles the git options from +options+ for git gem.
+ #
+ # Returns reference for the git gem.
+
+ def gem_git_reference options # :nodoc:
+ ref = options.delete :ref
+ branch = options.delete :branch
+ tag = options.delete :tag
+
+ reference = nil
+ reference ||= ref
+ reference ||= branch
+ reference ||= tag
+ reference ||= 'master'
+
+ if ref && branch
+ warn <<-WARNING
+Gem dependencies file #{@path} includes git reference for both ref and branch but only ref is used.
+ WARNING
+ end
+ if (ref||branch) && tag
+ warn <<-WARNING
+Gem dependencies file #{@path} includes git reference for both ref/branch and tag but only ref/branch is used.
+ WARNING
+ end
+
+ reference
+ end
+
private :gem_git
##
@@ -482,6 +510,23 @@ Gem dependencies file #{@path} requires #{name} more than once.
private :gem_path
##
+ # Handles the source: option from +options+ for gem +name+.
+ #
+ # Returns +true+ if the source option was handled.
+
+ def gem_source name, options # :nodoc:
+ return unless source = options.delete(:source)
+
+ pin_gem_source name, :source, source
+
+ @source_set.add_source_gem name, source
+
+ true
+ end
+
+ private :gem_source
+
+ ##
# Handles the platforms: option from +options+. Returns true if the
# platform matches the current platform.
@@ -527,6 +572,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
else
@requires[name] << name
end
+ raise ArgumentError, "Unhandled gem options #{options.inspect}" unless options.empty?
end
private :gem_requires
@@ -612,6 +658,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
add_dependencies groups, spec.development_dependencies
+ @vendor_set.add_vendor_gem spec.name, path
gem_requires spec.name, options
end
@@ -651,6 +698,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
when :default then '(default)'
when :path then "path: #{source}"
when :git then "git: #{source}"
+ when :source then "source: #{source}"
else '(unknown)'
end
@@ -799,4 +847,3 @@ Gem dependencies file #{@path} requires #{name} more than once.
Gem::RequestSet::GemDepedencyAPI = self # :nodoc:
end
-
diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
index e9a706e83b..7f6eadb939 100644
--- a/lib/rubygems/request_set/lockfile.rb
+++ b/lib/rubygems/request_set/lockfile.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Parses a gem.deps.rb.lock file and constructs a LockSet containing the
# dependencies found inside. If the lock file is missing no LockSet is
@@ -130,8 +130,8 @@ class Gem::RequestSet::Lockfile
[source.repository, source.rev_parse]
end
- out << "GIT"
by_repository_revision.each do |(repository, revision), requests|
+ out << "GIT"
out << " remote: #{repository}"
out << " revision: #{revision}"
out << " specs:"
@@ -144,9 +144,8 @@ class Gem::RequestSet::Lockfile
out << " #{dep.name}#{dep.requirement.for_lockfile}"
end
end
+ out << nil
end
-
- out << nil
end
def relative_path_from dest, base # :nodoc:
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
index 18aaadf3bb..ebea940188 100644
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ b/lib/rubygems/request_set/lockfile/parser.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
class Gem::RequestSet::Lockfile::Parser
###
# Parses lockfiles
@@ -325,15 +325,24 @@ class Gem::RequestSet::Lockfile::Parser
@tokens.peek
end
- def pinned_requirement name # :nodoc:
- spec = @set.sets.select { |set|
- Gem::Resolver::GitSet === set or
- Gem::Resolver::VendorSet === set
- }.map { |set|
- set.specs[name]
- }.compact.first
+ if [].respond_to? :flat_map
+ def pinned_requirement name # :nodoc:
+ requirement = Gem::Dependency.new name
+ specification = @set.sets.flat_map { |set|
+ set.find_all(requirement)
+ }.compact.first
- spec.version
+ specification && specification.version
+ end
+ else # FIXME: remove when 1.8 is dropped
+ def pinned_requirement name # :nodoc:
+ requirement = Gem::Dependency.new name
+ specification = @set.sets.map { |set|
+ set.find_all(requirement)
+ }.flatten(1).compact.first
+
+ specification && specification.version
+ end
end
##
@@ -343,4 +352,3 @@ class Gem::RequestSet::Lockfile::Parser
@tokens.unshift token
end
end
-
diff --git a/lib/rubygems/request_set/lockfile/tokenizer.rb b/lib/rubygems/request_set/lockfile/tokenizer.rb
index d68645d235..c9f1fac75b 100644
--- a/lib/rubygems/request_set/lockfile/tokenizer.rb
+++ b/lib/rubygems/request_set/lockfile/tokenizer.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'strscan'
require 'rubygems/request_set/lockfile/parser'
diff --git a/lib/rubygems/requirement.rb b/lib/rubygems/requirement.rb
index a33f67dafb..32dc769055 100644
--- a/lib/rubygems/requirement.rb
+++ b/lib/rubygems/requirement.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require "rubygems/version"
require "rubygems/deprecate"
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index 92dcab8e42..3a406d0444 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/dependency'
require 'rubygems/exceptions'
require 'rubygems/util'
@@ -279,6 +279,7 @@ require 'rubygems/resolver/index_set'
require 'rubygems/resolver/installer_set'
require 'rubygems/resolver/lock_set'
require 'rubygems/resolver/vendor_set'
+require 'rubygems/resolver/source_set'
require 'rubygems/resolver/specification'
require 'rubygems/resolver/spec_specification'
diff --git a/lib/rubygems/resolver/activation_request.rb b/lib/rubygems/resolver/activation_request.rb
index 2dd540cda0..135d75d6bc 100644
--- a/lib/rubygems/resolver/activation_request.rb
+++ b/lib/rubygems/resolver/activation_request.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Specifies a Specification object that should be activated. Also contains a
# dependency that was used to introduce this activation.
@@ -50,15 +50,27 @@ class Gem::Resolver::ActivationRequest
# Downloads a gem at +path+ and returns the file path.
def download path
- if @spec.respond_to? :source
+ Gem.ensure_gem_subdirectories path
+
+ if @spec.respond_to? :sources
+ exception = nil
+ path = @spec.sources.find{ |source|
+ begin
+ source.download full_spec, path
+ rescue exception
+ end
+ }
+ return path if path
+ raise exception if exception
+
+ elsif @spec.respond_to? :source
source = @spec.source
+ source.download full_spec, path
+
else
source = Gem.sources.first
+ source.download full_spec, path
end
-
- Gem.ensure_gem_subdirectories path
-
- source.download full_spec, path
end
##
diff --git a/lib/rubygems/resolver/api_set.rb b/lib/rubygems/resolver/api_set.rb
index 611c74ad10..ee3046af63 100644
--- a/lib/rubygems/resolver/api_set.rb
+++ b/lib/rubygems/resolver/api_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The global rubygems pool, available via the rubygems.org API.
# Returns instances of APISpecification.
diff --git a/lib/rubygems/resolver/api_specification.rb b/lib/rubygems/resolver/api_specification.rb
index e7ba38d614..1e22dd0b6f 100644
--- a/lib/rubygems/resolver/api_specification.rb
+++ b/lib/rubygems/resolver/api_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Represents a specification retrieved via the rubygems.org API.
#
diff --git a/lib/rubygems/resolver/best_set.rb b/lib/rubygems/resolver/best_set.rb
index c3c756c5e3..4479535abe 100644
--- a/lib/rubygems/resolver/best_set.rb
+++ b/lib/rubygems/resolver/best_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The BestSet chooses the best available method to query a remote index.
#
diff --git a/lib/rubygems/resolver/composed_set.rb b/lib/rubygems/resolver/composed_set.rb
index 66d927be2a..0b65942dca 100644
--- a/lib/rubygems/resolver/composed_set.rb
+++ b/lib/rubygems/resolver/composed_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A ComposedSet allows multiple sets to be queried like a single set.
#
diff --git a/lib/rubygems/resolver/conflict.rb b/lib/rubygems/resolver/conflict.rb
index 101923eb74..7997f92950 100644
--- a/lib/rubygems/resolver/conflict.rb
+++ b/lib/rubygems/resolver/conflict.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Used internally to indicate that a dependency conflicted
# with a spec that would be activated.
diff --git a/lib/rubygems/resolver/current_set.rb b/lib/rubygems/resolver/current_set.rb
index f8cec599de..265c639f15 100644
--- a/lib/rubygems/resolver/current_set.rb
+++ b/lib/rubygems/resolver/current_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A set which represents the installed gems. Respects
# all the normal settings that control where to look
diff --git a/lib/rubygems/resolver/dependency_request.rb b/lib/rubygems/resolver/dependency_request.rb
index ded554a85a..c2918911cd 100644
--- a/lib/rubygems/resolver/dependency_request.rb
+++ b/lib/rubygems/resolver/dependency_request.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Used Internally. Wraps a Dependency object to also track which spec
# contained the Dependency.
diff --git a/lib/rubygems/resolver/git_set.rb b/lib/rubygems/resolver/git_set.rb
index 2b5aae64c6..723a202d7a 100644
--- a/lib/rubygems/resolver/git_set.rb
+++ b/lib/rubygems/resolver/git_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A GitSet represents gems that are sourced from git repositories.
#
diff --git a/lib/rubygems/resolver/git_specification.rb b/lib/rubygems/resolver/git_specification.rb
index 507f346812..2448797d3f 100644
--- a/lib/rubygems/resolver/git_specification.rb
+++ b/lib/rubygems/resolver/git_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A GitSpecification represents a gem that is sourced from a git repository
# and is being loaded through a gem dependencies file through the +git:+
diff --git a/lib/rubygems/resolver/index_set.rb b/lib/rubygems/resolver/index_set.rb
index e7cd989095..2450f14b4f 100644
--- a/lib/rubygems/resolver/index_set.rb
+++ b/lib/rubygems/resolver/index_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The global rubygems pool represented via the traditional
# source index.
diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb
index 632a8a2d89..4340f46943 100644
--- a/lib/rubygems/resolver/index_specification.rb
+++ b/lib/rubygems/resolver/index_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Represents a possible Specification object returned from IndexSet. Used to
# delay needed to download full Specification objects when only the +name+
diff --git a/lib/rubygems/resolver/installed_specification.rb b/lib/rubygems/resolver/installed_specification.rb
index 06da6af3db..d9c6a5e5cf 100644
--- a/lib/rubygems/resolver/installed_specification.rb
+++ b/lib/rubygems/resolver/installed_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# An InstalledSpecification represents a gem that is already installed
# locally.
diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb
index d840b71711..1ed02e6f9f 100644
--- a/lib/rubygems/resolver/installer_set.rb
+++ b/lib/rubygems/resolver/installer_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A set of gems for installation sourced from remote sources and local .gem
# files
diff --git a/lib/rubygems/resolver/local_specification.rb b/lib/rubygems/resolver/local_specification.rb
index 76192e4c0b..1d9d22f0ac 100644
--- a/lib/rubygems/resolver/local_specification.rb
+++ b/lib/rubygems/resolver/local_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A LocalSpecification comes from a .gem file on the local filesystem.
diff --git a/lib/rubygems/resolver/lock_set.rb b/lib/rubygems/resolver/lock_set.rb
index fb581a1508..7fddc93e1c 100644
--- a/lib/rubygems/resolver/lock_set.rb
+++ b/lib/rubygems/resolver/lock_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A set of gems from a gem dependencies lockfile.
@@ -28,11 +28,9 @@ class Gem::Resolver::LockSet < Gem::Resolver::Set
def add name, version, platform # :nodoc:
version = Gem::Version.new version
-
- specs = @sources.map do |source|
- Gem::Resolver::LockSpecification.new self, name, version, source,
- platform
- end
+ specs = [
+ Gem::Resolver::LockSpecification.new(self, name, version, @sources, platform)
+ ]
@specs.concat specs
diff --git a/lib/rubygems/resolver/lock_specification.rb b/lib/rubygems/resolver/lock_specification.rb
index 0226878752..f485675673 100644
--- a/lib/rubygems/resolver/lock_specification.rb
+++ b/lib/rubygems/resolver/lock_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The LockSpecification comes from a lockfile (Gem::RequestSet::Lockfile).
#
@@ -7,13 +7,16 @@
class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
- def initialize set, name, version, source, platform
+ attr_reader :sources
+
+ def initialize set, name, version, sources, platform
super()
@name = name
@platform = platform
@set = set
- @source = source
+ @source = sources.first
+ @sources = sources
@version = version
@dependencies = []
diff --git a/lib/rubygems/resolver/molinillo.rb b/lib/rubygems/resolver/molinillo.rb
index 019536dc9b..2357f41bee 100644
--- a/lib/rubygems/resolver/molinillo.rb
+++ b/lib/rubygems/resolver/molinillo.rb
@@ -1,2 +1,2 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/resolver/molinillo/lib/molinillo'
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo.rb b/lib/rubygems/resolver/molinillo/lib/molinillo.rb
index 34dc7787dc..0ae4b6a912 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo.rb
@@ -1,6 +1,10 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/resolver/molinillo/lib/molinillo/gem_metadata'
require 'rubygems/resolver/molinillo/lib/molinillo/errors'
require 'rubygems/resolver/molinillo/lib/molinillo/resolver'
require 'rubygems/resolver/molinillo/lib/molinillo/modules/ui'
require 'rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider'
+
+# Gem::Resolver::Molinillo is a generic dependency resolution algorithm.
+module Gem::Resolver::Molinillo
+end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
index c3a1d5a2ef..deb4659448 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'set'
require 'tsort'
@@ -15,8 +15,10 @@ module Gem::Resolver::Molinillo
include TSort
+ # @visibility private
alias_method :tsort_each_node, :each
+ # @visibility private
def tsort_each_child(vertex, &block)
vertex.successors.each(&block)
end
@@ -42,12 +44,14 @@ module Gem::Resolver::Molinillo
# by {Vertex#name}
attr_reader :vertices
+ # Initializes an empty dependency graph
def initialize
@vertices = {}
end
# Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices}
# are properly copied.
+ # @param [DependencyGraph] other the graph to copy.
def initialize_copy(other)
super
@vertices = {}
@@ -101,6 +105,7 @@ module Gem::Resolver::Molinillo
vertex
end
+ # Adds a vertex with the given name, or updates the existing one.
# @param [String] name
# @param [Object] payload
# @return [Vertex] the vertex that was added to `self`
@@ -151,6 +156,8 @@ module Gem::Resolver::Molinillo
private
+ # Adds a new {Edge} to the dependency graph without checking for
+ # circularity.
def add_edge_no_circular(origin, destination, requirement)
edge = Edge.new(origin, destination, requirement)
origin.outgoing_edges << edge
@@ -175,6 +182,7 @@ module Gem::Resolver::Molinillo
attr_accessor :root
alias_method :root?, :root
+ # Initializes a vertex with the given name and payload.
# @param [String] name see {#name}
# @param [Object] payload see {#payload}
def initialize(name, payload)
@@ -241,6 +249,7 @@ module Gem::Resolver::Molinillo
successors.to_set == other.successors.to_set
end
+ # @param [Vertex] other the other vertex to compare to
# @return [Boolean] whether the two vertices are equal, determined
# solely by {#name} and {#payload} equality
def shallow_eql?(other)
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb
index 074ee9dd7d..3fad948392 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem::Resolver::Molinillo
# An error that occurred during the resolution process
class ResolverError < StandardError; end
@@ -12,6 +12,7 @@ module Gem::Resolver::Molinillo
# @return [Array<Object>] the specifications that depended upon {#dependency}
attr_accessor :required_by
+ # Initializes a new error with the given missing dependency.
# @param [Object] dependency @see {#dependency}
# @param [Array<Object>] required_by @see {#required_by}
def initialize(dependency, required_by = [])
@@ -20,6 +21,8 @@ module Gem::Resolver::Molinillo
super()
end
+ # The error message for the missing dependency, including the specifications
+ # that had this dependency.
def message
sources = required_by.map { |r| "`#{r}`" }.join(' and ')
message = "Unable to find a specification for `#{dependency}`"
@@ -37,6 +40,7 @@ module Gem::Resolver::Molinillo
# [Set<Object>] the dependencies responsible for causing the error
attr_reader :dependencies
+ # Initializes a new error with the given circular vertices.
# @param [Array<DependencyGraph::Vertex>] nodes the nodes in the dependency
# that caused the error
def initialize(nodes)
@@ -51,6 +55,7 @@ module Gem::Resolver::Molinillo
# resolution to fail
attr_reader :conflicts
+ # Initializes a new error with the given version conflicts.
# @param [{String => Resolution::Conflict}] conflicts see {#conflicts}
def initialize(conflicts)
pairs = []
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
index 8140c57a58..79cae2c697 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
@@ -1,4 +1,5 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem::Resolver::Molinillo
- VERSION = '0.4.0'
+ # The version of Gem::Resolver::Molinillo.
+ VERSION = '0.4.1'.freeze
end
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
index 10c655ac32..916345b12a 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem::Resolver::Molinillo
# Provides information about specifcations and dependencies to the resolver,
# allowing the {Resolver} class to remain generic while still providing power
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
index 100b694ebc..348ace286a 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem::Resolver::Molinillo
# Conveys information about the resolution process to a user.
module UI
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
index 5a0eb36849..0f822f0b82 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem::Resolver::Molinillo
class Resolver
# A specific resolution from a given {Resolver}
@@ -39,6 +39,7 @@ module Gem::Resolver::Molinillo
# @return [Array] the dependencies that were explicitly required
attr_reader :original_requested
+ # Initializes a new resolution.
# @param [SpecificationProvider] specification_provider
# see {#specification_provider}
# @param [UI] resolver_ui see {#resolver_ui}
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
index a92b3273ab..5c59a45c3d 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb
@@ -1,10 +1,10 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph'
module Gem::Resolver::Molinillo
# This class encapsulates a dependency resolver.
# The resolver is responsible for determining which set of dependencies to
- # activate, with feedback from the the {#specification_provider}
+ # activate, with feedback from the {#specification_provider}
#
#
class Resolver
@@ -18,6 +18,7 @@ module Gem::Resolver::Molinillo
# during the resolution process
attr_reader :resolver_ui
+ # Initializes a new resolver.
# @param [SpecificationProvider] specification_provider
# see {#specification_provider}
# @param [UI] resolver_ui
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
index 7bc9d98927..ac25538a5a 100644
--- a/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
+++ b/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
@@ -1,13 +1,13 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem::Resolver::Molinillo
# A state that a {Resolution} can be in
- # @attr [String] name
- # @attr [Array<Object>] requirements
- # @attr [DependencyGraph] activated
- # @attr [Object] requirement
- # @attr [Object] possibility
- # @attr [Integer] depth
- # @attr [Set<Object>] conflicts
+ # @attr [String] name the name of the current requirement
+ # @attr [Array<Object>] requirements currently unsatisfied requirements
+ # @attr [DependencyGraph] activated the graph of activated dependencies
+ # @attr [Object] requirement the current requirement
+ # @attr [Object] possibilities the possibilities to satisfy the current requirement
+ # @attr [Integer] depth the depth of the resolution
+ # @attr [Set<Object>] conflicts unresolved conflicts
ResolutionState = Struct.new(
:name,
:requirements,
diff --git a/lib/rubygems/resolver/requirement_list.rb b/lib/rubygems/resolver/requirement_list.rb
index 32f2ac5a99..2768c80170 100644
--- a/lib/rubygems/resolver/requirement_list.rb
+++ b/lib/rubygems/resolver/requirement_list.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The RequirementList is used to hold the requirements being considered
# while resolving a set of gems.
diff --git a/lib/rubygems/resolver/set.rb b/lib/rubygems/resolver/set.rb
index e2253abf3a..cc12633d46 100644
--- a/lib/rubygems/resolver/set.rb
+++ b/lib/rubygems/resolver/set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Resolver sets are used to look up specifications (and their
# dependencies) used in resolution. This set is abstract.
diff --git a/lib/rubygems/resolver/source_set.rb b/lib/rubygems/resolver/source_set.rb
new file mode 100644
index 0000000000..66f5963e54
--- /dev/null
+++ b/lib/rubygems/resolver/source_set.rb
@@ -0,0 +1,48 @@
+##
+# The SourceSet chooses the best available method to query a remote index.
+#
+# Kind off like BestSet but filters the sources for gems
+
+class Gem::Resolver::SourceSet < Gem::Resolver::Set
+
+ ##
+ # Creates a SourceSet for the given +sources+ or Gem::sources if none are
+ # specified. +sources+ must be a Gem::SourceList.
+
+ def initialize
+ super()
+
+ @links = {}
+ @sets = {}
+ end
+
+ def find_all req # :nodoc:
+ if set = get_set(req.dependency.name)
+ set.find_all req
+ else
+ []
+ end
+ end
+
+ # potentially no-op
+ def prefetch reqs # :nodoc:
+ reqs.each do |req|
+ if set = get_set(req.dependency.name)
+ set.prefetch reqs
+ end
+ end
+ end
+
+ def add_source_gem name, source
+ @links[name] = source
+ end
+
+private
+
+ def get_set(name)
+ link = @links[name]
+ @sets[link] ||= Gem::Source.new(link).dependency_resolver_set if link
+ end
+
+end
+
diff --git a/lib/rubygems/resolver/spec_specification.rb b/lib/rubygems/resolver/spec_specification.rb
index 00a0533bb5..35ee8cc247 100644
--- a/lib/rubygems/resolver/spec_specification.rb
+++ b/lib/rubygems/resolver/spec_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The Resolver::SpecSpecification contains common functionality for
# Resolver specifications that are backed by a Gem::Specification.
diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb
index 5833320660..44989d39ae 100644
--- a/lib/rubygems/resolver/specification.rb
+++ b/lib/rubygems/resolver/specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A Resolver::Specification contains a subset of the information
# contained in a Gem::Specification. Only the information necessary for
diff --git a/lib/rubygems/resolver/stats.rb b/lib/rubygems/resolver/stats.rb
index 4de766f2e1..3b95efebf7 100644
--- a/lib/rubygems/resolver/stats.rb
+++ b/lib/rubygems/resolver/stats.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
class Gem::Resolver::Stats
def initialize
@max_depth = 0
diff --git a/lib/rubygems/resolver/vendor_set.rb b/lib/rubygems/resolver/vendor_set.rb
index a006220ffe..f30ce534af 100644
--- a/lib/rubygems/resolver/vendor_set.rb
+++ b/lib/rubygems/resolver/vendor_set.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A VendorSet represents gems that have been unpacked into a specific
# directory that contains a gemspec.
diff --git a/lib/rubygems/resolver/vendor_specification.rb b/lib/rubygems/resolver/vendor_specification.rb
index ecf8e74def..c624f3e834 100644
--- a/lib/rubygems/resolver/vendor_specification.rb
+++ b/lib/rubygems/resolver/vendor_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A VendorSpecification represents a gem that has been unpacked into a project
# and is being loaded through a gem dependencies file through the +path:+
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index 941462d7bd..119d6d56f7 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/security/policies.rb b/lib/rubygems/security/policies.rb
index 05c6bbdb2a..f16c46306a 100644
--- a/lib/rubygems/security/policies.rb
+++ b/lib/rubygems/security/policies.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem::Security
##
diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb
index 0e13497b9d..f43e6c8c96 100644
--- a/lib/rubygems/security/policy.rb
+++ b/lib/rubygems/security/policy.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/user_interaction'
##
@@ -158,7 +158,7 @@ class Gem::Security::Policy
path = Gem::Security.trust_dir.cert_path root
unless File.exist? path then
- message = "root cert #{root.subject} is not trusted"
+ message = "root cert #{root.subject} is not trusted".dup
message << " (root of signing cert #{chain.last.subject})" if
chain.length > 1
@@ -293,4 +293,3 @@ class Gem::Security::Policy
alias to_s name # :nodoc:
end
-
diff --git a/lib/rubygems/security/signer.rb b/lib/rubygems/security/signer.rb
index a6d0161edc..1c9d9b7d3b 100644
--- a/lib/rubygems/security/signer.rb
+++ b/lib/rubygems/security/signer.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Basic OpenSSL-based package signing class.
diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb
index a032debf6e..bf44975cc6 100644
--- a/lib/rubygems/security/trust_dir.rb
+++ b/lib/rubygems/security/trust_dir.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The TrustDir manages the trusted certificates for gem signature
# verification.
diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
index d83a928571..8d6a96b1c2 100644
--- a/lib/rubygems/server.rb
+++ b/lib/rubygems/server.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'webrick'
require 'zlib'
require 'erb'
diff --git a/lib/rubygems/source.rb b/lib/rubygems/source.rb
index 7a58a441d2..85f5268fa3 100644
--- a/lib/rubygems/source.rb
+++ b/lib/rubygems/source.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'uri'
require 'fileutils'
diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb
index 7096ebe617..0900da0cbc 100644
--- a/lib/rubygems/source/git.rb
+++ b/lib/rubygems/source/git.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'digest'
require 'rubygems/util'
diff --git a/lib/rubygems/source/installed.rb b/lib/rubygems/source/installed.rb
index 3327010768..300491e467 100644
--- a/lib/rubygems/source/installed.rb
+++ b/lib/rubygems/source/installed.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Represents an installed gem. This is used for dependency resolution.
diff --git a/lib/rubygems/source/local.rb b/lib/rubygems/source/local.rb
index a320ff1c66..3227fb61b0 100644
--- a/lib/rubygems/source/local.rb
+++ b/lib/rubygems/source/local.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The local source finds gems in the current directory for fulfilling
# dependencies.
diff --git a/lib/rubygems/source/lock.rb b/lib/rubygems/source/lock.rb
index 98fef5a4d1..86b16e964c 100644
--- a/lib/rubygems/source/lock.rb
+++ b/lib/rubygems/source/lock.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A Lock source wraps an installed gem's source and sorts before other sources
# during dependency resolution. This allows RubyGems to prefer gems from
diff --git a/lib/rubygems/source/specific_file.rb b/lib/rubygems/source/specific_file.rb
index 790e424033..459c803e1a 100644
--- a/lib/rubygems/source/specific_file.rb
+++ b/lib/rubygems/source/specific_file.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# A source representing a single .gem file. This is used for installation of
# local gems.
diff --git a/lib/rubygems/source/vendor.rb b/lib/rubygems/source/vendor.rb
index 057d54ebea..e1b3698607 100644
--- a/lib/rubygems/source/vendor.rb
+++ b/lib/rubygems/source/vendor.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# This represents a vendored source that is similar to an installed gem.
diff --git a/lib/rubygems/source_list.rb b/lib/rubygems/source_list.rb
index add82f2327..942d657963 100644
--- a/lib/rubygems/source_list.rb
+++ b/lib/rubygems/source_list.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/source'
##
@@ -10,7 +10,7 @@ require 'rubygems/source'
# Or by adding them:
#
# sources = Gem::SourceList.new
-# sources.add 'https://rubygems.example'
+# sources << 'https://rubygems.example'
#
# The most common way to get a SourceList is Gem.sources.
diff --git a/lib/rubygems/source_local.rb b/lib/rubygems/source_local.rb
index d56b697718..07cb9e6e8f 100644
--- a/lib/rubygems/source_local.rb
+++ b/lib/rubygems/source_local.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/source'
require 'rubygems/source_local'
diff --git a/lib/rubygems/source_specific_file.rb b/lib/rubygems/source_specific_file.rb
index 2ae5792781..d42e6e7440 100644
--- a/lib/rubygems/source_specific_file.rb
+++ b/lib/rubygems/source_specific_file.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/source/specific_file'
# TODO warn upon require, this file is deprecated.
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index dbeecad243..755d4be1eb 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/remote_fetcher'
require 'rubygems/user_interaction'
require 'rubygems/errors'
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index ddba38da84..af8b5077a4 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1,5 +1,5 @@
+# frozen_string_literal: true
# -*- coding: utf-8 -*-
-# frozen_string_literal: false
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@@ -1192,6 +1192,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.normalize_yaml_input(input)
result = input.respond_to?(:read) ? input.read : input
result = "--- " + result unless result =~ /\A--- /
+ result = result.dup
result.gsub!(/ !!null \n/, " \n")
# date: 2011-04-26 00:00:00.000000000Z
# date: 2011-04-26 00:00:00.000000000 Z
@@ -2334,7 +2335,7 @@ class Gem::Specification < Gem::BasicSpecification
def ruby_code(obj)
case obj
- when String then obj.dump
+ when String then obj.dump + ".freeze"
when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
when Hash then
seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
@@ -2524,14 +2525,14 @@ class Gem::Specification < Gem::BasicSpecification
dependencies.each do |dep|
req = dep.requirements_list.inspect
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
- result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{req})"
+ result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
end
result << " else"
dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect
- result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
+ result << " s.add_dependency(%q<#{dep.name}>.freeze, #{version_reqs_param})"
end
result << ' end'
@@ -2539,7 +2540,7 @@ class Gem::Specification < Gem::BasicSpecification
result << " else"
dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect
- result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
+ result << " s.add_dependency(%q<#{dep.name}>.freeze, #{version_reqs_param})"
end
result << " end"
end
@@ -2761,10 +2762,13 @@ class Gem::Specification < Gem::BasicSpecification
end
if !Gem::Licenses.match?(license)
- warning <<-warning
-WARNING: license value '#{license}' is invalid. Use a license identifier from
+ suggestions = Gem::Licenses.suggestions(license)
+ message = <<-warning
+license value '#{license}' is invalid. Use a license identifier from
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
warning
+ message += "Did you mean #{suggestions.map { |s| "'#{s}'"}.join(', ')}?\n" unless suggestions.nil?
+ warning(message)
end
}
diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb
index 98ec7ce070..61df5a2262 100644
--- a/lib/rubygems/stub_specification.rb
+++ b/lib/rubygems/stub_specification.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# Gem::StubSpecification reads the stub: line from the gemspec. This prevents
# us having to eval the entire gemspec in order to find out certain
diff --git a/lib/rubygems/syck_hack.rb b/lib/rubygems/syck_hack.rb
index 0f49793ea1..051483eac8 100644
--- a/lib/rubygems/syck_hack.rb
+++ b/lib/rubygems/syck_hack.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# :stopdoc:
# Hack to handle syck's DefaultKey bug
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 3ffc608a1c..aebc36bc6c 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# TODO: $SAFE = 1
begin
@@ -542,7 +542,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
# Enables pretty-print for all tests
def mu_pp(obj)
- s = ''
+ s = String.new
s = PP.pp obj, s
s = s.force_encoding(Encoding.default_external) if defined? Encoding
s.chomp
@@ -1307,12 +1307,22 @@ Also, a list:
def vendor_gem name = 'a', version = 1
directory = File.join 'vendor', name
+ FileUtils.mkdir_p directory
+
+ save_gemspec name, version, directory
+ end
+
+ ##
+ # create_gemspec creates gem specification in given +direcotry+ or '.'
+ # for the given +name+ and +version+.
+ #
+ # Yields the +specification+ to the block, if given
+
+ def save_gemspec name = 'a', version = 1, directory = '.'
vendor_spec = Gem::Specification.new name, version do |specification|
yield specification if block_given?
end
- FileUtils.mkdir_p directory
-
open File.join(directory, "#{name}.gemspec"), 'w' do |io|
io.write vendor_spec.to_ruby
end
@@ -1483,3 +1493,4 @@ tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path"))
pid = $$
END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
Gem.clear_paths
+
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index bb633eb3cc..686916ea02 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'tempfile'
require 'rubygems'
require 'rubygems/remote_fetcher'
diff --git a/lib/rubygems/text.rb b/lib/rubygems/text.rb
index 470874621b..732f1b99f2 100644
--- a/lib/rubygems/text.rb
+++ b/lib/rubygems/text.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems'
##
@@ -71,4 +71,3 @@ module Gem::Text
return x
end
end
-
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
index b54eeba585..89f47a45fe 100644
--- a/lib/rubygems/uninstaller.rb
+++ b/lib/rubygems/uninstaller.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/uri_formatter.rb b/lib/rubygems/uri_formatter.rb
index bf0fc287a4..bb128e4ef9 100644
--- a/lib/rubygems/uri_formatter.rb
+++ b/lib/rubygems/uri_formatter.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'cgi'
require 'uri'
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 69eb26df5a..6c8534dd55 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index 76d8ad4bc1..ead2babc1f 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# This module contains various utility methods as module methods.
@@ -25,7 +25,7 @@ module Gem::Util
def self.gzip(data)
require 'zlib'
require 'stringio'
- zipped = StringIO.new('','w')
+ zipped = StringIO.new(String.new, 'w')
zipped.set_encoding Encoding::BINARY if Object.const_defined? :Encoding
Zlib::GzipWriter.wrap zipped do |io| io.write data end
diff --git a/lib/rubygems/util/licenses.rb b/lib/rubygems/util/licenses.rb
index 08ebd925f7..f4a99af39e 100644
--- a/lib/rubygems/util/licenses.rb
+++ b/lib/rubygems/util/licenses.rb
@@ -1,5 +1,9 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
+require 'rubygems/text'
+
class Gem::Licenses
+ extend Gem::Text
+
NONSTANDARD = 'Nonstandard'.freeze
# Software Package Data Exchange (SPDX) standard open-source software
@@ -327,4 +331,13 @@ class Gem::Licenses
def self.match?(license)
!REGEXP.match(license).nil?
end
+
+ def self.suggestions(license)
+ by_distance = IDENTIFIERS.group_by do |identifier|
+ levenshtein_distance(identifier, license)
+ end
+ lowest = by_distance.keys.min
+ return unless lowest < license.size
+ by_distance[lowest]
+ end
end
diff --git a/lib/rubygems/util/list.rb b/lib/rubygems/util/list.rb
index 83dc8497c4..9c25f6b6dc 100644
--- a/lib/rubygems/util/list.rb
+++ b/lib/rubygems/util/list.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Gem
class List
include Enumerable
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index 8a13e9911b..83448229bb 100644
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 8e37baa348..54da49e8e8 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
##
# The Version class processes string versions into comparable
# values. A version string should normally be a series of numbers
@@ -282,7 +282,10 @@ class Gem::Version
# A version is considered a prerelease if it contains a letter.
def prerelease?
- @prerelease ||= !!(@version =~ /[a-zA-Z]/)
+ unless instance_variable_defined? :@prerelease
+ @prerelease = !!(@version =~ /[a-zA-Z]/)
+ end
+ @prerelease
end
def pretty_print q # :nodoc:
diff --git a/lib/rubygems/version_option.rb b/lib/rubygems/version_option.rb
index a31cb14db4..3209d95f0f 100644
--- a/lib/rubygems/version_option.rb
+++ b/lib/rubygems/version_option.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.