summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-01-30 14:40:18 -0800
committerCarl Lerche <carllerche@mac.com>2010-01-30 14:40:18 -0800
commitc131309ca737676346119476295a705c44306862 (patch)
tree44b54ef86933515b83f7f5ed99396b7abdf52853
parent92bde2fc8f99cf94c01fecd4c621b72994ba479d (diff)
downloadbundler-c131309ca737676346119476295a705c44306862.tar.gz
Make up a gemspec if one is missing?
-rw-r--r--bundler.gemspec2
-rw-r--r--lib/bundler/dsl.rb41
-rw-r--r--lib/bundler/index.rb4
-rw-r--r--lib/bundler/source.rb33
-rw-r--r--spec/install/git_spec.rb10
-rw-r--r--spec/install/path_spec.rb (renamed from spec/install/directory_spec.rb)0
6 files changed, 69 insertions, 21 deletions
diff --git a/bundler.gemspec b/bundler.gemspec
index c56eb1cb99..9562dcef15 100644
--- a/bundler.gemspec
+++ b/bundler.gemspec
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5") if s.respond_to? :required_rubygems_version=
s.authors = ["Carl Lerche", "Yehuda Katz"]
- s.date = %q{2010-01-29}
+ s.date = %q{2010-01-30}
s.default_executable = %q{bundle}
s.email = ["carlhuda@engineyard.com"]
s.executables = ["bundle"]
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 2b36843f69..90c17082b4 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -15,22 +15,12 @@ module Bundler
end
def gem(name, *args)
- opts = Hash === args.last ? args.pop : {}
+ options = Hash === args.last ? args.pop : {}
version = args.last || ">= 0"
- # Normalize the options
- opts.each do |k, v|
- opts[k.to_s] = v
- end
-
- # Set options
- opts["group"] ||= @group
-
- if opts["git"]
- opts["source"] = git(opts["git"], :ref => opts["ref"])
- end
+ _normalize_options(name, version, options)
- @dependencies << Dependency.new(name, version, opts)
+ @dependencies << Dependency.new(name, version, options)
end
def source(source)
@@ -63,5 +53,30 @@ module Bundler
@group = old
end
+ private
+
+ def _version?(version)
+ version && Gem::Version.new(version) rescue false
+ end
+
+ def _normalize_options(name, version, opts)
+ opts.each do |k, v|
+ opts[k.to_s] = v
+ end
+
+ opts["group"] ||= @group
+
+ _normalize_git_options(name, version, opts)
+ end
+
+ def _normalize_git_options(name, version, opts)
+ # Normalize Git options
+ if opts["git"]
+ source = git(opts["git"], :ref => opts["ref"])
+ source.default_spec name, version if _version?(version)
+ opts["source"] = source
+ end
+ end
+
end
end \ No newline at end of file
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index 79cbb10fc8..94a36bf3e2 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -23,6 +23,10 @@ module Bundler
merge!(o)
end
+ def empty?
+ @specs.values.flatten.empty?
+ end
+
def search(query)
case query
when Gem::Specification, RemoteSpecification then search_by_spec(query)
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 2c8557adac..2c152476b8 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -104,19 +104,35 @@ module Bundler
@path = options[:path]
end
+ def default_spec(*args)
+ return @default_spec if args.empty?
+ name, version = *args
+ @default_spec = Specification.new do |s|
+ s.name = name
+ s.source = self
+ s.version = Gem::Version.new(version)
+ s.relative_loaded_from = "#{name}.gemspec"
+ end
+ end
+
def local_specs
@local_specs ||= begin
index = Index.new
- Dir["#{path}/#{@glob}"].each do |file|
- file = Pathname.new(file)
- if spec = eval(File.read(file))
- spec = Specification.from_gemspec(spec)
- spec.loaded_from = file
- spec.source = self
- index << spec
+ if File.directory?(path)
+ Dir["#{path}/#{@glob}"].each do |file|
+ file = Pathname.new(file)
+ if spec = eval(File.read(file))
+ spec = Specification.from_gemspec(spec)
+ spec.loaded_from = file
+ spec.source = self
+ index << spec
+ end
end
+
+ index << default_spec if default_spec && index.empty?
end
+
index.freeze
end
end
@@ -170,6 +186,9 @@ module Bundler
end
end
end
+
+ index << default_spec if default_spec && index.empty?
+
index.freeze
end
end
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb
index 7084a69db2..ce4e68a550 100644
--- a/spec/install/git_spec.rb
+++ b/spec/install/git_spec.rb
@@ -110,4 +110,14 @@ describe "gemfile install with git sources" do
should_be_installed "foo 1.0"
end
+
+ it "fakes the gem out if there is no gemspec" do
+ build_git "foo", :gemspec => false
+
+ install_gemfile <<-G
+ gem "foo", "1.0", :git => "#{lib_path('foo-1.0')}"
+ G
+
+ should_be_installed("foo 1.0")
+ end
end \ No newline at end of file
diff --git a/spec/install/directory_spec.rb b/spec/install/path_spec.rb
index e4df4d5f59..e4df4d5f59 100644
--- a/spec/install/directory_spec.rb
+++ b/spec/install/path_spec.rb