diff options
author | Xavier Noria <fxn@hashref.com> | 2011-05-13 00:43:43 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-05-13 01:06:27 +0200 |
commit | c88dddbe4d40c9e0590df4d6f76c02c46448264d (patch) | |
tree | dd8ba047a85432af3d89937a10fcb54f7d296d82 /railties/lib | |
parent | 55d87d2b5c2d9176752ef62eaf0e8ef2e37ca52c (diff) | |
download | rails-c88dddbe4d40c9e0590df4d6f76c02c46448264d.tar.gz rails-c88dddbe4d40c9e0590df4d6f76c02c46448264d.tar.bz2 rails-c88dddbe4d40c9e0590df4d6f76c02c46448264d.zip |
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.
Diffstat (limited to 'railties/lib')
3 files changed, 16 insertions, 5 deletions
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 |