module Bundler
def load_gemspec(file)
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(contents) # Raises ArgumentError if the file is not valid YAML rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception begin 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}" msg << " from\n #{original_line}" if original_line msg << "\n" if RUBY_VERSION >= "1.9.0" msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9." end raise GemspecError, msg end end end end