Permalink
Browse files

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.
  • Loading branch information...
indirect committed Mar 27, 2010
1 parent 93d2a24 commit 0d92de7842d3b7260671944bc804c110fa1a7fcd
Showing with 48 additions and 16 deletions.
  1. +5 −1 lib/bundler.rb
  2. +4 −0 lib/bundler/environment.rb
  3. +11 −0 lib/bundler/index.rb
  4. +2 −9 lib/bundler/installer.rb
  5. +0 −4 lib/bundler/runtime.rb
  6. +26 −2 lib/bundler/source.rb
View
@@ -99,8 +99,12 @@ def install_path
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
@@ -30,6 +30,10 @@ def specs
private
+ def sources
+ @definition.sources
+ end
+
def runtime_gems
@runtime_gems ||= Index.build do |i|
sources.each do |s|
View
@@ -7,6 +7,17 @@ def self.build
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
View
@@ -26,18 +26,15 @@ def run(options)
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 @@ def resolved_dependencies
private
- def sources
- @definition.sources
- end
-
def resolve_locally
# Return unless all the dependencies have = version requirements
return if resolved_dependencies.any? { |d| ambiguous?(d) }
View
@@ -95,10 +95,6 @@ def cache
private
- def sources
- @definition.sources
- end
-
def load_paths
specs.map { |s| s.load_paths }.flatten
end
View
@@ -80,7 +80,11 @@ def specs
@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 @@ def install(spec)
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 @@ def install(spec)
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

0 comments on commit 0d92de7

Please sign in to comment.