diff options
author | Samuel E. Giddins <segiddins@segiddins.me> | 2015-05-16 20:26:36 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-05-16 22:58:10 -0700 |
commit | 858afa5cfec914bd3c9d6242d1ae49cd6c227fa1 (patch) | |
tree | 8a10e014db248aa9900e12405c8c50d761d3ba87 | |
parent | 86c0b7775690f5b00fe3f3f73ae407b2fa6db875 (diff) | |
download | bundler-858afa5cfec914bd3c9d6242d1ae49cd6c227fa1.tar.gz |
[Path] Validate the gemspecs we find when globbing
-rw-r--r-- | lib/bundler/dsl.rb | 22 | ||||
-rw-r--r-- | lib/bundler/source/path.rb | 15 |
2 files changed, 17 insertions, 20 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index cd0c80b3ff..a6fbd99518 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -48,7 +48,12 @@ module Bundler case gemspecs.size when 1 - spec = load_valid_gemspec(gemspecs.first) + spec = Bundler.load_gemspec(gemspecs.first) + + unless spec + raise InvalidOption, "There was an error loading the gemspec at " \ + "#{file}. Make sure you can build the gem, then try again." + end gem spec.name, :path => path, :glob => glob @@ -360,21 +365,6 @@ module Bundler end end - def load_valid_gemspec(path) - spec = Bundler.load_gemspec(path) - - unless spec - raise InvalidOption, "There was an error loading the gemspec at " \ - "#{path}. Make sure you can build the gem, then try again." - end - - spec.validate - spec - rescue Gem::InvalidSpecificationException => e - raise InvalidOption, "The gemspec at #{path} is not valid. " \ - "The validation error was '#{e.message}'" - end - class DSLError < GemfileError # @return [String] the description that should be presented to the user. # diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 862fbcb97a..6c2ed85881 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -1,6 +1,5 @@ module Bundler class Source - class Path < Source autoload :Installer, 'bundler/source/path/installer' @@ -132,8 +131,7 @@ module Bundler if File.directory?(expanded_path) # 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 + if spec = load_and_validate_gemspec(file) spec.loaded_from = file.to_s spec.source = self index << spec @@ -220,7 +218,16 @@ module Bundler end end end - end + def load_and_validate_gemspec(file) + spec = load_gemspec(file) + spec.validate + spec + rescue Gem::InvalidSpecificationException => e + raise InvalidOption, "The gemspec at #{file} is not valid. " \ + "The validation error was '#{e.message}'" + end + + end end end |