Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3428 from segiddins/seg-path-depth-sort
Browse files Browse the repository at this point in the history
[Source::Path] Sort gemspecs by relative depth
  • Loading branch information
TimMoore committed Feb 27, 2015
2 parents 516d548 + ed8182e commit d8f6169
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bundler/source/path.rb
Expand Up @@ -130,7 +130,8 @@ def load_spec_files
index = Index.new

if File.directory?(expanded_path)
Dir["#{expanded_path}/#{@glob}"].each do |file|
# We sort depth-first since `<<` will override the earlier-found specs
Dir["#{expanded_path}/#{@glob}"].sort_by { |p| -p.split(File::SEPARATOR).size }.each do |file|
spec = Bundler.load_gemspec(file)
if spec
spec.loaded_from = file.to_s
Expand Down
19 changes: 19 additions & 0 deletions spec/install/gemfile/path_spec.rb
Expand Up @@ -120,6 +120,25 @@
should_be_installed "foo 1.0"
end

it "prefers gemspecs closer to the path root" do
build_lib "premailer", "1.0.0", :path => lib_path("premailer") do |s|
s.write "gemfiles/ruby187.gemspec", <<-G
Gem::Specification.new do |s|
s.name = 'premailer'
s.version = '1.0.0'
end
G
end

install_gemfile <<-G
gem "premailer", :path => "#{lib_path("premailer")}"
G

# Installation of the 'gemfiles' gemspec would fail since it will be unable
# to require 'premailer.rb'
should_be_installed "premailer 1.0.0"
end

it "supports gemspec syntax" do
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
s.add_dependency "rack", "1.0"
Expand Down

0 comments on commit d8f6169

Please sign in to comment.