Add a generic --skip-gems options to generator

Also remove --skip-turbolinks.

This option is useful if users want to remove some gems like jbuilder,
turbolinks, coffee-rails, etc that don't have specific options on the
generator.

    rails new my_app --skip-gems turbolinks coffee-rails
上级 43262ea8
* Add a generic --skip-gems options to generator
This option is useful if users want to remove some gems like jbuilder,
turbolinks, coffee-rails, etc that don't have specific options on the
generator.
rails new my_app --skip-gems turbolinks coffee-rails
*Rafael Mendonça França*
* Invalid `bin/rails generate` commands will now show spelling suggestions.
*Richard Schneeman*
......
......@@ -41,6 +41,9 @@ def self.add_shared_options_for(name)
class_option :skip_active_record, type: :boolean, aliases: '-O', default: false,
desc: 'Skip Active Record files'
class_option :skip_gems, type: :array, default: [],
desc: 'Skip the provided gems files'
class_option :skip_action_view, type: :boolean, aliases: '-V', default: false,
desc: 'Skip Action View files'
......@@ -50,9 +53,6 @@ def self.add_shared_options_for(name)
class_option :skip_spring, type: :boolean, default: false,
desc: "Don't install Spring application preloader"
class_option :skip_turbolinks, type: :boolean, default: false,
desc: "Don't install Turbolinks"
class_option :database, type: :string, aliases: '-d', default: 'sqlite3',
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
......@@ -82,7 +82,7 @@ def self.add_shared_options_for(name)
end
def initialize(*args)
@gem_filter = lambda { |gem| true }
@gem_filter = lambda { |gem| !options[:skip_gems].include?(gem.name) }
@extra_entries = []
super
convert_database_option_for_jruby
......@@ -290,10 +290,8 @@ def javascript_gemfile_entry
gems << GemfileEntry.version("#{options[:javascript]}-rails", nil,
"Use #{options[:javascript]} as the JavaScript library")
unless options[:skip_turbolinks]
gems << GemfileEntry.version("turbolinks", nil,
"Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks")
end
gems << GemfileEntry.version("turbolinks", nil,
"Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks")
gems
end
end
......
......@@ -448,11 +448,12 @@ def test_skip_spring
end
end
def test_skip_turbolinks
run_generator [destination_root, "--skip-turbolinks"]
def test_generator_if_skip_gems_is_given
run_generator [destination_root, "--skip-gems", "turbolinks", "coffee-rails"]
assert_file "Gemfile" do |content|
assert_no_match(/turbolinks/, content)
assert_no_match(/coffee-rails/, content)
end
assert_file "app/views/layouts/application.html.erb" do |content|
assert_no_match(/data-turbolinks-track/, content)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册