lib/bundler.rb in bundler-1.3.0.pre vs lib/bundler.rb in bundler-1.3.0.pre.2

- old
+ new

@@ -286,21 +286,16 @@ spec.dup if spec end def load_gemspec_uncached(file) path = Pathname.new(file) - # Eval the gemspec from its parent directory + # Eval the gemspec from its parent directory, because some gemspecs + # depend on "./" relative paths. Dir.chdir(path.dirname.to_s) do - contents = File.read(path.basename.to_s) - if contents =~ /\A---/ # try YAML - begin - Gem::Specification.from_yaml(contents) - # Raises ArgumentError if the file is not valid YAML (on syck) - # Psych raises a Psych::SyntaxError - rescue YamlSyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception - eval_gemspec(path, contents) - end + contents = path.read + if contents[0..2] == "---" # YAML header + eval_yaml_gemspec(path, contents) else eval_gemspec(path, contents) end end end @@ -308,9 +303,17 @@ def clear_gemspec_cache @gemspec_cache = {} end private + + def eval_yaml_gemspec(path, contents) + # If the YAML is invalid, Syck raises an ArgumentError, and Psych + # raises a Psych::SyntaxError. See psyched_yaml.rb for more info. + Gem::Specification.from_yaml(contents) + rescue YamlSyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception + eval_gemspec(path, contents) + end def eval_gemspec(path, contents) eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s) rescue LoadError, SyntaxError => e original_line = e.backtrace.find { |line| line.include?(path.to_s) }