summaryrefslogtreecommitdiff
path: root/lib/bundler
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-07-02 14:24:01 -0700
committerCarlhuda <carlhuda@engineyard.com>2010-07-02 14:24:01 -0700
commit48089338b337cdd1af6f07373e9e9ce0a41f90f1 (patch)
tree17bb5c70e5508a92c7890c62b804bcee1a5b7401 /lib/bundler
parent7d3cb65c41e964e23a9c760b390696b1823409f6 (diff)
downloadbundler-48089338b337cdd1af6f07373e9e9ce0a41f90f1.tar.gz
Improve bundling bundler logic
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/definition.rb10
-rw-r--r--lib/bundler/runtime.rb1
-rw-r--r--lib/bundler/source.rb21
-rw-r--r--lib/bundler/spec_set.rb12
4 files changed, 34 insertions, 10 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index ad0f1952b3..7170276273 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -70,7 +70,15 @@ module Bundler
end
def specs
- @specs ||= resolve.materialize(requested_dependencies)
+ @specs ||= begin
+ specs = resolve.materialize(requested_dependencies)
+
+ unless specs["bundler"].any?
+ specs["bundler"] = index.search(Gem::Dependency.new('bundler', VERSION)).last
+ end
+
+ specs
+ end
end
def missing_specs
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index a1df6e3aaf..99f72bc7d2 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -77,6 +77,7 @@ module Bundler
Bundler.ui.info "Updating .gem files in vendor/cache"
specs.each do |spec|
+ next if spec.name == 'bundler'
spec.source.cache(spec) if spec.source.respond_to?(:cache)
end
end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 79bb62595d..d6aebae5ec 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -146,21 +146,24 @@ module Bundler
def installed_specs
@installed_specs ||= begin
idx = Index.new
+ have_bundler = false
Gem::SourceIndex.from_installed_gems.to_a.reverse.each do |name, spec|
- next if name == 'bundler'
+ have_bundler = true if name == 'bundler' && spec.version.to_s == VERSION
spec.source = self
idx << spec
end
# Always have bundler locally
- bundler = Gem::Specification.new do |s|
- s.name = 'bundler'
- s.version = VERSION
- s.platform = Gem::Platform::RUBY
- s.source = self
- # TODO: Remove this
- s.loaded_from = 'w0t'
+ unless have_bundler
+ bundler = Gem::Specification.new do |s|
+ s.name = 'bundler'
+ s.version = VERSION
+ s.platform = Gem::Platform::RUBY
+ s.source = self
+ # TODO: Remove this
+ s.loaded_from = 'w0t'
+ end
+ idx << bundler
end
- idx << bundler
idx
end
end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 193b0f4307..36faf1a6d5 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -18,6 +18,7 @@ module Bundler
def for(dependencies, skip = [], check = false, match_current_platform = false)
handled, deps, specs = {}, dependencies.dup, []
+ skip << 'bundler'
until deps.empty?
dep = deps.shift
@@ -44,6 +45,10 @@ module Bundler
end
end
+ if spec = lookup['bundler'].first
+ specs << spec
+ end
+
check ? true : SpecSet.new(specs)
end
@@ -56,6 +61,13 @@ module Bundler
lookup[key].reverse
end
+ def []=(key, value)
+ @specs << value
+ @lookup = nil
+ @sorted = nil
+ value
+ end
+
def to_a
sorted.dup
end