diff options
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 89 |
1 files changed, 47 insertions, 42 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 569afe8104..71186891a3 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -38,12 +38,13 @@ module Rails class_option :skip_keeps, type: :boolean, default: false, desc: 'Skip source control .keep files' + class_option :skip_action_mailer, type: :boolean, aliases: "-M", + default: false, + desc: "Skip Action Mailer files" + class_option :skip_active_record, type: :boolean, aliases: '-O', default: false, desc: 'Skip Active Record files' - class_option :skip_action_view, type: :boolean, aliases: '-V', default: false, - desc: 'Skip Action View files' - class_option :skip_sprockets, type: :boolean, aliases: '-S', default: false, desc: 'Skip Sprockets files' @@ -65,6 +66,9 @@ module Rails class_option :edge, type: :boolean, default: false, desc: "Setup the #{name} with Gemfile pointing to Rails repository" + class_option :skip_turbolinks, type: :boolean, default: false, + desc: 'Skip turbolinks gem' + class_option :skip_test_unit, type: :boolean, aliases: '-T', default: false, desc: 'Skip Test::Unit files' @@ -104,14 +108,14 @@ module Rails end def gemfile_entries - [ rails_gemfile_entry, - database_gemfile_entry, - assets_gemfile_entry, - javascript_gemfile_entry, - jbuilder_gemfile_entry, - sdoc_gemfile_entry, - spring_gemfile_entry, - @extra_entries].flatten.find_all(&@gem_filter) + [rails_gemfile_entry, + database_gemfile_entry, + assets_gemfile_entry, + javascript_gemfile_entry, + jbuilder_gemfile_entry, + sdoc_gemfile_entry, + psych_gemfile_entry, + @extra_entries].flatten.find_all(&@gem_filter) end def add_gem_entry_filter @@ -164,7 +168,7 @@ module Rails end def include_all_railties? - !options[:skip_active_record] && !options[:skip_action_view] && !options[:skip_test_unit] && !options[:skip_sprockets] + options.values_at(:skip_active_record, :skip_action_mailer, :skip_test_unit, :skip_sprockets).none? end def comment_if(value) @@ -180,8 +184,12 @@ module Rails super end - def self.github(name, github, comment = nil) - new(name, nil, comment, github: github) + def self.github(name, github, branch = nil, comment = nil) + if branch + new(name, nil, comment, github: github, branch: branch) + else + new(name, nil, comment, github: github) + end end def self.version(name, version, comment = nil) @@ -191,19 +199,19 @@ module Rails def self.path(name, path, comment = nil) new(name, nil, comment, path: path) end - - def padding(max_width) - ' ' * (max_width - name.length + 2) - end end def rails_gemfile_entry if options.dev? - [GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH), - GemfileEntry.github('arel', 'rails/arel')] + [ + GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH), + GemfileEntry.github('arel', 'rails/arel') + ] elsif options.edge? - [GemfileEntry.github('rails', 'rails/rails'), - GemfileEntry.github('arel', 'rails/arel')] + [ + GemfileEntry.github('rails', 'rails/rails'), + GemfileEntry.github('arel', 'rails/arel') + ] else [GemfileEntry.version('rails', Rails::VERSION::STRING, @@ -242,16 +250,8 @@ module Rails return [] if options[:skip_sprockets] gems = [] - if options.dev? || options.edge? - gems << GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails', - 'Use edge version of sprockets-rails') - gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', - 'Use SCSS for stylesheets') - else - gems << GemfileEntry.version('sass-rails', - '~> 4.0.3', + gems << GemfileEntry.version('sass-rails', '~> 5.0', 'Use SCSS for stylesheets') - end gems << GemfileEntry.version('uglifier', '>= 1.3.0', @@ -271,11 +271,11 @@ module Rails end def coffee_gemfile_entry - comment = 'Use CoffeeScript for .js.coffee assets and views' + comment = 'Use CoffeeScript for .coffee assets and views' if options.dev? || options.edge? - GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', comment + GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', nil, comment else - GemfileEntry.version 'coffee-rails', '~> 4.0.0', comment + GemfileEntry.version 'coffee-rails', '~> 4.1.0', comment end end @@ -285,10 +285,13 @@ module Rails else gems = [coffee_gemfile_entry, javascript_runtime_gemfile_entry] gems << GemfileEntry.version("#{options[:javascript]}-rails", nil, - "Use #{options[:javascript]} as the JavaScript library") + "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 @@ -302,10 +305,12 @@ module Rails end end - def spring_gemfile_entry - return [] unless spring_install? - comment = 'Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring' - GemfileEntry.new('spring', nil, comment, group: :development) + def psych_gemfile_entry + return [] unless defined?(Rubinius) + + comment = 'Use Psych as the YAML engine, instead of Syck, so serialized ' \ + 'data can be read safely from different rubies (see http://git.io/uuLVag)' + GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx) end def bundle_command(command) @@ -337,7 +342,7 @@ module Rails end def spring_install? - !options[:skip_spring] && Process.respond_to?(:fork) + !options[:skip_spring] && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin") end def run_bundle |