diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-10-12 13:32:09 +0900 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-10-13 16:22:09 +0900 |
| commit | ea05ddbeff99b1c0766b0171d11a9fa84dce62ec (patch) | |
| tree | 650828a37a6bc34d750dc1fcaa596f5a184d206e | |
| parent | c2bdb198d78508853609257058aaebb6c364af7c (diff) | |
Move path normalization into Gem from Bundler class
| -rw-r--r-- | lib/bundled_gems.rb | 1 | ||||
| -rw-r--r-- | lib/bundler/rubygems_integration.rb | 6 |
2 files changed, 3 insertions, 4 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb index cebf72798f..9e5c5b2082 100644 --- a/lib/bundled_gems.rb +++ b/lib/bundled_gems.rb @@ -69,6 +69,7 @@ module Gem::BUNDLED_GEMS end def self.warning?(name) + name = name.tr("/", "-") _t, path = $:.resolve_feature_path(name) return unless gem = find_gem(path) caller = caller_locations(3, 3).find {|c| c&.absolute_path} diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 184e87046e..b15bd31c47 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -243,9 +243,7 @@ module Bundler [::Kernel.singleton_class, ::Kernel].each do |kernel_class| kernel_class.send(:alias_method, :no_warning_require, :require) - kernel_class.send(:define_method, :require) do |file| - file = File.path(file) - name = file.tr("/", "-") + kernel_class.send(:define_method, :require) do |name| if message = ::Gem::BUNDLED_GEMS.warning?(name) message += " Add #{name} to your Gemfile." location = caller_locations(1,1)[0]&.path @@ -261,7 +259,7 @@ module Bundler end warn message, :uplevel => 1 end - kernel_class.send(:no_warning_require, file) + kernel_class.send(:no_warning_require, name) end if kernel_class == ::Kernel kernel_class.send(:private, :require) |
