diff options
-rw-r--r-- | lib/bundler/cli.rb | 6 | ||||
-rw-r--r-- | lib/bundler/manifest.rb | 8 | ||||
-rw-r--r-- | lib/bundler/manifest_file.rb | 4 | ||||
-rw-r--r-- | spec/bundler/cli_spec.rb | 27 |
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 |