summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2010-03-26 20:12:22 -0700
committerAndre Arko <andre@arko.net>2010-03-30 10:14:13 -0700
commitb42ee712d3b2225dc1d7f28ec3976e947648e7a4 (patch)
tree256b659f8877352ec7a678ae95c505ddb552b629
parent128e6b2265006a0aaa652cd4f1de66daa9224af6 (diff)
downloadbundler-b42ee712d3b2225dc1d7f28ec3976e947648e7a4.tar.gz
Add Bundler::Source::BundlerGems, to distingush from SystemGems.
This allows, among other things, for the bundle install command to inform users of whether the gem being bundled is currently installed in system gems or into the set of bundled gems.
-rw-r--r--lib/bundler.rb6
-rw-r--r--lib/bundler/environment.rb4
-rw-r--r--lib/bundler/index.rb11
-rw-r--r--lib/bundler/installer.rb11
-rw-r--r--lib/bundler/runtime.rb4
-rw-r--r--lib/bundler/source.rb28
6 files changed, 48 insertions, 16 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 38f28b9a63..ec5f8a50e0 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -99,8 +99,12 @@ module Bundler
home.join("gems")
end
+ def specs_path
+ bundle_path.join("specifications")
+ end
+
def cache
- bundle_path.join('cache/bundler')
+ bundle_path.join("cache/bundler")
end
def root
diff --git a/lib/bundler/environment.rb b/lib/bundler/environment.rb
index 872af35a3d..143eb3509d 100644
--- a/lib/bundler/environment.rb
+++ b/lib/bundler/environment.rb
@@ -30,6 +30,10 @@ module Bundler
private
+ def sources
+ @definition.sources
+ end
+
def runtime_gems
@runtime_gems ||= Index.build do |i|
sources.each do |s|
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index 1bdb29645f..fa9318480b 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -7,6 +7,17 @@ module Bundler
end
def self.installed_gems
+ build do |idx|
+ idx.use bundler_gems
+ idx.use system_gems
+ end
+ end
+
+ def self.bundler_gems
+ Source::BundlerGems.new.specs
+ end
+
+ def self.system_gems
Source::SystemGems.new.specs
end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index b3d62c2265..84c263c706 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -26,18 +26,15 @@ module Bundler
next
end
- Bundler.ui.info "Installing #{spec.name} (#{spec.version}) from #{spec.source} "
-
+ Bundler.ui.info "Bundling #{spec.name} (#{spec.version}) from #{spec.source}"
spec.source.install(spec)
-
- Bundler.ui.info ""
end
if locked?
write_rb_lock
end
- Bundler.ui.confirm "Your bundle is complete!"
+ Bundler.ui.confirm "Your bundle is complete! Use `bundle show gemname` to see where a bundled gem is installed."
end
def dependencies
@@ -50,10 +47,6 @@ module Bundler
private
- def sources
- @definition.sources
- end
-
def resolve_locally
# Return unless all the dependencies have = version requirements
return if actual_dependencies.any? { |d| ambiguous?(d) }
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index 7476efd84e..4677e4aa4a 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -95,10 +95,6 @@ module Bundler
private
- def sources
- @definition.sources
- end
-
def load_paths
specs.map { |s| s.load_paths }.flatten
end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 1ba6f0b7f4..0363fbd43e 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -80,7 +80,11 @@ module Bundler
@specs ||= begin
index = Index.new
- Gem::SourceIndex.from_installed_gems.to_a.reverse.each do |name, spec|
+ system_paths = Gem::SourceIndex.installed_spec_directories
+ system_paths.reject!{|d| d == Bundler.specs_path.to_s }
+
+ system_index = Gem::SourceIndex.from_gems_in(*system_paths)
+ system_index.to_a.reverse.each do |name, spec|
spec.source = self
index << spec
end
@@ -98,6 +102,26 @@ module Bundler
end
end
+ class BundlerGems < SystemGems
+ def specs
+ @specs ||= begin
+ index = Index.new
+
+ bundle_index = Gem::SourceIndex.from_gems_in(Bundler.specs_path)
+ bundle_index.to_a.reverse.each do |name, spec|
+ spec.source = self
+ index << spec
+ end
+
+ index
+ end
+ end
+
+ def to_s
+ "bundler gems"
+ end
+ end
+
class GemCache
def initialize(options)
@path = options["path"]
@@ -206,7 +230,7 @@ module Bundler
def generate_bin(spec)
gem_dir = spec.full_gem_path
- gem_file = nil # so we have access once after it's set in the block
+ gem_file = nil # so we have access after it's set in the block
Dir.chdir(gem_dir) do
gem_file = Gem::Builder.new(spec).build