Skip to content

Commit

Permalink
Pass Gem::Specification.from_yaml a string containing the gemspec (in…
Browse files Browse the repository at this point in the history
…stead of the filename)
  • Loading branch information
sumbach authored and Andre Arko and Terence Lee committed Jan 25, 2011
1 parent 30319c6 commit f0e9ca3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/bundler.rb
Expand Up @@ -230,12 +230,13 @@ def load_gemspec(file)
path = Pathname.new(file)
# Eval the gemspec from its parent directory
Dir.chdir(path.dirname.to_s) do
contents = File.read(path.basename.to_s)
begin
Gem::Specification.from_yaml(path.basename.to_s)
Gem::Specification.from_yaml(contents)
# Raises ArgumentError if the file is not valid YAML
rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception
begin
eval(File.read(path.basename.to_s), TOPLEVEL_BINDING, path.expand_path.to_s)
eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
rescue LoadError => e
original_line = e.backtrace.find { |line| line.include?(path.to_s) }
msg = "There was a LoadError while evaluating #{path.basename}:\n #{e.message}"
Expand Down

0 comments on commit f0e9ca3

Please sign in to comment.