From 83dbe36e70f75c767bbadf25242c4659d5ecb042 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sat, 17 Sep 2011 19:28:56 -0700 Subject: [PATCH] Allow clearing --without groups fixes #1259 --- lib/bundler/cli.rb | 9 ++++----- lib/bundler/settings.rb | 5 ++--- spec/install/gems/groups_spec.rb | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 8839c8c4307..7b5f63d9ce8 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -150,12 +150,11 @@ def check "Install using defaults tuned for deployment environments" def install(path = nil) opts = options.dup - opts[:without] ||= [] - if opts[:without].size == 1 - opts[:without] = opts[:without].map{|g| g.split(" ") } + if opts[:without] + opts[:without].map!{|g| g.split(" ") } opts[:without].flatten! + opts[:without].map!{|g| g.to_sym } end - opts[:without] = opts[:without].map{|g| g.to_sym } # Can't use Bundler.settings for this because settings needs gemfile.dirname ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile] @@ -214,7 +213,7 @@ def install(path = nil) Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs] Bundler.settings[:no_prune] = true if opts["no-prune"] Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil - Bundler.settings.without = opts[:without] unless opts[:without].empty? + Bundler.settings.without = opts[:without] Bundler.ui.be_quiet! if opts[:quiet] Installer.install(Bundler.root, Bundler.definition, opts) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index c3209c3ad3e..a663eb8f79d 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -62,9 +62,7 @@ def pretty_values_for(exposed_key) end def without=(array) - unless array.empty? - self[:without] = array.join(":") - end + self[:without] = (array.empty? ? nil : array.join(":")) if array end def without @@ -95,6 +93,7 @@ def key_for(key) def set_key(key, value, hash, file) key = key_for(key) + puts key.inspect unless hash[key] == value hash[key] = value diff --git a/spec/install/gems/groups_spec.rb b/spec/install/gems/groups_spec.rb index 51865ab6217..af3cdab31f4 100644 --- a/spec/install/gems/groups_spec.rb +++ b/spec/install/gems/groups_spec.rb @@ -136,6 +136,20 @@ ENV["BUNDLE_WITHOUT"] = nil end + + it "clears without when passed an empty list" do + bundle :install, :without => "emo" + + bundle 'install --without ""' + should_be_installed "activesupport 2.3.5" + end + + it "doesn't clear without when nothing is passed" do + bundle :install, :without => "emo" + + bundle :install + should_not_be_installed "activesupport 2.3.5" + end end describe "with gems assigned to multiple groups" do