Skip to content

Commit

Permalink
Allow clearing --without groups
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Sep 18, 2011
1 parent 73b04ed commit 83dbe36
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
9 changes: 4 additions & 5 deletions lib/bundler/cli.rb
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions lib/bundler/settings.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions spec/install/gems/groups_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 83dbe36

Please sign in to comment.