Merge RubyGems/Bundler master

from bfb0ae6977
This commit is contained in:
Hiroshi SHIBATA 2022-12-12 09:09:23 +09:00
parent f1cdc129d4
commit bbe56a6437
Notes: git 2022-12-12 01:50:02 +00:00
58 changed files with 330 additions and 569 deletions

View File

@ -29,8 +29,8 @@ Gem::Specification.new do |s|
"source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler", "source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler",
} }
s.required_ruby_version = ">= 2.3.0" s.required_ruby_version = ">= 2.6.0"
s.required_rubygems_version = ">= 2.5.2" s.required_rubygems_version = ">= 3.0.1"
s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) } s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }

View File

@ -40,7 +40,7 @@ module Bundler
raise InvalidOption, "Please specify gems to add." if gems.empty? raise InvalidOption, "Please specify gems to add." if gems.empty?
version.to_a.each do |v| version.to_a.each do |v|
raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN =~ v.to_s raise InvalidOption, "Invalid gem requirement pattern '#{v}'" unless Gem::Requirement::PATTERN.match?(v.to_s)
end end
end end
end end

View File

@ -73,13 +73,11 @@ module Bundler
definition.specs.each do |spec| definition.specs.each do |spec|
bundles_for_gem(spec).each do |bundle| bundles_for_gem(spec).each do |bundle|
bad_paths = dylibs(bundle).select do |f| bad_paths = dylibs(bundle).select do |f|
begin
Fiddle.dlopen(f) Fiddle.dlopen(f)
false false
rescue Fiddle::DLError rescue Fiddle::DLError
true true
end end
end
if bad_paths.any? if bad_paths.any?
broken_links[spec] ||= [] broken_links[spec] ||= []
broken_links[spec].concat(bad_paths) broken_links[spec].concat(bad_paths)

View File

@ -270,7 +270,7 @@ module Bundler
Bundler.ui.info hint_text("test") Bundler.ui.info hint_text("test")
result = Bundler.ui.ask "Enter a test framework. rspec/minitest/test-unit/(none):" result = Bundler.ui.ask "Enter a test framework. rspec/minitest/test-unit/(none):"
if result =~ /rspec|minitest|test-unit/ if /rspec|minitest|test-unit/.match?(result)
test_framework = result test_framework = result
else else
test_framework = false test_framework = false
@ -311,7 +311,7 @@ module Bundler
Bundler.ui.info hint_text("ci") Bundler.ui.info hint_text("ci")
result = Bundler.ui.ask "Enter a CI service. github/travis/gitlab/circle/(none):" result = Bundler.ui.ask "Enter a CI service. github/travis/gitlab/circle/(none):"
if result =~ /github|travis|gitlab|circle/ if /github|travis|gitlab|circle/.match?(result)
ci_template = result ci_template = result
else else
ci_template = false ci_template = false
@ -342,7 +342,7 @@ module Bundler
Bundler.ui.info hint_text("linter") Bundler.ui.info hint_text("linter")
result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):" result = Bundler.ui.ask "Enter a linter. rubocop/standard/(none):"
if result =~ /rubocop|standard/ if /rubocop|standard/.match?(result)
linter_template = result linter_template = result
else else
linter_template = false linter_template = false
@ -389,7 +389,7 @@ module Bundler
end end
def ensure_safe_gem_name(name, constant_array) def ensure_safe_gem_name(name, constant_array)
if name =~ /^\d/ if /^\d/.match?(name)
Bundler.ui.error "Invalid gem name #{name} Please give a name which does not start with numbers." Bundler.ui.error "Invalid gem name #{name} Please give a name which does not start with numbers."
exit 1 exit 1
end end
@ -416,28 +416,15 @@ module Bundler
end end
def required_ruby_version def required_ruby_version
if Gem.ruby_version < Gem::Version.new("2.4.a") then "2.3.0"
elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "2.4.0"
elsif Gem.ruby_version < Gem::Version.new("2.6.a") then "2.5.0"
else
"2.6.0" "2.6.0"
end end
end
def rubocop_version def rubocop_version
if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.81.0"
elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.12"
else
"1.21" "1.21"
end end
end
def standard_version def standard_version
if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.2.5"
elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.0"
else
"1.3" "1.3"
end end
end end
end end
end

View File

@ -68,7 +68,7 @@ module Bundler
def info_path(name) def info_path(name)
name = name.to_s name = name.to_s
if name =~ /[^a-z0-9_-]/ if /[^a-z0-9_-]/.match?(name)
name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}" name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
info_roots.last.join(name) info_roots.last.join(name)
else else

View File

@ -20,14 +20,14 @@ module Bundler
def initialize(fetcher) def initialize(fetcher)
@fetcher = fetcher @fetcher = fetcher
require_relative "../vendored_tmpdir"
end end
def update(local_path, remote_path, retrying = nil) def update(local_path, remote_path, retrying = nil)
headers = {} headers = {}
Bundler::Dir.mktmpdir("bundler-compact-index-") do |local_temp_dir| local_temp_path = local_path.sub(/$/, ".#{$$}")
local_temp_path = Pathname.new(local_temp_dir).join(local_path.basename) local_temp_path = local_temp_path.sub(/$/, ".retrying") if retrying
local_temp_path = local_temp_path.sub(/$/, ".tmp")
# first try to fetch any new bytes on the existing file # first try to fetch any new bytes on the existing file
if retrying.nil? && local_path.file? if retrying.nil? && local_path.file?
@ -74,9 +74,10 @@ module Bundler
end end
update(local_path, remote_path, :retrying) update(local_path, remote_path, :retrying)
end
rescue Zlib::GzipFile::Error rescue Zlib::GzipFile::Error
raise Bundler::HTTPError raise Bundler::HTTPError
ensure
FileUtils.remove_file(local_temp_path) if File.exist?(local_temp_path)
end end
def etag_for(path) def etag_for(path)

View File

@ -295,7 +295,7 @@ module Bundler
# Convert to \r\n if the existing lock has them # Convert to \r\n if the existing lock has them
# i.e., Windows with `git config core.autocrlf=true` # i.e., Windows with `git config core.autocrlf=true`
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n") contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match?("\r\n")
if @locked_bundler_version if @locked_bundler_version
locked_major = @locked_bundler_version.segments.first locked_major = @locked_bundler_version.segments.first

View File

@ -324,7 +324,7 @@ module Bundler
if name.is_a?(Symbol) if name.is_a?(Symbol)
raise GemfileError, %(You need to specify gem names as Strings. Use 'gem "#{name}"' instead) raise GemfileError, %(You need to specify gem names as Strings. Use 'gem "#{name}"' instead)
end end
if name =~ /\s/ if /\s/.match?(name)
raise GemfileError, %('#{name}' is not a valid gem name because it contains whitespace) raise GemfileError, %('#{name}' is not a valid gem name because it contains whitespace)
end end
raise GemfileError, %(an empty gem name is not valid) if name.empty? raise GemfileError, %(an empty gem name is not valid) if name.empty?

View File

@ -12,7 +12,6 @@ module Bundler
method = instance_method(method_name) method = instance_method(method_name)
undef_method(method_name) undef_method(method_name)
define_method(method_name) do |*args, &blk| define_method(method_name) do |*args, &blk|
begin
method.bind(self).call(*args, &blk) method.bind(self).call(*args, &blk)
rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
raise HTTPError, e.message raise HTTPError, e.message
@ -24,7 +23,6 @@ module Bundler
nil nil
end end
end end
end
def specs(gem_names) def specs(gem_names)
specs_for_names(gem_names) specs_for_names(gem_names)

View File

@ -80,7 +80,7 @@ module Bundler
private private
def validate_uri_scheme!(uri) def validate_uri_scheme!(uri)
return if uri.scheme =~ /\Ahttps?\z/ return if /\Ahttps?\z/.match?(uri.scheme)
raise InvalidOption, raise InvalidOption,
"The request uri `#{uri}` has an invalid scheme (`#{uri.scheme}`). " \ "The request uri `#{uri}` has an invalid scheme (`#{uri.scheme}`). " \
"Did you mean `http` or `https`?" "Did you mean `http` or `https`?"

View File

@ -37,7 +37,7 @@ module Bundler
when Thor::Error when Thor::Error
Bundler.ui.error error.message Bundler.ui.error error.message
when LoadError when LoadError
raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/ raise error unless /cannot load such file -- openssl|openssl.so|libcrypto.so/.match?(error.message)
Bundler.ui.error "\nCould not load OpenSSL. #{error.class}: #{error}\n#{error.backtrace.join("\n ")}" Bundler.ui.error "\nCould not load OpenSSL. #{error.class}: #{error}\n#{error.backtrace.join("\n ")}"
when Interrupt when Interrupt
Bundler.ui.error "\nQuitting..." Bundler.ui.error "\nQuitting..."

View File

@ -235,7 +235,7 @@ module Bundler
gemfile.each_with_index do |line, index| gemfile.each_with_index do |line, index|
next unless !line.nil? && line.strip.start_with?(block_name) next unless !line.nil? && line.strip.start_with?(block_name)
if gemfile[index + 1] =~ /^\s*end\s*$/ if /^\s*end\s*$/.match?(gemfile[index + 1])
gemfile[index] = nil gemfile[index] = nil
gemfile[index + 1] = nil gemfile[index + 1] = nil
end end

View File

@ -136,11 +136,7 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w" mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb" require "erb"
content = if RUBY_VERSION >= "2.6" content = ERB.new(template, :trim_mode => "-").result(binding)
ERB.new(template, :trim_mode => "-").result(binding)
else
ERB.new(template, nil, "-").result(binding)
end
File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask) File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
if Gem.win_platform? || options[:all_platforms] if Gem.win_platform? || options[:all_platforms]
@ -183,11 +179,7 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w" mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb" require "erb"
content = if RUBY_VERSION >= "2.6" content = ERB.new(template, :trim_mode => "-").result(binding)
ERB.new(template, :trim_mode => "-").result(binding)
else
ERB.new(template, nil, "-").result(binding)
end
File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755) File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
if Gem.win_platform? || options[:all_platforms] if Gem.win_platform? || options[:all_platforms]
@ -226,12 +218,10 @@ module Bundler
requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) } requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.map do |spec| path_plugin_files = requested_path_gems.map do |spec|
begin
Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}") Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec" error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message raise Gem::InvalidSpecificationException, error_message
end
end.flatten end.flatten
Bundler.rubygems.load_plugin_files(path_plugin_files) Bundler.rubygems.load_plugin_files(path_plugin_files)
Bundler.rubygems.load_env_plugins Bundler.rubygems.load_env_plugins

View File

@ -63,7 +63,7 @@ module Bundler
@state = nil @state = nil
@specs = {} @specs = {}
if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/) if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \ raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
"Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock." "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
end end
@ -80,7 +80,7 @@ module Bundler
@state = :ruby @state = :ruby
elsif line == BUNDLED elsif line == BUNDLED
@state = :bundled_with @state = :bundled_with
elsif line =~ /^[^\s]/ elsif /^[^\s]/.match?(line)
@state = nil @state = nil
elsif @state elsif @state
send("parse_#{@state}", line) send("parse_#{@state}", line)

View File

@ -148,7 +148,6 @@ module Bundler
class TCPSocketProbe class TCPSocketProbe
def replies?(mirror) def replies?(mirror)
MirrorSockets.new(mirror).any? do |socket, address, timeout| MirrorSockets.new(mirror).any? do |socket, address, timeout|
begin
socket.connect_nonblock(address) socket.connect_nonblock(address)
rescue Errno::EINPROGRESS rescue Errno::EINPROGRESS
wait_for_writtable_socket(socket, address, timeout) wait_for_writtable_socket(socket, address, timeout)
@ -156,7 +155,6 @@ module Bundler
false false
end end
end end
end
private private

View File

@ -338,11 +338,7 @@ module Gem
end end
def glob_files_in_dir(glob, base_path) def glob_files_in_dir(glob, base_path)
if RUBY_VERSION >= "2.5"
Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) } Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }
else
Dir.glob(File.join(base_path.to_s.gsub(/[\[\]]/, '\\\\\\&'), glob)).map! {|f| File.expand_path(f) }
end
end end
end end
end end

View File

@ -64,7 +64,7 @@ module Bundler
at = if local? at = if local?
path path
elsif user_ref = options["ref"] elsif user_ref = options["ref"]
if ref =~ /\A[a-z0-9]{4,}\z/i if /\A[a-z0-9]{4,}\z/i.match?(ref)
shortref_for_display(user_ref) shortref_for_display(user_ref)
else else
user_ref user_ref
@ -295,7 +295,7 @@ module Bundler
end end
def uri_hash def uri_hash
if uri =~ %r{^\w+://(\w+@)?} if %r{^\w+://(\w+@)?}.match?(uri)
# Downcase the domain component of the URI # Downcase the domain component of the URI
# and strip off a trailing slash, if one is present # and strip off a trailing slash, if one is present
input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "") input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")

View File

@ -250,7 +250,7 @@ module Bundler
# Adds credentials to the URI # Adds credentials to the URI
def configured_uri def configured_uri
if /https?:/ =~ uri if /https?:/.match?(uri)
remote = Bundler::URI(uri) remote = Bundler::URI(uri)
config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host] config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
remote.userinfo ||= config_auth remote.userinfo ||= config_auth

View File

@ -224,13 +224,13 @@ module Bundler
# Some gem authors put absolute paths in their gemspec # Some gem authors put absolute paths in their gemspec
# and we have to save them from themselves # and we have to save them from themselves
spec.files = spec.files.map do |p| spec.files = spec.files.map do |path|
next p unless p =~ /\A#{Pathname::SEPARATOR_PAT}/ next path unless /\A#{Pathname::SEPARATOR_PAT}/.match?(path)
next if File.directory?(p) next if File.directory?(path)
begin begin
Pathname.new(p).relative_path_from(gem_dir).to_s Pathname.new(path).relative_path_from(gem_dir).to_s
rescue ArgumentError rescue ArgumentError
p path
end end
end.compact end.compact

View File

@ -145,7 +145,7 @@ module Bundler
end end
if installed?(spec) && !force if installed?(spec) && !force
print_using_message "Using #{version_message(spec)}" print_using_message "Using #{version_message(spec, options[:previous_spec])}"
return nil # no post-install message return nil # no post-install message
end end
@ -163,8 +163,6 @@ module Bundler
install_path = rubygems_dir install_path = rubygems_dir
bin_path = Bundler.system_bindir bin_path = Bundler.system_bindir
Bundler.mkdir_p bin_path unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
require_relative "../rubygems_gem_installer" require_relative "../rubygems_gem_installer"
installer = Bundler::RubyGemsGemInstaller.at( installer = Bundler::RubyGemsGemInstaller.at(
@ -340,7 +338,7 @@ module Bundler
def normalize_uri(uri) def normalize_uri(uri)
uri = uri.to_s uri = uri.to_s
uri = "#{uri}/" unless uri =~ %r{/$} uri = "#{uri}/" unless %r{/$}.match?(uri)
require_relative "../vendored_uri" require_relative "../vendored_uri"
uri = Bundler::URI(uri) uri = Bundler::URI(uri)
raise ArgumentError, "The source must be an absolute URI. For example:\n" \ raise ArgumentError, "The source must be an absolute URI. For example:\n" \
@ -383,7 +381,7 @@ module Bundler
idx = @allow_local ? installed_specs.dup : Index.new idx = @allow_local ? installed_specs.dup : Index.new
Dir["#{cache_path}/*.gem"].each do |gemfile| Dir["#{cache_path}/*.gem"].each do |gemfile|
next if gemfile =~ /^bundler\-[\d\.]+?\.gem/ next if /^bundler\-[\d\.]+?\.gem/.match?(gemfile)
s ||= Bundler.rubygems.spec_from_gem(gemfile) s ||= Bundler.rubygems.spec_from_gem(gemfile)
s.source = self s.source = self
idx << s idx << s

View File

@ -206,7 +206,7 @@ module Bundler
def warn_on_git_protocol(source) def warn_on_git_protocol(source)
return if Bundler.settings["git.allow_insecure"] return if Bundler.settings["git.allow_insecure"]
if source.uri =~ /^git\:/ if /^git\:/.match?(source.uri)
Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \ Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \
"which transmits data without encryption. Disable this warning with " \ "which transmits data without encryption. Disable this warning with " \
"`bundle config set --local git.allow_insecure true`, or switch to the `https` " \ "`bundle config set --local git.allow_insecure true`, or switch to the `https` " \

View File

@ -72,13 +72,7 @@ m = Module.new do
bundler_gem_version = Gem::Version.new(version) bundler_gem_version = Gem::Version.new(version)
requirement = bundler_gem_version.approximate_recommendation bundler_gem_version.approximate_recommendation
return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
requirement += ".a" if bundler_gem_version.prerelease?
requirement
end end
def load_bundler! def load_bundler!

View File

@ -1,154 +0,0 @@
# frozen_string_literal: true
#
# tmpdir - retrieve temporary directory path
#
# $Id$
#
require_relative '../../fileutils/lib/fileutils'
begin
require 'etc.so'
rescue LoadError # rescue LoadError for miniruby
end
class Bundler::Dir < Dir
@systmpdir ||= defined?(Etc.systmpdir) ? Etc.systmpdir : '/tmp'
##
# Returns the operating system's temporary file path.
def self.tmpdir
tmp = nil
['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @systmpdir], ['/tmp']*2, ['.']*2].each do |name, dir = ENV[name]|
next if !dir
dir = File.expand_path(dir)
stat = File.stat(dir) rescue next
case
when !stat.directory?
warn "#{name} is not a directory: #{dir}"
when !stat.writable?
warn "#{name} is not writable: #{dir}"
when stat.world_writable? && !stat.sticky?
warn "#{name} is world-writable: #{dir}"
else
tmp = dir
break
end
end
raise ArgumentError, "could not find a temporary directory" unless tmp
tmp
end
# Bundler::Dir.mktmpdir creates a temporary directory.
#
# The directory is created with 0700 permission.
# Application should not change the permission to make the temporary directory accessible from other users.
#
# The prefix and suffix of the name of the directory is specified by
# the optional first argument, <i>prefix_suffix</i>.
# - If it is not specified or nil, "d" is used as the prefix and no suffix is used.
# - If it is a string, it is used as the prefix and no suffix is used.
# - If it is an array, first element is used as the prefix and second element is used as a suffix.
#
# Bundler::Dir.mktmpdir {|dir| dir is ".../d..." }
# Bundler::Dir.mktmpdir("foo") {|dir| dir is ".../foo..." }
# Bundler::Dir.mktmpdir(["foo", "bar"]) {|dir| dir is ".../foo...bar" }
#
# The directory is created under Bundler::Dir.tmpdir or
# the optional second argument <i>tmpdir</i> if non-nil value is given.
#
# Bundler::Dir.mktmpdir {|dir| dir is "#{Bundler::Dir.tmpdir}/d..." }
# Bundler::Dir.mktmpdir(nil, "/var/tmp") {|dir| dir is "/var/tmp/d..." }
#
# If a block is given,
# it is yielded with the path of the directory.
# The directory and its contents are removed
# using Bundler::FileUtils.remove_entry before Bundler::Dir.mktmpdir returns.
# The value of the block is returned.
#
# Bundler::Dir.mktmpdir {|dir|
# # use the directory...
# open("#{dir}/foo", "w") { ... }
# }
#
# If a block is not given,
# The path of the directory is returned.
# In this case, Bundler::Dir.mktmpdir doesn't remove the directory.
#
# dir = Bundler::Dir.mktmpdir
# begin
# # use the directory...
# open("#{dir}/foo", "w") { ... }
# ensure
# # remove the directory.
# Bundler::FileUtils.remove_entry dir
# end
#
def self.mktmpdir(prefix_suffix=nil, *rest, **options)
base = nil
path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|p, _, _, d|
base = d
mkdir(p, 0700)
}
if block_given?
begin
yield path.dup
ensure
unless base
stat = File.stat(File.dirname(path))
if stat.world_writable? and !stat.sticky?
raise ArgumentError, "parent directory is world writable but not sticky"
end
end
Bundler::FileUtils.remove_entry path
end
else
path
end
end
module Tmpname # :nodoc:
module_function
def tmpdir
Bundler::Dir.tmpdir
end
UNUSABLE_CHARS = "^,-.0-9A-Z_a-z~"
class << (RANDOM = Random.new)
MAX = 36**6 # < 0x100000000
def next
rand(MAX).to_s(36)
end
end
private_constant :RANDOM
def create(basename, tmpdir=nil, max_try: nil, **opts)
origdir = tmpdir
tmpdir ||= tmpdir()
n = nil
prefix, suffix = basename
prefix = (String.try_convert(prefix) or
raise ArgumentError, "unexpected prefix: #{prefix.inspect}")
prefix = prefix.delete(UNUSABLE_CHARS)
suffix &&= (String.try_convert(suffix) or
raise ArgumentError, "unexpected suffix: #{suffix.inspect}")
suffix &&= suffix.delete(UNUSABLE_CHARS)
begin
t = Time.now.strftime("%Y%m%d")
path = "#{prefix}#{t}-#{$$}-#{RANDOM.next}"\
"#{n ? %[-#{n}] : ''}#{suffix||''}"
path = File.join(tmpdir, path)
yield(path, n, opts, origdir)
rescue Errno::EEXIST
n ||= 0
n += 1
retry if !max_try or n < max_try
raise "cannot generate temporary name using `#{basename}' under `#{tmpdir}'"
end
path
end
end
end

View File

@ -1,4 +0,0 @@
# frozen_string_literal: true
module Bundler; end
require_relative "vendor/tmpdir/lib/tmpdir"

View File

@ -87,14 +87,12 @@ module Bundler
creation_errors = [] creation_errors = []
@threads = Array.new(@size) do |i| @threads = Array.new(@size) do |i|
begin
Thread.start { process_queue(i) }.tap do |thread| Thread.start { process_queue(i) }.tap do |thread|
thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=) thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=)
end end
rescue ThreadError => e rescue ThreadError => e
creation_errors << e creation_errors << e
nil nil
end
end.compact end.compact
add_interrupt_handler unless @threads.empty? add_interrupt_handler unless @threads.empty?

View File

@ -107,7 +107,7 @@ class Gem::Commands::SetupCommand < Gem::Command
end end
def check_ruby_version def check_ruby_version
required_version = Gem::Requirement.new ">= 2.3.0" required_version = Gem::Requirement.new ">= 2.6.0"
unless required_version.satisfied_by? Gem.ruby_version unless required_version.satisfied_by? Gem.ruby_version
alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}" alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"

View File

@ -329,14 +329,8 @@ command to remove old versions.
Gem::Version.new("3.2.3") Gem::Version.new("3.2.3")
elsif Gem.ruby_version > Gem::Version.new("2.7.a") elsif Gem.ruby_version > Gem::Version.new("2.7.a")
Gem::Version.new("3.1.2") Gem::Version.new("3.1.2")
elsif Gem.ruby_version > Gem::Version.new("2.6.a")
Gem::Version.new("3.0.1")
elsif Gem.ruby_version > Gem::Version.new("2.5.a")
Gem::Version.new("2.7.3")
elsif Gem.ruby_version > Gem::Version.new("2.4.a")
Gem::Version.new("2.6.8")
else else
Gem::Version.new("2.5.2") Gem::Version.new("3.0.1")
end end
end end
end end

View File

@ -1,7 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# `uplevel` keyword argument of Kernel#warn is available since ruby 2.5. if !Gem::KERNEL_WARN_IGNORES_INTERNAL_ENTRIES
if RUBY_VERSION >= "2.5" && !Gem::KERNEL_WARN_IGNORES_INTERNAL_ENTRIES
module Kernel module Kernel
rubygems_path = "#{__dir__}/" # Frames to be skipped start with this path. rubygems_path = "#{__dir__}/" # Frames to be skipped start with this path.

View File

@ -433,13 +433,6 @@ module Gem::Security
ec_key ec_key
end end
##
# In Ruby 2.3 EC doesn't implement the private_key? but not the private? method
if defined?(OpenSSL::PKey::EC) && Gem::Version.new(String.new(RUBY_VERSION)) < Gem::Version.new("2.4.0")
OpenSSL::PKey::EC.send(:alias_method, :private?, :private_key?)
end
## ##
# Creates a self-signed certificate with an issuer and subject from +email+, # Creates a self-signed certificate with an issuer and subject from +email+,
# a subject alternative name of +email+ and the given +extensions+ for the # a subject alternative name of +email+ and the given +extensions+ for the
@ -492,13 +485,7 @@ module Gem::Security
when "rsa" when "rsa"
OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH) OpenSSL::PKey::RSA.new(RSA_DSA_KEY_LENGTH)
when "ec" when "ec"
if RUBY_VERSION >= "2.4.0"
OpenSSL::PKey::EC.generate(EC_NAME) OpenSSL::PKey::EC.generate(EC_NAME)
else
domain_key = OpenSSL::PKey::EC.new(EC_NAME)
domain_key.generate_key
domain_key
end
else else
raise Gem::Security::Exception, raise Gem::Security::Exception,
"#{algorithm} algorithm not found. RSA, DSA, and EC algorithms are supported." "#{algorithm} algorithm not found. RSA, DSA, and EC algorithms are supported."

View File

@ -97,11 +97,7 @@ module Gem::Util
# returning absolute paths to the matching files. # returning absolute paths to the matching files.
def self.glob_files_in_dir(glob, base_path) def self.glob_files_in_dir(glob, base_path)
if RUBY_VERSION >= "2.5"
Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) } Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) }
else
Dir.glob(File.expand_path(glob, base_path))
end
end end
## ##

View File

@ -15,10 +15,7 @@ else
require "bundler" require "bundler"
end end
# Workaround for non-activated bundler spec due to missing https://github.com/rubygems/rubygems/commit/4e306d7bcdee924b8d80ca9db6125aa59ee4e5a3 if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("3.0.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
gem "bundler", Bundler::VERSION if Gem.rubygems_version < Gem::Version.new("2.6.2")
if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("2.6.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
Bundler.ui.warn \ Bundler.ui.warn \
"Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \ "Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \
"`required_ruby_version` from working for Bundler. Any scripts that use " \ "`required_ruby_version` from working for Bundler. Any scripts that use " \

View File

@ -34,8 +34,6 @@ RSpec.describe Bundler::Env do
end end
it "prints user home" do it "prints user home" do
skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0"
with_clear_paths("HOME", "/a/b/c") do with_clear_paths("HOME", "/a/b/c") do
out = described_class.report out = described_class.report
expect(out).to include("User Home /a/b/c") expect(out).to include("User Home /a/b/c")
@ -43,8 +41,6 @@ RSpec.describe Bundler::Env do
end end
it "prints user path" do it "prints user path" do
skip "needs to use a valid HOME" if Gem.win_platform? && RUBY_VERSION < "2.6.0"
with_clear_paths("HOME", "/a/b/c") do with_clear_paths("HOME", "/a/b/c") do
allow(File).to receive(:exist?) allow(File).to receive(:exist?)
allow(File).to receive(:exist?).with("/a/b/c/.gem").and_return(true) allow(File).to receive(:exist?).with("/a/b/c/.gem").and_return(true)

View File

@ -143,7 +143,6 @@ RSpec.describe ".bundle/config" do
end end
it "has lower precedence than env" do it "has lower precedence than env" do
begin
ENV["BUNDLE_FOO"] = "env" ENV["BUNDLE_FOO"] = "env"
bundle "config set --global foo global" bundle "config set --global foo global"
@ -154,7 +153,6 @@ RSpec.describe ".bundle/config" do
ensure ensure
ENV.delete("BUNDLE_FOO") ENV.delete("BUNDLE_FOO")
end end
end
it "can be deleted" do it "can be deleted" do
bundle "config set --global foo global" bundle "config set --global foo global"
@ -221,7 +219,6 @@ RSpec.describe ".bundle/config" do
end end
it "has higher precedence than env" do it "has higher precedence than env" do
begin
ENV["BUNDLE_FOO"] = "env" ENV["BUNDLE_FOO"] = "env"
bundle "config set --local foo local" bundle "config set --local foo local"
@ -230,7 +227,6 @@ RSpec.describe ".bundle/config" do
ensure ensure
ENV.delete("BUNDLE_FOO") ENV.delete("BUNDLE_FOO")
end end
end
it "can be deleted" do it "can be deleted" do
bundle "config set --local foo local" bundle "config set --local foo local"

View File

@ -2,9 +2,7 @@
RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do
before do before do
graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4" realworld_system_gems "ruby-graphviz --version 1.2.5"
realworld_system_gems "ruby-graphviz --version #{graphviz_version}"
end end
it "graphs gems from the Gemfile" do it "graphs gems from the Gemfile" do

View File

@ -210,6 +210,33 @@ RSpec.describe "bundle install" do
expect(err).to be_empty expect(err).to be_empty
end end
it "prints the previous version when switching to a previously downloaded gem" do
build_repo4 do
build_gem "rails", "7.0.3"
build_gem "rails", "7.0.4"
end
bundle "config set path.system true"
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'rails', "7.0.4"
G
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'rails', "7.0.3"
G
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem 'rails', "7.0.4"
G
expect(out).to include("Using rails 7.0.4 (was 7.0.3)")
expect(err).to be_empty
end
it "can install dependencies with newer bundler version with system gems" do it "can install dependencies with newer bundler version with system gems" do
bundle "config set path.system true" bundle "config set path.system true"

View File

@ -1237,7 +1237,7 @@ RSpec.describe "bundle install with git sources" do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-RUBY s.write "ext/extconf.rb", <<-RUBY
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
create_makefile("foo") create_makefile("foo")
RUBY RUBY
s.write "ext/foo.c", "void Init_foo() {}" s.write "ext/foo.c", "void Init_foo() {}"

View File

@ -7,7 +7,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle" name = "c_extension_bundle"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" raise "OMG" unless with_config("c_extension") == "hello"
@ -52,7 +52,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle" name = "c_extension_bundle"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" raise "OMG" unless with_config("c_extension") == "hello"
@ -97,7 +97,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle_#{n}" name = "c_extension_bundle_#{n}"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension_#{n}") == "#{n}" raise "OMG" unless with_config("c_extension_#{n}") == "#{n}"
@ -150,7 +150,7 @@ RSpec.describe "installing a gem with native extensions" do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
name = "c_extension_bundle" name = "c_extension_bundle"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola" raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola"

View File

@ -589,8 +589,7 @@ RSpec.describe "major deprecations" do
context "bundle viz" do context "bundle viz" do
before do before do
graphviz_version = RUBY_VERSION >= "2.4" ? "1.2.5" : "1.2.4" realworld_system_gems "ruby-graphviz --version 1.2.5"
realworld_system_gems "ruby-graphviz --version #{graphviz_version}"
create_file "gems.rb", "source \"#{file_uri_for(gem_repo1)}\"" create_file "gems.rb", "source \"#{file_uri_for(gem_repo1)}\""
bundle "viz" bundle "viz"
end end

View File

@ -41,7 +41,7 @@ RSpec.describe "La biblioteca si misma" do
included = /ronn/ included = /ronn/
error_messages = [] error_messages = []
man_tracked_files.each do |filename| man_tracked_files.each do |filename|
next unless filename =~ included next unless filename&.match?(included)
error_messages << check_for_expendable_words(filename) error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename) error_messages << check_for_specific_pronouns(filename)
end end
@ -52,7 +52,7 @@ RSpec.describe "La biblioteca si misma" do
error_messages = [] error_messages = []
exempt = /vendor/ exempt = /vendor/
lib_tracked_files.each do |filename| lib_tracked_files.each do |filename|
next if filename =~ exempt next if filename&.match?(exempt)
error_messages << check_for_expendable_words(filename) error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename) error_messages << check_for_specific_pronouns(filename)
end end

View File

@ -12,7 +12,7 @@ RSpec.describe "The library itself" do
failing_lines = [] failing_lines = []
each_line(filename) do |line, number| each_line(filename) do |line, number|
failing_lines << number + 1 if line =~ merge_conflicts_regex failing_lines << number + 1 if line&.match?(merge_conflicts_regex)
end end
return if failing_lines.empty? return if failing_lines.empty?
@ -32,8 +32,8 @@ RSpec.describe "The library itself" do
def check_for_extra_spaces(filename) def check_for_extra_spaces(filename)
failing_lines = [] failing_lines = []
each_line(filename) do |line, number| each_line(filename) do |line, number|
next if line =~ /^\s+#.*\s+\n$/ next if /^\s+#.*\s+\n$/.match?(line)
failing_lines << number + 1 if line =~ /\s+\n$/ failing_lines << number + 1 if /\s+\n$/.match?(line)
end end
return if failing_lines.empty? return if failing_lines.empty?
@ -45,7 +45,7 @@ RSpec.describe "The library itself" do
failing_lines = [] failing_lines = []
each_line(filename) do |line, number| each_line(filename) do |line, number|
failing_lines << number + 1 if line =~ // failing_lines << number + 1 if //.match?(line)
end end
return if failing_lines.empty? return if failing_lines.empty?
@ -89,7 +89,7 @@ RSpec.describe "The library itself" do
exempt = /\.gitmodules|fixtures|vendor|LICENSE|vcr_cassettes|rbreadline\.diff|index\.txt$/ exempt = /\.gitmodules|fixtures|vendor|LICENSE|vcr_cassettes|rbreadline\.diff|index\.txt$/
error_messages = [] error_messages = []
tracked_files.each do |filename| tracked_files.each do |filename|
next if filename =~ exempt next if filename&.match?(exempt)
error_messages << check_for_tab_characters(filename) error_messages << check_for_tab_characters(filename)
error_messages << check_for_extra_spaces(filename) error_messages << check_for_extra_spaces(filename)
end end
@ -100,7 +100,7 @@ RSpec.describe "The library itself" do
exempt = /vendor|vcr_cassettes|LICENSE|rbreadline\.diff/ exempt = /vendor|vcr_cassettes|LICENSE|rbreadline\.diff/
error_messages = [] error_messages = []
tracked_files.each do |filename| tracked_files.each do |filename|
next if filename =~ exempt next if filename&.match?(exempt)
error_messages << check_for_straneous_quotes(filename) error_messages << check_for_straneous_quotes(filename)
end end
expect(error_messages.compact).to be_well_formed expect(error_messages.compact).to be_well_formed
@ -110,7 +110,7 @@ RSpec.describe "The library itself" do
error_messages = [] error_messages = []
exempt = %r{lock/lockfile_spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb} exempt = %r{lock/lockfile_spec|quality_spec|vcr_cassettes|\.ronn|lockfile_parser\.rb}
tracked_files.each do |filename| tracked_files.each do |filename|
next if filename =~ exempt next if filename&.match?(exempt)
error_messages << check_for_git_merge_conflicts(filename) error_messages << check_for_git_merge_conflicts(filename)
end end
expect(error_messages.compact).to be_well_formed expect(error_messages.compact).to be_well_formed
@ -120,7 +120,7 @@ RSpec.describe "The library itself" do
included = /ronn/ included = /ronn/
error_messages = [] error_messages = []
man_tracked_files.each do |filename| man_tracked_files.each do |filename|
next unless filename =~ included next unless filename&.match?(included)
error_messages << check_for_expendable_words(filename) error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename) error_messages << check_for_specific_pronouns(filename)
end end
@ -131,7 +131,7 @@ RSpec.describe "The library itself" do
error_messages = [] error_messages = []
exempt = /vendor|vcr_cassettes|CODE_OF_CONDUCT/ exempt = /vendor|vcr_cassettes|CODE_OF_CONDUCT/
lib_tracked_files.each do |filename| lib_tracked_files.each do |filename|
next if filename =~ exempt next if filename&.match?(exempt)
error_messages << check_for_expendable_words(filename) error_messages << check_for_expendable_words(filename)
error_messages << check_for_specific_pronouns(filename) error_messages << check_for_specific_pronouns(filename)
end end
@ -229,7 +229,7 @@ RSpec.describe "The library itself" do
exempt = %r{templates/|\.5|\.1|vendor/} exempt = %r{templates/|\.5|\.1|vendor/}
all_bad_requires = [] all_bad_requires = []
lib_tracked_files.each do |filename| lib_tracked_files.each do |filename|
next if filename =~ exempt next if filename&.match?(exempt)
each_line(filename) do |line, number| each_line(filename) do |line, number|
line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" } line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
end end

View File

@ -1304,11 +1304,7 @@ end
describe "default gem activation" do describe "default gem activation" do
let(:exemptions) do let(:exemptions) do
exempts = if Gem.rubygems_version >= Gem::Version.new("2.7") exempts = %w[did_you_mean bundler]
%w[did_you_mean]
else
%w[io-console openssl]
end << "bundler"
exempts << "uri" if Gem.ruby_version >= Gem::Version.new("2.7") exempts << "uri" if Gem.ruby_version >= Gem::Version.new("2.7")
exempts << "pathname" if Gem.ruby_version >= Gem::Version.new("3.0") exempts << "pathname" if Gem.ruby_version >= Gem::Version.new("3.0")
exempts << "set" unless Gem.rubygems_version >= Gem::Version.new("3.2.6") exempts << "set" unless Gem.rubygems_version >= Gem::Version.new("3.2.6")

View File

@ -96,7 +96,6 @@ RSpec.configure do |config|
end end
config.around :each do |example| config.around :each do |example|
begin
FileUtils.cp_r pristine_system_gem_path, system_gem_path FileUtils.cp_r pristine_system_gem_path, system_gem_path
with_gem_path_as(system_gem_path) do with_gem_path_as(system_gem_path) do
@ -113,7 +112,6 @@ RSpec.configure do |config|
ensure ensure
reset! reset!
end end
end
config.after :suite do config.after :suite do
FileUtils.rm_r Spec::Path.pristine_system_gem_path FileUtils.rm_r Spec::Path.pristine_system_gem_path

View File

@ -456,7 +456,7 @@ module Spec
write "ext/extconf.rb", <<-RUBY write "ext/extconf.rb", <<-RUBY
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4" $extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"]
extension_name = "#{name}_c" extension_name = "#{name}_c"
if extra_lib_dir = with_config("ext-lib") if extra_lib_dir = with_config("ext-lib")

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
require "rubygems" require "rubygems"
Gem.instance_variable_set(:@ruby, ENV["RUBY"]) if ENV["RUBY"]
require_relative "path" require_relative "path"
bundler_gemspec = Spec::Path.loaded_gemspec bundler_gemspec = Spec::Path.loaded_gemspec
bundler_gemspec.instance_variable_set(:@full_gem_path, Spec::Path.source_root) bundler_gemspec.instance_variable_set(:@full_gem_path, Spec::Path.source_root)

View File

@ -33,11 +33,4 @@ module Gem
if ENV["BUNDLER_SPEC_GEM_SOURCES"] if ENV["BUNDLER_SPEC_GEM_SOURCES"]
self.sources = [ENV["BUNDLER_SPEC_GEM_SOURCES"]] self.sources = [ENV["BUNDLER_SPEC_GEM_SOURCES"]]
end end
# We only need this hack for rubygems versions without the BundlerVersionFinder
if Gem.rubygems_version < Gem::Version.new("2.7.0")
@path_to_default_spec_map.delete_if do |_path, spec|
spec.name == "bundler"
end
end
end end

View File

@ -290,7 +290,7 @@ module Spec
if gem_name.start_with?("bundler") if gem_name.start_with?("bundler")
version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler" version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler"
with_built_bundler(version) {|gem_path| install_gem(gem_path, default) } with_built_bundler(version) {|gem_path| install_gem(gem_path, default) }
elsif gem_name =~ %r{\A(?:[a-zA-Z]:)?/.*\.gem\z} elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name)
install_gem(gem_name, default) install_gem(gem_name, default)
else else
install_gem("#{gem_repo}/gems/#{gem_name}.gem", default) install_gem("#{gem_repo}/gems/#{gem_name}.gem", default)
@ -486,10 +486,10 @@ module Spec
Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".") Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".")
end end
# versions providing a bundler version finder but not including # versions not including
# https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1 # https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1
def rubygems_version_failing_to_activate_bundler_prereleases def rubygems_version_failing_to_activate_bundler_prereleases
Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1") && Gem.rubygems_version >= Gem::Version.new("2.7.0") Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1")
end end
def revision_for(path) def revision_for(path)

View File

@ -126,7 +126,7 @@ module Spec
next if version == v("1.4.2.1") && platform != pl("x86-mswin32") next if version == v("1.4.2.1") && platform != pl("x86-mswin32")
next if version == v("1.4.2") && platform == pl("x86-mswin32") next if version == v("1.4.2") && platform == pl("x86-mswin32")
gem "nokogiri", version, platform do gem "nokogiri", version, platform do
dep "weakling", ">= 0.0.3" if platform =~ pl("java") dep "weakling", ">= 0.0.3" if platform =~ pl("java") # rubocop:disable Performance/RegexpMatch
end end
end end
end end

View File

@ -295,25 +295,11 @@ module Spec
end end
def rubocop_gemfile_basename def rubocop_gemfile_basename
filename = if RUBY_VERSION.start_with?("2.3") source_root.join("tool/bundler/rubocop_gems.rb")
"rubocop23_gems"
elsif RUBY_VERSION.start_with?("2.4")
"rubocop24_gems"
else
"rubocop_gems"
end
tool_dir.join("#{filename}.rb")
end end
def standard_gemfile_basename def standard_gemfile_basename
filename = if RUBY_VERSION.start_with?("2.3") source_root.join("tool/bundler/standard_gems.rb")
"standard23_gems"
elsif RUBY_VERSION.start_with?("2.4")
"standard24_gems"
else
"standard_gems"
end
tool_dir.join("#{filename}.rb")
end end
def tool_dir def tool_dir

View File

@ -113,7 +113,7 @@ class RubygemsVersionManager
end end
def resolve_target_tag def resolve_target_tag
return "v#{@source}" if @source.match(/^\d/) return "v#{@source}" if @source.match?(/^\d/)
@source @source
end end

View File

@ -2061,13 +2061,8 @@ You may need to `bundle install` to install missing gems
end end
def redefine_method(base, method, new_result) def redefine_method(base, method, new_result)
if RUBY_VERSION >= "2.5"
base.alias_method(method, method) base.alias_method(method, method)
base.define_method(method) { new_result } base.define_method(method) { new_result }
else
base.send(:alias_method, method, method)
base.send(:define_method, method) { new_result }
end
end end
def with_plugin(path) def with_plugin(path)

View File

@ -76,7 +76,7 @@ class TestGemCommandManager < Gem::TestCase
message = "Unknown command pish".dup message = "Unknown command pish".dup
if RUBY_VERSION >= "2.4" && defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable) if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
message << "\nDid you mean? \"push\"" message << "\nDid you mean? \"push\""
end end

View File

@ -83,7 +83,7 @@ class TestGemRequirement < Gem::TestCase
Gem::Requirement.parse(Gem::Version.new("2")) Gem::Requirement.parse(Gem::Version.new("2"))
end end
if RUBY_VERSION >= "2.5" && !(Gem.java_platform? && ENV["JRUBY_OPTS"].to_s.include?("--debug")) if !(Gem.java_platform? && ENV["JRUBY_OPTS"].to_s.include?("--debug"))
def test_parse_deduplication def test_parse_deduplication
assert_same "~>", Gem::Requirement.parse("~> 1").first assert_same "~>", Gem::Requirement.parse("~> 1").first
end end

View File

@ -596,8 +596,6 @@ class TestGemRequire < Gem::TestCase
assert_empty unresolved_names assert_empty unresolved_names
end end
# uplevel is 2.5+ only
if RUBY_VERSION >= "2.5"
["", "Kernel."].each do |prefix| ["", "Kernel."].each do |prefix|
define_method "test_no_kernel_require_in_#{prefix.tr(".", "_")}warn_with_uplevel" do define_method "test_no_kernel_require_in_#{prefix.tr(".", "_")}warn_with_uplevel" do
Dir.mktmpdir("warn_test") do |dir| Dir.mktmpdir("warn_test") do |dir|
@ -667,7 +665,6 @@ class TestGemRequire < Gem::TestCase
assert_match(/main\.rb:2: warning: This is a deprecated method$/, err) assert_match(/main\.rb:2: warning: This is a deprecated method$/, err)
end end
end end
end
private private

View File

@ -2,17 +2,16 @@
source "https://rubygems.org" source "https://rubygems.org"
gem "rdoc", "6.2.0" # 6.2.1 is required > Ruby 2.3
gem "test-unit", "~> 3.0" gem "test-unit", "~> 3.0"
gem "rake", "~> 13.0" gem "rake", "~> 13.0"
gem "webrick", "~> 1.6" gem "webrick", "~> 1.6"
gem "parallel_tests", "~> 2.29" gem "parallel_tests", "~> 2.29"
gem "parallel", "1.19.2" # 1.20+ is required > Ruby 2.3 gem "parallel", "~> 1.19"
gem "rspec-core", "~> 3.12" gem "rspec-core", "~> 3.12"
gem "rspec-expectations", "~> 3.12" gem "rspec-expectations", "~> 3.12"
gem "rspec-mocks", "~> 3.12" gem "rspec-mocks", "~> 3.12"
gem "uri", "~> 0.10.1" gem "uri", "~> 0.12.0"
group :doc do group :doc do
gem "ronn", "~> 0.7.3", :platform => :ruby gem "ronn", "~> 0.7.3", :platform => :ruby

View File

@ -5,13 +5,12 @@ GEM
hpricot (0.8.6) hpricot (0.8.6)
hpricot (0.8.6-java) hpricot (0.8.6-java)
mustache (1.1.1) mustache (1.1.1)
parallel (1.19.2) parallel (1.22.1)
parallel_tests (2.32.0) parallel_tests (2.32.0)
parallel parallel
power_assert (2.0.1) power_assert (2.0.2)
rake (13.0.6) rake (13.0.6)
rdiscount (2.2.0.2) rdiscount (2.2.7)
rdoc (6.2.0)
ronn (0.7.3) ronn (0.7.3)
hpricot (>= 0.8.2) hpricot (>= 0.8.2)
mustache (>= 0.7.0) mustache (>= 0.7.0)
@ -21,13 +20,13 @@ GEM
rspec-expectations (3.12.0) rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0) rspec-support (~> 3.12.0)
rspec-mocks (3.12.0) rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0) rspec-support (~> 3.12.0)
rspec-support (3.12.0) rspec-support (3.12.0)
test-unit (3.5.3) test-unit (3.5.5)
power_assert power_assert
uri (0.10.1) uri (0.12.0)
webrick (1.7.0) webrick (1.7.0)
PLATFORMS PLATFORMS
@ -41,16 +40,15 @@ PLATFORMS
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES
parallel (= 1.19.2) parallel (~> 1.19)
parallel_tests (~> 2.29) parallel_tests (~> 2.29)
rake (~> 13.0) rake (~> 13.0)
rdoc (= 6.2.0)
ronn (~> 0.7.3) ronn (~> 0.7.3)
rspec-core (~> 3.12) rspec-core (~> 3.12)
rspec-expectations (~> 3.12) rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12) rspec-mocks (~> 3.12)
test-unit (~> 3.0) test-unit (~> 3.0)
uri (~> 0.10.1) uri (~> 0.12.0)
webrick (~> 1.6) webrick (~> 1.6)
BUNDLED WITH BUNDLED WITH

View File

@ -3,45 +3,48 @@ GEM
specs: specs:
ast (2.4.2) ast (2.4.2)
diff-lcs (1.5.0) diff-lcs (1.5.0)
minitest (5.15.0) json (2.6.3)
parallel (1.21.0) json (2.6.3-java)
parser (3.1.0.0) minitest (5.16.3)
parallel (1.22.1)
parser (3.1.3.0)
ast (~> 2.4.1) ast (~> 2.4.1)
power_assert (2.0.1) power_assert (2.0.2)
rainbow (3.1.1) rainbow (3.1.1)
rake (13.0.6) rake (13.0.6)
rake-compiler (1.1.7) rake-compiler (1.2.0)
rake rake
regexp_parser (2.2.0) regexp_parser (2.6.1)
rexml (3.2.5) rexml (3.2.5)
rspec (3.10.0) rspec (3.12.0)
rspec-core (~> 3.10.0) rspec-core (~> 3.12.0)
rspec-expectations (~> 3.10.0) rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.10.0) rspec-mocks (~> 3.12.0)
rspec-core (3.10.2) rspec-core (3.12.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.12.0)
rspec-expectations (3.10.2) rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.12.0)
rspec-mocks (3.10.3) rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.12.0)
rspec-support (3.10.3) rspec-support (3.12.0)
rubocop (1.24.1) rubocop (1.40.0)
json (~> 2.3)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.0.0.0) parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 1.8, < 3.0)
rexml rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.15.1, < 2.0) rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0) unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1) rubocop-ast (1.24.0)
parser (>= 3.0.1.1) parser (>= 3.1.1.0)
ruby-progressbar (1.11.0) ruby-progressbar (1.11.0)
test-unit (3.5.3) test-unit (3.5.5)
power_assert power_assert
unicode-display_width (2.1.0) unicode-display_width (2.3.0)
PLATFORMS PLATFORMS
aarch64-linux aarch64-linux

View File

@ -3,51 +3,56 @@ GEM
specs: specs:
ast (2.4.2) ast (2.4.2)
diff-lcs (1.5.0) diff-lcs (1.5.0)
minitest (5.15.0) json (2.6.3)
parallel (1.21.0) json (2.6.3-java)
parser (3.1.0.0) language_server-protocol (3.17.0.2)
minitest (5.16.3)
parallel (1.22.1)
parser (3.1.3.0)
ast (~> 2.4.1) ast (~> 2.4.1)
power_assert (2.0.1) power_assert (2.0.2)
rainbow (3.1.1) rainbow (3.1.1)
rake (13.0.6) rake (13.0.6)
rake-compiler (1.1.7) rake-compiler (1.2.0)
rake rake
regexp_parser (2.2.0) regexp_parser (2.6.1)
rexml (3.2.5) rexml (3.2.5)
rspec (3.10.0) rspec (3.12.0)
rspec-core (~> 3.10.0) rspec-core (~> 3.12.0)
rspec-expectations (~> 3.10.0) rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.10.0) rspec-mocks (~> 3.12.0)
rspec-core (3.10.2) rspec-core (3.12.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.12.0)
rspec-expectations (3.10.2) rspec-expectations (3.12.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.12.0)
rspec-mocks (3.10.3) rspec-mocks (3.12.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.12.0)
rspec-support (3.10.3) rspec-support (3.12.0)
rubocop (1.24.1) rubocop (1.39.0)
json (~> 2.3)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.0.0.0) parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 1.8, < 3.0)
rexml rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.15.1, < 2.0) rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0) unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.1) rubocop-ast (1.24.0)
parser (>= 3.0.1.1) parser (>= 3.1.1.0)
rubocop-performance (1.13.1) rubocop-performance (1.15.1)
rubocop (>= 1.7.0, < 2.0) rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0) rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0) ruby-progressbar (1.11.0)
standard (1.6.0) standard (1.19.1)
rubocop (= 1.24.1) language_server-protocol (~> 3.17.0.2)
rubocop-performance (= 1.13.1) rubocop (= 1.39.0)
test-unit (3.5.3) rubocop-performance (= 1.15.1)
test-unit (3.5.5)
power_assert power_assert
unicode-display_width (2.1.0) unicode-display_width (2.3.0)
PLATFORMS PLATFORMS
aarch64-linux aarch64-linux

View File

@ -5,7 +5,7 @@ GEM
rack-test rack-test
builder (3.2.4) builder (3.2.4)
compact_index (0.13.0) compact_index (0.13.0)
mustermann (1.1.1) mustermann (1.1.2)
ruby2_keywords (~> 0.0.1) ruby2_keywords (~> 0.0.1)
rack (2.0.8) rack (2.0.8)
rack-protection (2.0.8.1) rack-protection (2.0.8.1)
@ -19,7 +19,7 @@ GEM
rack (~> 2.0) rack (~> 2.0)
rack-protection (= 2.0.8.1) rack-protection (= 2.0.8.1)
tilt (~> 2.0) tilt (~> 2.0)
tilt (2.0.10) tilt (2.0.11)
webrick (1.7.0) webrick (1.7.0)
PLATFORMS PLATFORMS