summaryrefslogtreecommitdiff
path: root/lib/bundler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler.rb')
-rw-r--r--lib/bundler.rb16
1 files changed, 16 insertions, 0 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