aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/app_base.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2013-11-02 18:25:02 +0000
committerJon Leighton <j@jonathanleighton.com>2013-12-03 23:07:40 +0000
commitdf50e3064abc3099adc524f381ffced0dab84869 (patch)
tree09b021abbcadd4beccc90eb7fd52f93ea2582f88 /railties/lib/rails/generators/app_base.rb
parentd5332de37963ab41372541fc8cf66f602663abf4 (diff)
downloadrails-df50e3064abc3099adc524f381ffced0dab84869.tar.gz
rails-df50e3064abc3099adc524f381ffced0dab84869.tar.bz2
rails-df50e3064abc3099adc524f381ffced0dab84869.zip
Install Spring preloader when generating new applications
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r--railties/lib/rails/generators/app_base.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 2022b4ed3d..5d4682f6e3 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -47,6 +47,9 @@ module Rails
class_option :skip_sprockets, type: :boolean, aliases: '-S', default: false,
desc: 'Skip Sprockets files'
+ class_option :skip_spring, type: :boolean, default: false,
+ desc: "Don't install Spring application preloader"
+
class_option :database, type: :string, aliases: '-d', default: 'sqlite3',
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
@@ -109,6 +112,7 @@ module Rails
jbuilder_gemfile_entry,
sdoc_gemfile_entry,
platform_dependent_gemfile_entry,
+ spring_gemfile_entry,
@extra_entries].flatten.find_all(&@gem_filter)
end
@@ -365,6 +369,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/jonleighton/spring'
+ GemfileEntry.new('spring', nil, comment, group: :development)
+ end
+
def bundle_command(command)
say_status :run, "bundle #{command}"
@@ -388,8 +398,22 @@ module Rails
end
end
+ def bundle_install?
+ !(options[:skip_gemfile] || options[:skip_bundle] || options[:pretend])
+ end
+
+ def spring_install?
+ !options[:skip_spring] && Process.respond_to?(:fork)
+ end
+
def run_bundle
- bundle_command('install') unless options[:skip_gemfile] || options[:skip_bundle] || options[:pretend]
+ bundle_command('install') if bundle_install?
+ end
+
+ def generate_spring_binstubs
+ if bundle_install? && spring_install?
+ bundle_command("exec spring binstub --all")
+ end
end
def empty_directory_with_keep_file(destination, config = {})