diff options
author | Homu <homu@barosl.com> | 2016-02-27 07:48:21 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-02-27 07:48:21 +0900 |
commit | f819834287274aa78d0fd03ac5685cf543cd68e4 (patch) | |
tree | fb8f1c68db281827f5d468aa3351f92995617c61 | |
parent | 4786adb75e2e2fec2dde60618b53132ef7b03cdb (diff) | |
parent | 49744f57a175dc5d71b380c17d460cbb9a71b046 (diff) | |
download | bundler-f819834287274aa78d0fd03ac5685cf543cd68e4.tar.gz |
Auto merge of #4304 - mobilutz:master, r=indirect
Bundle Viz : Options without can have multiple values
I wanted to only have one 'environment' when calling `bundle viz`. There is the options `--without`, but passing two arguments or some other form of array was not possible.
Maybe this is not the best solution. But it works for me.
The format for the option is `--without=development,test`.
-rw-r--r-- | lib/bundler/cli.rb | 12 | ||||
-rw-r--r-- | lib/bundler/cli/viz.rb | 3 | ||||
-rw-r--r-- | spec/commands/viz_spec.rb | 34 |
3 files changed, 43 insertions, 6 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 0bd82fd128..e652bfd6e1 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -359,14 +359,14 @@ module Bundler Viz requires the ruby-graphviz gem (and its dependencies). The associated gems must also be installed via 'bundle install'. D - method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :banner => "The name to use for the generated file. see format option" - method_option :format, :type => :string, :default => "png", :aliases => "-F", :banner => "This is output format option. Supported format is png, jpg, svg, dot ..." - method_option :requirements, :type => :boolean, :default => false, :aliases => "-r", :banner => "Set to show the version of each required dependency." - method_option :version, :type => :boolean, :default => false, :aliases => "-v", :banner => "Set to show each gem version." - method_option :without, :type => :array, :default => [], :banner => "Exclude gems that are part of the specified named group." + method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option" + method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..." + method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency." + method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version." + method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group." def viz require "bundler/cli/viz" - Viz.new(options).run + Viz.new(options.dup).run end desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a rubygem" diff --git a/lib/bundler/cli/viz.rb b/lib/bundler/cli/viz.rb index 7ccd306d63..75e6affff9 100644 --- a/lib/bundler/cli/viz.rb +++ b/lib/bundler/cli/viz.rb @@ -8,7 +8,10 @@ module Bundler def run require "graphviz" + + options[:without] = options[:without].join(":").tr(" ", ":").split(":") output_file = File.expand_path(options[:file]) + graph = Graph.new(Bundler.load, output_file, options[:version], options[:requirements], options[:format], options[:without]) graph.viz rescue LoadError => e diff --git a/spec/commands/viz_spec.rb b/spec/commands/viz_spec.rb index c680568899..20dc9175d9 100644 --- a/spec/commands/viz_spec.rb +++ b/spec/commands/viz_spec.rb @@ -32,4 +32,38 @@ describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do bundle "viz", :env => { "RUBYOPT" => "-I #{graphviz_lib}" } expect(out).to include("gem_graph.png") end + + context "--without option" do + it "one group" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "activesupport" + + group :rails do + gem "rails" + end + G + + bundle "viz --without=rails", :env => { "RUBYOPT" => "-I #{graphviz_lib}" } + expect(out).to include("gem_graph.png") + end + + it "two groups" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "activesupport" + + group :rack do + gem "rack" + end + + group :rails do + gem "rails" + end + G + + bundle "viz --without=rails:rack", :env => { "RUBYOPT" => "-I #{graphviz_lib}" } + expect(out).to include("gem_graph.png") + end + end end |