summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel E. Giddins <segiddins@segiddins.me>2015-05-16 20:26:36 -0700
committerSamuel E. Giddins <segiddins@segiddins.me>2015-05-16 21:25:22 -0700
commitedec4c324aed86858005336d144d3474f29182fd (patch)
treeb70e7ee67109fb4becbdbc1553281457840caecf
parent7536f442674f3a8d8407fdf72719559340783a77 (diff)
downloadbundler-seg-validate-path-gemspecs.tar.gz
[Path] Validate the gemspecs we find when globbingseg-validate-path-gemspecs
-rw-r--r--lib/bundler.rb16
-rw-r--r--lib/bundler/dsl.rb17
-rw-r--r--lib/bundler/source/path.rb3
3 files changed, 18 insertions, 18 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 197e88c222..f487d2c69d 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -364,6 +364,22 @@ module Bundler
end
end
+ def load_and_validate_gemspec(file, allow_nil = false)
+ spec = load_gemspec(file)
+
+ unless spec
+ return if allow_nil
+ raise InvalidOption, "There was an error loading the gemspec at " \
+ "#{file}. Make sure you can build the gem, then try again."
+ end
+
+ spec.validate
+ spec
+ rescue Gem::InvalidSpecificationException => e
+ raise InvalidOption, "The gemspec at #{file} is not valid. " \
+ "The validation error was '#{e.message}'"
+ end
+
def clear_gemspec_cache
@gemspec_cache = {}
end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index cd0c80b3ff..84fafa7d62 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -48,7 +48,7 @@ module Bundler
case gemspecs.size
when 1
- spec = load_valid_gemspec(gemspecs.first)
+ spec = Bundler.load_and_validate_gemspec(gemspecs.first)
gem spec.name, :path => path, :glob => glob
@@ -360,21 +360,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..9d2cbb708d 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -132,8 +132,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 = Bundler.load_and_validate_gemspec(file, true)
spec.loaded_from = file.to_s
spec.source = self
index << spec