summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Hull <joshbuddy@gmail.com>2010-04-14 09:40:10 -0400
committerAndre Arko <andre@arko.net>2010-04-14 22:05:16 -0700
commit4a05eefbec072c8f5cb0e85720d99ca787b1ff54 (patch)
tree87ef5f7e53e2a65dea5f371c7783ca0b3d1ff319
parent0753a247d516346c8a0804915267f9fa93d692db (diff)
downloadbundler-4a05eefbec072c8f5cb0e85720d99ca787b1ff54.tar.gz
Load YAML gemspecs
Closes #248
-rw-r--r--lib/bundler/source.rb16
-rw-r--r--spec/install/gems/simple_case_spec.rb19
-rw-r--r--spec/support/builders.rb14
3 files changed, 44 insertions, 5 deletions
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index b2e5c038ec..71f56ca478 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -193,7 +193,21 @@ module Bundler
Dir["#{path}/#{@glob}"].each do |file|
file = Pathname.new(file)
# Eval the gemspec from its parent directory
- if spec = Dir.chdir(file.dirname) { eval(File.read(file.basename), binding, file.expand_path.to_s) }
+ spec = Dir.chdir(file.dirname) do
+ begin
+ Gem::Specification.from_yaml(file.basename)
+ # Raises ArgumentError if the file is not valid YAML
+ rescue ArgumentError, Gem::EndOfYAMLException, Gem::Exception
+ begin
+ eval(File.read(file.basename), TOPLEVEL_BINDING, file.expand_path.to_s)
+ rescue LoadError
+ raise GemspecError, "There was a LoadError while evaluating #{file.basename}.\n" +
+ "Does it try to require a relative path? That doesn't work in Ruby 1.9."
+ end
+ end
+ end
+
+ if spec
spec = Specification.from_gemspec(spec)
spec.loaded_from = file.to_s
spec.source = self
diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb
index 8ab731ee1e..ac4f3df010 100644
--- a/spec/install/gems/simple_case_spec.rb
+++ b/spec/install/gems/simple_case_spec.rb
@@ -343,4 +343,21 @@ describe "bundle install with gem sources" do
out.should include("no activesupport")
end
end
-end \ No newline at end of file
+
+ describe "when a gem has a YAML gemspec" do
+ before :each do
+ build_repo2 do
+ build_gem "yaml_spec", :gemspec => :yaml
+ end
+ end
+
+ it "still installs correctly" do
+ gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "yaml_spec"
+ G
+ bundle :install
+ err.should be_empty
+ end
+ end
+end
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index ba4da76b50..2145cdc510 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -356,7 +356,15 @@ module Spec
def _build(options)
path = options[:path] || _default_path
- @files["#{name}.gemspec"] = @spec.to_ruby unless options[:gemspec] == false
+ case options[:gemspec]
+ when false
+ # do nothing
+ when :yaml
+ @files["#{name}.gemspec"] = @spec.to_yaml
+ else
+ @files["#{name}.gemspec"] = @spec.to_ruby
+ end
+
unless options[:no_default]
@files = _default_files.merge(@files)
end
@@ -429,7 +437,7 @@ module Spec
class GemBuilder < LibBuilder
def _build(opts)
- lib_path = super(:path => @context.tmp(".tmp/#{@spec.full_name}"), :no_default => opts[:no_default])
+ lib_path = super(opts.merge(:path => @context.tmp(".tmp/#{@spec.full_name}"), :no_default => opts[:no_default]))
Dir.chdir(lib_path) do
destination = opts[:path] || _default_path
FileUtils.mkdir_p(destination)
@@ -447,4 +455,4 @@ module Spec
end
end
end
-end \ No newline at end of file
+end