diff options
author | Andre Arko <andre@arko.net> | 2011-09-17 19:28:56 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2011-09-17 19:28:57 -0700 |
commit | 83dbe36e70f75c767bbadf25242c4659d5ecb042 (patch) | |
tree | 771e590f277e3ebf7249757695409e0069801c7d | |
parent | 73b04ed902aa0265f70ea8fc54b018de554674e0 (diff) | |
download | bundler-83dbe36e70f75c767bbadf25242c4659d5ecb042.tar.gz |
Allow clearing --without groups
fixes #1259
-rw-r--r-- | lib/bundler/cli.rb | 9 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 5 | ||||
-rw-r--r-- | 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 8839c8c430..7b5f63d9ce 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -150,12 +150,11 @@ module Bundler "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 @@ module Bundler 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 c3209c3ad3..a663eb8f79 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -62,9 +62,7 @@ module Bundler 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 @@ module Bundler 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 51865ab621..af3cdab31f 100644 --- a/spec/install/gems/groups_spec.rb +++ b/spec/install/gems/groups_spec.rb @@ -136,6 +136,20 @@ describe "bundle install with gem sources" do 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 |