summaryrefslogtreecommitdiff
path: root/lib
diff options
authorHiroshi SHIBATA <[email protected]>2022-08-03 12:24:38 +0900
committerHiroshi SHIBATA <[email protected]>2022-08-03 13:14:10 +0900
commit71794a75db5d3da810146da106baf7eb5e86f745 (patch)
treec354ae515036c15a96a079712f3b7427c807be18 /lib
parent8a1be433e8cac6ca5ded095f6fefbdc1009102b9 (diff)
Merge rubygems/bundler HEAD
Pick from https://github.com/rubygems/rubygems/commit/8331e63263081a6aa690d8025d2957f30c4e814a
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6209
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli/platform.rb2
-rw-r--r--lib/bundler/cli/viz.rb2
-rw-r--r--lib/bundler/constants.rb2
-rw-r--r--lib/bundler/fetcher/downloader.rb2
-rw-r--r--lib/bundler/templates/Executable2
-rw-r--r--lib/bundler/templates/Executable.bundler5
-rw-r--r--lib/bundler/templates/Executable.standalone2
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/rdoc_command.rb5
-rw-r--r--lib/rubygems/defaults.rb2
-rw-r--r--lib/rubygems/ext/builder.rb2
-rw-r--r--lib/rubygems/installer.rb4
-rw-r--r--lib/rubygems/validator.rb2
13 files changed, 19 insertions, 15 deletions
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb
index 068c765aad..16d4e0145a 100644
--- a/lib/bundler/cli/platform.rb
+++ b/lib/bundler/cli/platform.rb
@@ -9,7 +9,7 @@ module Bundler
def run
platforms, ruby_version = Bundler.ui.silence do
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version
+ locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version.gsub(/p\d+\Z/, "")
gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
[Bundler.definition.platforms.map {|p| "* #{p}" },
locked_ruby_version || gemfile_ruby_version]
diff --git a/lib/bundler/cli/viz.rb b/lib/bundler/cli/viz.rb
index 644f9b25cf..5c09e00995 100644
--- a/lib/bundler/cli/viz.rb
+++ b/lib/bundler/cli/viz.rb
@@ -23,7 +23,7 @@ module Bundler
Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
Bundler.ui.warn "`gem install ruby-graphviz`"
rescue StandardError => e
- raise unless e.message =~ /GraphViz not installed or dot not in PATH/
+ raise unless e.message.to_s.include?("GraphViz not installed or dot not in PATH")
Bundler.ui.error e.message
Bundler.ui.warn "Please install GraphViz. On a Mac with Homebrew, you can run `brew install graphviz`."
end
diff --git a/lib/bundler/constants.rb b/lib/bundler/constants.rb
index 2e4ebb37ee..8dd8a53815 100644
--- a/lib/bundler/constants.rb
+++ b/lib/bundler/constants.rb
@@ -2,6 +2,6 @@
module Bundler
WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
- FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
+ FREEBSD = RbConfig::CONFIG["host_os"].to_s.include?("bsd")
NULL = WINDOWS ? "NUL" : "/dev/null"
end
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
index f2aad3a500..0a668eb17c 100644
--- a/lib/bundler/fetcher/downloader.rb
+++ b/lib/bundler/fetcher/downloader.rb
@@ -68,7 +68,7 @@ module Bundler
raise CertificateFailureError.new(uri)
rescue *HTTP_ERRORS => e
Bundler.ui.trace e
- if e.is_a?(SocketError) || e.message =~ /host down:/
+ if e.is_a?(SocketError) || e.message.to_s.include?("host down:")
raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
"connection and try again."
else
diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable
index f6487e3c89..9ff6f00898 100644
--- a/lib/bundler/templates/Executable
+++ b/lib/bundler/templates/Executable
@@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir
bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub)
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
diff --git a/lib/bundler/templates/Executable.bundler b/lib/bundler/templates/Executable.bundler
index 51650c7664..77f90e735c 100644
--- a/lib/bundler/templates/Executable.bundler
+++ b/lib/bundler/templates/Executable.bundler
@@ -62,8 +62,9 @@ m = Module.new do
def bundler_requirement
@bundler_requirement ||=
- env_var_version || cli_arg_version ||
- bundler_requirement_for(lockfile_version)
+ env_var_version ||
+ cli_arg_version ||
+ bundler_requirement_for(lockfile_version)
end
def bundler_requirement_for(version)
diff --git a/lib/bundler/templates/Executable.standalone b/lib/bundler/templates/Executable.standalone
index d591e3fc04..3117a27e86 100644
--- a/lib/bundler/templates/Executable.standalone
+++ b/lib/bundler/templates/Executable.standalone
@@ -1,4 +1,6 @@
#!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
+# frozen_string_literal: true
+
#
# This file was generated by Bundler.
#
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index e59cd26870..b21f00acc7 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1010,7 +1010,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Is this platform Solaris?
def self.solaris_platform?
- RUBY_PLATFORM =~ /solaris/
+ RUBY_PLATFORM.include?("solaris")
end
##
diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb
index 17ad6f836b..a998a9704c 100644
--- a/lib/rubygems/commands/rdoc_command.rb
+++ b/lib/rubygems/commands/rdoc_command.rb
@@ -86,8 +86,9 @@ Use --overwrite to force rebuilding of documentation.
begin
doc.generate
rescue Errno::ENOENT => e
- e.message =~ / - /
- alert_error "Unable to document #{spec.full_name}, #{$'} is missing, skipping"
+ match = / - /.match(e.message)
+ alert_error "Unable to document #{spec.full_name}, " \
+ " #{match.post_match} is missing, skipping"
terminate_interaction 1 if specs.length == 1
end
end
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index d27f286265..b805ef9174 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -171,7 +171,7 @@ module Gem
def self.default_exec_format
exec_format = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s") rescue "%s"
- unless exec_format =~ /%s/
+ unless exec_format.include?("%s")
raise Gem::Exception,
"[BUG] invalid exec_format #{exec_format.inspect}, no %s"
end
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index c5a03806b9..b46f9b5cd5 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -26,7 +26,7 @@ class Gem::Ext::Builder
RbConfig::CONFIG["configure_args"] =~ /with-make-prog\=(\w+)/
make_program_name = ENV["MAKE"] || ENV["make"] || $1
unless make_program_name
- make_program_name = (/mswin/ =~ RUBY_PLATFORM) ? "nmake" : "make"
+ make_program_name = (RUBY_PLATFORM.include?("mswin")) ? "nmake" : "make"
end
make_program = Shellwords.split(make_program_name)
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 52307f6d93..8ec75d1ff7 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -234,8 +234,8 @@ class Gem::Installer
io.gets # blankline
# TODO detect a specially formatted comment instead of trying
- # to run a regexp against Ruby code.
- next unless io.gets =~ /This file was generated by RubyGems/
+ # to find a string inside Ruby code.
+ next unless io.gets.to_s.include?("This file was generated by RubyGems")
ruby_executable = true
existing = io.read.slice(%r{
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index 60104a34d5..1609924607 100644
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -26,7 +26,7 @@ class Gem::Validator
Find.find gem_directory do |file_name|
fn = file_name[gem_directory.size..file_name.size - 1].sub(/^\//, "")
installed_files << fn unless
- fn =~ /CVS/ || fn.empty? || File.directory?(file_name)
+ fn.empty? || fn.include?("CVS") || File.directory?(file_name)
end
installed_files