Permalink
Browse files

Bring back ryan davis spermy operators for git & directory sources. C…

…loses #114
  • Loading branch information...
1 parent d794186 commit 327af9c55c8dbf9b3e0ee280446d083a3279b393 Carlhuda committed Dec 9, 2009
Showing with 47 additions and 4 deletions.
  1. +6 −2 lib/bundler/dsl.rb
  2. +2 −1 lib/bundler/resolver.rb
  3. +5 −1 lib/bundler/source.rb
  4. +22 −0 spec/bundler/directory_spec.rb
  5. +12 −0 spec/bundler/git_spec.rb
View
@@ -104,12 +104,16 @@ def gem(name, *args)
private
+ def _version?(version)
+ version && Gem::Version.new(version) rescue false
+ end
+
def _handle_vendored_option(name, version, options)
dir, path = _find_directory_source(options[:path])
if dir
dir.required_specs << name
- dir.add_spec(path, name, version) if version
+ dir.add_spec(path, name, version) if _version?(version)
dir
else
directory options[:path] do
@@ -147,7 +151,7 @@ def _handle_git_option(name, version, options)
end
source.required_specs << name
- source.add_spec(Pathname.new(options[:path] || '.'), name, version) if version
+ source.add_spec(Pathname.new(options[:path] || '.'), name, version) if _version?(version)
source
else
git(git, :ref => ref, :branch => branch) do
View
@@ -157,7 +157,8 @@ def resolve(reqs, activated)
if matching_versions.empty?
if current.required_by.empty?
- raise GemNotFound, "Could not find gem '#{current}' in any of the sources"
+ location = @by_gem[current.name] ? @by_gem[current.name] : "any of the sources"
+ raise GemNotFound, "Could not find gem '#{current}' in #{location}"
end
Bundler.logger.warn "Could not find gem '#{current}' (required by '#{current.required_by.last}') in any of the sources"
end
View
@@ -274,7 +274,7 @@ def ==(other)
end
def to_s
- "#{@name} (#{@version}) Located at: '#{location}'"
+ "directory: '#{location}'"
end
def download(spec)
@@ -322,5 +322,9 @@ def gems
def download(spec)
# Nothing needed here
end
+
+ def to_s
+ "git: #{uri}"
+ end
end
end
@@ -164,6 +164,28 @@
:default.should have_const("HI2U")
end
+ it "directory can specify spermy specifiers" do
+ build_lib "omg", "1.0.2", :gemspec => true
+
+ install_manifest <<-Gemfile
+ clear_sources
+ gem "omg", "~> 1.0.0", :path => "#{tmp_path}/libs"
+ Gemfile
+
+ :default.should have_const("OMG")
+ end
+
+ it "raises exception when directory does not contain correct gem version" do
+ build_lib "omg", "1.0.2", :gemspec => true
+
+ lambda do
+ install_manifest <<-Gemfile
+ clear_sources
+ gem "omg", "~> 1.1", :path => "#{tmp_path}/libs"
+ Gemfile
+ end.should raise_error(Bundler::GemNotFound, /directory/)
+ end
+
it "can list vendored gems without :path" do
build_lib "omg", "1.0"
install_manifest <<-Gemfile
View
@@ -99,6 +99,18 @@
out.should == "1.0\n1.0"
end
+ it "raises exception when git does not contain correct gem version" do
+ build_lib "omg", "1.0.2", :gemspec => true
+ gitify tmp_path("libs")
+
+ lambda do
+ install_manifest <<-Gemfile
+ clear_sources
+ gem "omg", "~> 1.1", :git => "#{tmp_path("libs")}"
+ Gemfile
+ end.should raise_error(Bundler::GemNotFound, /git/)
+ end
+
it "allows bundling a specific tag" do
path = build_git_repo "very-simple", :with => fixture_dir.join("very-simple")
install_manifest <<-Gemfile

0 comments on commit 327af9c

Please sign in to comment.