@@ -547,15 +547,7 @@ def load_gemspec(file, validate = false)
547547 def load_gemspec_uncached ( file , validate = false )
548548 path = Pathname . new ( file )
549549 contents = read_file ( file )
550- spec = if contents . start_with? ( "---" ) # YAML header
551- eval_yaml_gemspec ( path , contents )
552- else
553- # Eval the gemspec from its parent directory, because some gemspecs
554- # depend on "./" relative paths.
555- SharedHelpers . chdir ( path . dirname . to_s ) do
556- eval_gemspec ( path , contents )
557- end
558- end
550+ spec = eval_gemspec ( path , contents )
559551 return unless spec
560552 spec . loaded_from = path . expand_path . to_s
561553 Bundler . rubygems . validate ( spec ) if validate
@@ -657,12 +649,18 @@ def eval_yaml_gemspec(path, contents)
657649 Kernel . require "psych"
658650
659651 Gem ::Specification . from_yaml ( contents )
660- rescue ::Psych ::SyntaxError , ArgumentError , Gem ::EndOfYAMLException , Gem ::Exception
661- eval_gemspec ( path , contents )
662652 end
663653
664654 def eval_gemspec ( path , contents )
665- eval ( contents , TOPLEVEL_BINDING . dup , path . expand_path . to_s )
655+ if contents . start_with? ( "---" ) # YAML header
656+ eval_yaml_gemspec ( path , contents )
657+ else
658+ # Eval the gemspec from its parent directory, because some gemspecs
659+ # depend on "./" relative paths.
660+ SharedHelpers . chdir ( path . dirname . to_s ) do
661+ eval ( contents , TOPLEVEL_BINDING . dup , path . expand_path . to_s )
662+ end
663+ end
666664 rescue ScriptError , StandardError => e
667665 msg = "There was an error while loading `#{ path . basename } `: #{ e . message } "
668666
0 commit comments