lib/rails/generators/app_base.rb in railties-3.1.0.beta1 vs lib/rails/generators/app_base.rb in railties-3.1.0.rc1
- old
+ new
@@ -26,10 +26,13 @@
:desc => "Path to an #{name} template (can be a filesystem path or URL)"
class_option :skip_gemfile, :type => :boolean, :default => false,
:desc => "Don't create a Gemfile"
+ class_option :skip_bundle, :type => :boolean, :default => false,
+ :desc => "Don't run bundle install"
+
class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
:desc => "Skip Git ignores and keeps"
class_option :skip_active_record, :type => :boolean, :aliases => "-O", :default => false,
:desc => "Skip Active Record files"
@@ -115,21 +118,21 @@
options[:template]
end
end
def database_gemfile_entry
- entry = options[:skip_active_record] ? "" : "gem '#{gem_for_database}'"
- if options[:database] == 'mysql'
- if options.dev? || options.edge?
- entry += ", :git => 'git://github.com/brianmario/mysql2.git'"
- else
- entry += "\n# gem 'mysql2', :git => 'git://github.com/brianmario/mysql2.git'"
- end
- end
- entry + "\n"
+ options[:skip_active_record] ? "" : "gem '#{gem_for_database}'\n"
end
+ def include_all_railties?
+ !options[:skip_active_record] && !options[:skip_test_unit]
+ end
+
+ def comment_if(value)
+ options[value] ? '#' : ''
+ end
+
def rails_gemfile_entry
if options.dev?
<<-GEMFILE.strip_heredoc
gem 'rails', :path => '#{Rails::Generators::RAILS_DEV_PATH}'
GEMFILE
@@ -160,19 +163,19 @@
else options[:database]
end
end
def gem_for_ruby_debugger
- if RUBY_VERSION < "1.9.2"
+ if RUBY_VERSION < "1.9"
"gem 'ruby-debug'"
else
"gem 'ruby-debug19', :require => 'ruby-debug'"
end
end
def gem_for_turn
- unless RUBY_VERSION < "1.9.2"
+ unless RUBY_VERSION < "1.9.2" || options[:skip_test_unit]
<<-GEMFILE.strip_heredoc
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
@@ -182,16 +185,21 @@
def gem_for_javascript
"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)
+ require 'bundler'
+ require 'bundler/cli'
+
+ say_status :run, "bundle #{command}"
+ Bundler::CLI.new.send(command)
+ rescue
+ say_status :failure, "bundler raised an exception, are you offline?", :red
end
- def dev_or_edge?
- options.dev? || options.edge?
+ def run_bundle
+ bundle_command('install') unless options[:skip_gemfile] || options[:skip_bundle]
end
def empty_directory_with_gitkeep(destination, config = {})
empty_directory(destination, config)
git_keep(destination)