diff options
author | Gonçalo Silva <goncalossilva@gmail.com> | 2011-05-08 03:54:55 +0100 |
---|---|---|
committer | Gonçalo Silva <goncalossilva@gmail.com> | 2011-05-08 03:54:55 +0100 |
commit | aec7456f81985b88d6d604679d754636183b5b3a (patch) | |
tree | 798fcab8ae0c6e2c8c5a63e1f39308ff4bb5a20c /railties/lib/rails/generators/app_base.rb | |
parent | 1c2b2233c3a7ec76c0a0eddf5b8be45c489be133 (diff) | |
parent | 70f9558d0e4b8e605576693cbb489caa5cf6a2bc (diff) | |
download | rails-aec7456f81985b88d6d604679d754636183b5b3a.tar.gz rails-aec7456f81985b88d6d604679d754636183b5b3a.tar.bz2 rails-aec7456f81985b88d6d604679d754636183b5b3a.zip |
Merge branch 'master' of https://github.com/rails/rails into performance_test
Conflicts:
activesupport/lib/active_support/testing/performance.rb
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 481fa95068..e8709b2ddd 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -10,7 +10,8 @@ module Rails module Generators class AppBase < Base DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) - JAVASCRIPTS = %w( jquery prototype ) + JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql ) + DATABASES.concat(JDBC_DATABASES) attr_accessor :rails_template add_shebang_option! @@ -36,8 +37,8 @@ module Rails class_option :database, :type => :string, :aliases => "-d", :default => "sqlite3", :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})" - class_option :javascript, :type => :string, :aliases => "-j", :default => "jquery", - :desc => "Preconfigure for selected JavaScript library (options: #{JAVASCRIPTS.join('/')})" + class_option :javascript, :type => :string, :aliases => '-j', :default => 'jquery', + :desc => 'Preconfigure for selected JavaScript library' class_option :skip_javascript, :type => :boolean, :aliases => "-J", :default => false, :desc => "Skip JavaScript files" @@ -116,31 +117,25 @@ module Rails 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}' - gem 'arel', :git => 'git://github.com/rails/arel.git' - gem 'rack', :git => 'git://github.com/rack/rack.git' - gem 'sprockets', :git => "git://github.com/sstephenson/sprockets.git" GEMFILE elsif options.edge? <<-GEMFILE.strip_heredoc gem 'rails', :git => 'git://github.com/rails/rails.git' - gem 'arel', :git => 'git://github.com/rails/arel.git' - gem 'rack', :git => 'git://github.com/rack/rack.git' - gem 'sprockets', :git => "git://github.com/sstephenson/sprockets.git" GEMFILE else <<-GEMFILE.strip_heredoc @@ -148,24 +143,24 @@ module Rails # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' - # gem 'arel', :git => 'git://github.com/rails/arel.git' - # gem 'rack', :git => 'git://github.com/rack/rack.git' - # gem 'sprockets', :git => "git://github.com/sstephenson/sprockets.git" GEMFILE end end def gem_for_database - # %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) + # %w( mysql oracle postgresql sqlite3 frontbase ibm_db jdbcmysql jdbcsqlite3 jdbcpostgresql ) case options[:database] when "oracle" then "ruby-oci8" when "postgresql" then "pg" when "frontbase" then "ruby-frontbase" when "mysql" then "mysql2" + when "jdbcmysql" then "activerecord-jdbcmysql-adapter" + when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter" + when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter" else options[:database] end end - + def gem_for_ruby_debugger if RUBY_VERSION < "1.9.2" "gem 'ruby-debug'" @@ -173,7 +168,7 @@ module Rails "gem 'ruby-debug19', :require => 'ruby-debug'" end end - + def gem_for_turn unless RUBY_VERSION < "1.9.2" <<-GEMFILE.strip_heredoc @@ -185,6 +180,10 @@ module Rails end end + 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? @@ -198,7 +197,7 @@ module Rails empty_directory(destination, config) git_keep(destination) end - + def git_keep(destination) create_file("#{destination}/.gitkeep") unless options[:skip_git] end @@ -214,4 +213,4 @@ module Rails end end end -end
\ No newline at end of file +end |