Use Gem::BUNDLED_GEMS.warning? at Bundler.setup

This commit is contained in:
Hiroshi SHIBATA 2023-10-12 12:53:41 +09:00
Родитель d8a74207e7
Коммит 75644f98e5
1 изменённых файлов: 18 добавлений и 24 удалений

Просмотреть файл

@ -246,17 +246,13 @@ module Bundler
kernel_class.send(:define_method, :require) do |file|
file = File.path(file)
name = file.tr("/", "-")
if (::Gem::BUNDLED_GEMS::SINCE.keys - specs.to_a.map(&:name)).include?(name)
unless $LOADED_FEATURES.any? {|f| f.end_with?("#{name}.rb", "#{name}.#{RbConfig::CONFIG["DLEXT"]}") }
if message = ::Gem::BUNDLED_GEMS.warning?(name)
target_file = begin
Bundler.default_gemfile.basename
rescue GemfileNotFound
"inline Gemfile"
end
if ::Gem::BUNDLED_GEMS::SINCE[name]
be = ::Gem::BUNDLED_GEMS::SINCE[name] > RUBY_VERSION ? "will be" : "is"
message = "#{name} #{be} not part of the default gems since Ruby #{::Gem::BUNDLED_GEMS::SINCE[name]}." \
" Add #{name} to your #{target_file}."
message += " Add #{name} to your #{target_file}."
location = caller_locations(1,1)[0]&.path
if File.file?(location) && !location.start_with?(Gem::BUNDLED_GEMS::LIBDIR)
caller_gem = nil
@ -270,8 +266,6 @@ module Bundler
end
warn message, :uplevel => 1
end
end
end
kernel_class.send(:no_warning_require, file)
end
if kernel_class == ::Kernel