Permalink
Browse files

Continuing moving away from environment-centric view. Hax.

  • Loading branch information...
1 parent ecf9a79 commit a0b4eafff9e75f10edfa24be3332a4f393415940 Carlhuda committed Dec 11, 2009
Showing with 53 additions and 18 deletions.
  1. +10 −1 lib/bundler/bundle.rb
  2. +2 −2 lib/bundler/cli.rb
  3. +4 −15 lib/bundler/environment.rb
  4. +37 −0 spec/bundler/cli_spec.rb
View
@@ -128,7 +128,9 @@ def list_outdated(options={})
end
end
- def prune(dependencies, sources)
+ def prune(options = {})
+ dependencies, sources = @environment.gem_dependencies, @environment.sources
+
sources.each do |s|
s.repository = self
s.local = true
@@ -146,6 +148,13 @@ def prune(dependencies, sources)
end
end
+ def list(options = {})
+ Bundler.logger.info "Currently bundled gems:"
+ gems.each do |spec|
+ Bundler.logger.info " * #{spec.name} (#{spec.version})"
+ end
+ end
+
def gems
source_index.gems.values
end
View
@@ -45,11 +45,11 @@ def cache
end
def prune
- @environment.prune(@options)
+ @bundle.prune(@options)
end
def list
- @environment.list(@options)
+ @bundle.list(@options)
end
def list_outdated
View
@@ -43,17 +43,6 @@ def install(options = {})
Bundler.logger.info "Done."
end
- def prune(options = {})
- repository.prune(gem_dependencies, sources)
- end
-
- def list(options = {})
- Bundler.logger.info "Currently bundled gems:"
- repository.gems.each do |spec|
- Bundler.logger.info " * #{spec.name} (#{spec.version})"
- end
- end
-
def require_env(env = nil)
dependencies.each { |d| d.require_env(env) }
end
@@ -87,6 +76,10 @@ def clear_sources
@default_sources.clear
end
+ def gem_dependencies
+ @gem_dependencies ||= dependencies.map { |d| d.to_gem_dependency }
+ end
+
private
def default_sources
@@ -96,9 +89,5 @@ def default_sources
def repository
@repository ||= Bundle.new(self)
end
-
- def gem_dependencies
- @gem_dependencies ||= dependencies.map { |d| d.to_gem_dependency }
- end
end
end
View
@@ -461,6 +461,43 @@
end
end
+ describe "pruning the cache" do
+ it "works" do
+ install_manifest <<-Gemfile
+ clear_sources
+ source "file://#{gem_repo1}"
+ gem "rack", "0.9.1"
+ Gemfile
+
+ bundled_app("vendor", "gems").should have_cached_gems("rack-0.9.1")
+
+ install_manifest <<-Gemfile
+ clear_sources
+ source "file://#{gem_repo1}"
+ Gemfile
+
+ bundled_app("vendor", "gems").should have_cached_gems("rack-0.9.1")
+ Dir.chdir bundled_app
+ out = gem_command :bundle, "--prune-cache"
+ puts out
+ bundled_app("vendor", "gems").should_not have_cached_gems("rack-0.9.1")
+ end
+ end
+
+ describe "listing gems" do
+ it "works" do
+ install_manifest <<-Gemfile
+ clear_sources
+ source "file://#{gem_repo1}"
+ gem "rack", "0.9.1"
+ Gemfile
+
+ Dir.chdir bundled_app
+ out = gem_command :bundle, "--list"
+ out.should =~ /rack/
+ end
+ end
+
describe "listing outdated gems" do
it "shows a message when there are no outdated gems" do
m = build_manifest <<-Gemfile

0 comments on commit a0b4eaf

Please sign in to comment.