summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2023-12-16 14:52:20 +0800
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-12-16 17:34:45 +0900
commit83bdf127b8ddbb64c941bb9c467c686140b1696b (patch)
tree6cec20e9105181c15b0104ce2e6d9c8295aeca7e /lib
parent6f6b36b7e47d29ff8bc33918265a8bb4148109e8 (diff)
Avoid warning when requiring bigdecimal/util when bigdecimal is in gemfile
Diffstat (limited to 'lib')
-rw-r--r--lib/bundled_gems.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb
index f0e114138a..55d10e0419 100644
--- a/lib/bundled_gems.rb
+++ b/lib/bundled_gems.rb
@@ -59,10 +59,12 @@ module Gem::BUNDLED_GEMS
def self.replace_require(specs)
return if [::Kernel.singleton_class, ::Kernel].any? {|klass| klass.respond_to?(:no_warning_require) }
+ spec_names = specs.to_a.each_with_object({}) {|spec, h| h[spec.name] = true }
+
[::Kernel.singleton_class, ::Kernel].each do |kernel_class|
kernel_class.send(:alias_method, :no_warning_require, :require)
kernel_class.send(:define_method, :require) do |name|
- if message = ::Gem::BUNDLED_GEMS.warning?(name, specs: specs) # rubocop:disable Style/HashSyntax
+ if message = ::Gem::BUNDLED_GEMS.warning?(name, specs: spec_names) # rubocop:disable Style/HashSyntax
warn message, :uplevel => 1
end
kernel_class.send(:no_warning_require, name)
@@ -90,10 +92,12 @@ module Gem::BUNDLED_GEMS
def self.warning?(name, specs: nil)
feature = File.path(name) # name can be a feature name or a file path with String or Pathname
- name = feature.tr("/", "-").sub(LIBEXT, "")
- return if specs.to_a.map(&:name).include?(name)
+ name = feature.tr("/", "-")
+ name.sub!(LIBEXT, "")
+ return if specs.include?(name)
_t, path = $:.resolve_feature_path(feature)
if gem = find_gem(path)
+ return if specs.include?(gem)
caller = caller_locations(3, 3).find {|c| c&.absolute_path}
return if find_gem(caller&.absolute_path)
elsif SINCE[name]