From c88dddbe4d40c9e0590df4d6f76c02c46448264d Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 13 May 2011 00:43:43 +0200 Subject: application and plugin generation run bundle check unless --skip-gemfile The purpose of this feature is that the user knows whether dependencies are satisfied. In particular, if they are not he will be warned upfront, rather than finding out himself in an abrupt way by trying to run something. --- railties/lib/rails/generators/app_base.rb | 17 ++++++++++++++--- .../lib/rails/generators/rails/app/app_generator.rb | 2 +- .../generators/rails/plugin_new/plugin_new_generator.rb | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'railties/lib/rails/generators') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index e8709b2ddd..5d4afc8102 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -184,9 +184,20 @@ module Rails "gem '#{options[:javascript]}-rails'" unless options[:skip_javascript] end - def bundle_if_dev_or_edge - bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle') - run "#{bundle_command} install" if dev_or_edge? + def bundle_command(command) + # We use backticks and #print here instead of vanilla #system because it + # is easier to silence stdout in the existing test suite this way. The + # end-user gets the bundler commands called anyway. + # + # Thanks to James Tucker for the Gem tricks involved in this call. + print `"#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" #{command}` + end + + def run_bundle + unless options[:skip_gemfile] + command = dev_or_edge? ? 'install' : 'check' + bundle_command(command) + end end def dev_or_edge? diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index ed3bf15ca9..03c74143d0 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -225,7 +225,7 @@ module Rails build(:leftovers) end - public_task :apply_rails_template, :bundle_if_dev_or_edge + public_task :apply_rails_template, :run_bundle protected diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index 6201595308..939c0cd727 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -209,7 +209,7 @@ task :default => :test build(:leftovers) end - public_task :apply_rails_template, :bundle_if_dev_or_edge + public_task :apply_rails_template, :run_bundle protected -- cgit v1.2.3