[rubygems/rubygems] Use the dedicated method to convert file path
The dedicated method `File.path` to deal with pathname-like objects has been provided since ruby 1.9.0. Also adds a test for rubygems/rubygems#6837. https://github.com/rubygems/rubygems/commit/258c6eda80
This commit is contained in:
parent
bde4080b39
commit
0d86cc4caf
@ -245,7 +245,8 @@ 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|
|
||||
name = file.to_s.tr("/", "-")
|
||||
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"]}") }
|
||||
target_file = begin
|
||||
|
@ -37,8 +37,7 @@ module Kernel
|
||||
return gem_original_require(path) unless Gem.discover_gems_on_require
|
||||
|
||||
RUBYGEMS_ACTIVATION_MONITOR.synchronize do
|
||||
path = path.to_path if path.respond_to? :to_path
|
||||
path = String.try_convert(path) || path
|
||||
path = File.path(path)
|
||||
|
||||
if spec = Gem.find_unresolved_default_spec(path)
|
||||
# Ensure -I beats a default gem
|
||||
|
@ -1650,4 +1650,34 @@ end
|
||||
|
||||
expect(err).to include("net-imap is not part of the default gems")
|
||||
end
|
||||
|
||||
it "calls #to_path on the name to require" do
|
||||
build_repo4 do
|
||||
build_gem "net-imap" do |s|
|
||||
s.write "lib/net/imap.rb", "NET_IMAP = '0.0.1'"
|
||||
end
|
||||
build_gem "csv"
|
||||
end
|
||||
|
||||
install_gemfile <<-G
|
||||
source "#{file_uri_for(gem_repo4)}"
|
||||
gem "csv"
|
||||
G
|
||||
|
||||
ruby <<-R
|
||||
Gem.send(:remove_const, :BUNDLED_GEMS) if defined?(Gem::BUNDLED_GEMS)
|
||||
module Gem::BUNDLED_GEMS
|
||||
SINCE = { "csv" => "1.0.0", "net-imap" => "0.0.1" }
|
||||
end
|
||||
path = BasicObject.new
|
||||
def path.to_path; 'net/imap'; end
|
||||
require 'bundler/setup'
|
||||
begin
|
||||
require path
|
||||
rescue LoadError
|
||||
end
|
||||
R
|
||||
|
||||
expect(err).to include("net-imap is not part of the default gems")
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user