summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-29 15:45:42 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-29 15:45:42 -0700
commit4eaf065c6944ba385cbd57a874c3c0767bb269a4 (patch)
tree8c9a6cf9aa6501032d0474899b42350ee4b6d022
parent81016a8c0bcc747138dc2545ae171b829c4f173f (diff)
downloadbundler-4eaf065c6944ba385cbd57a874c3c0767bb269a4.tar.gz
Add an --update flag to the cli tool
-rw-r--r--lib/bundler/cli.rb6
-rw-r--r--lib/bundler/manifest.rb8
-rw-r--r--lib/bundler/manifest_file.rb4
-rw-r--r--spec/bundler/cli_spec.rb27
4 files changed, 38 insertions, 7 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index a591449b10..092a63d80f 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -15,7 +15,7 @@ module Bundler
manifest_file = Bundler::ManifestFile.load(@manifest)
if @args.empty?
- manifest_file.install
+ manifest_file.install(@update)
else
manifest_file.setup_environment
exec(*@args)
@@ -42,6 +42,10 @@ module Bundler
@manifest = Pathname.new(manifest)
end
+ op.on("-u", "--update", "Force a remote check for newer gems") do
+ @update = true
+ end
+
op.on_tail("-h", "--help", "Show this message") do
puts op
exit
diff --git a/lib/bundler/manifest.rb b/lib/bundler/manifest.rb
index c9ec1622f6..690e419155 100644
--- a/lib/bundler/manifest.rb
+++ b/lib/bundler/manifest.rb
@@ -16,8 +16,8 @@ module Bundler
@system_gems = system_gems
end
- def install
- fetch
+ def install(update)
+ fetch(update)
@repository.install_cached_gems(:bin_dir => @bindir || @repository.path.join("bin"))
cleanup_removed_gems
create_environment_files(@repository.path.join("environments"))
@@ -49,8 +49,8 @@ module Bundler
private
- def fetch
- return if all_gems_installed?
+ def fetch(update)
+ return unless update || !all_gems_installed?
finder = Finder.new(*sources)
unless bundle = finder.resolve(*gem_dependencies)
diff --git a/lib/bundler/manifest_file.rb b/lib/bundler/manifest_file.rb
index a24bbbaa33..0af486ecf5 100644
--- a/lib/bundler/manifest_file.rb
+++ b/lib/bundler/manifest_file.rb
@@ -26,8 +26,8 @@ module Bundler
@manifest ||= load_manifest
end
- def install
- manifest.install
+ def install(update = false)
+ manifest.install(update)
end
def setup_environment
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index e519e9a790..4e2add24a6 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -156,4 +156,31 @@ describe "Bundler::CLI" do
out.should == "#{Gem.ruby}\n"
end
end
+
+ describe "forcing an update" do
+ it "forces checking for remote updates if --update is used" do
+ m = build_manifest <<-Gemfile
+ sources.clear
+ source "file://#{gem_repo1}"
+ source "file://#{gem_repo2}"
+ gem "rack", "0.9.1"
+ Gemfile
+ m.install
+
+ build_manifest <<-Gemfile
+ sources.clear
+ source "file://#{gem_repo1}"
+ source "file://#{gem_repo2}"
+ gem "rack"
+ Gemfile
+
+ lib = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
+ bin = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'gem_bundler'))
+ Dir.chdir(tmp_dir) do
+ `#{Gem.ruby} -I #{lib} #{bin} --update`
+ end
+ tmp_file("vendor", "gems").should have_cached_gems("rack-1.0.0")
+ tmp_file("vendor", "gems").should have_installed_gems("rack-1.0.0")
+ end
+ end
end