diff options
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 104 |
1 files changed, 57 insertions, 47 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 21a2ae4e28..b677e974c8 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -9,7 +9,7 @@ require 'uri' module Rails module Generators class AppBase < Base - DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) + DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver ) JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc ) DATABASES.concat(JDBC_DATABASES) @@ -49,6 +49,9 @@ module Rails class_option :skip_javascript, :type => :boolean, :aliases => "-J", :default => false, :desc => "Skip JavaScript files" + class_option :skip_index_html, :type => :boolean, :aliases => "-I", :default => false, + :desc => "Skip public/index.html and app/assets/images/rails.png files" + class_option :dev, :type => :boolean, :default => false, :desc => "Setup the #{name} with Gemfile pointing to your Rails checkout" @@ -60,9 +63,6 @@ module Rails class_option :help, :type => :boolean, :aliases => "-h", :group => :rails, :desc => "Show this help message and quit" - - class_option :old_style_hash, :type => :boolean, :default => false, - :desc => "Force using old style hash (:foo => 'bar') on Ruby >= 1.9" end def initialize(*args) @@ -123,7 +123,7 @@ module Rails end def database_gemfile_entry - options[:skip_active_record] ? "" : "gem '#{gem_for_database}'\n" + options[:skip_active_record] ? "" : "gem '#{gem_for_database}'" end def include_all_railties? @@ -138,28 +138,35 @@ module Rails if options.dev? <<-GEMFILE.strip_heredoc gem 'rails', :path => '#{Rails::Generators::RAILS_DEV_PATH}' + gem 'journey', :git => 'https://github.com/rails/journey.git' + gem 'arel', :git => 'https://github.com/rails/arel.git' + gem 'active_record_deprecated_finders', :git => 'git://github.com/rails/active_record_deprecated_finders.git' GEMFILE elsif options.edge? <<-GEMFILE.strip_heredoc - gem 'rails', :git => 'git://github.com/rails/rails.git' + gem 'rails', :git => 'https://github.com/rails/rails.git' + gem 'journey', :git => 'https://github.com/rails/journey.git' + gem 'arel', :git => 'https://github.com/rails/arel.git' + gem 'active_record_deprecated_finders', :git => 'git://github.com/rails/active_record_deprecated_finders.git' GEMFILE else <<-GEMFILE.strip_heredoc gem 'rails', '#{Rails::VERSION::STRING}' # Bundle edge Rails instead: - # gem 'rails', :git => 'git://github.com/rails/rails.git' + # gem 'rails', :git => 'https://github.com/rails/rails.git' GEMFILE end end def gem_for_database - # %w( mysql oracle postgresql sqlite3 frontbase ibm_db jdbcmysql jdbcsqlite3 jdbcpostgresql ) + # %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver 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 "oracle" then "ruby-oci8" + when "postgresql" then "pg" + when "frontbase" then "ruby-frontbase" + when "mysql" then "mysql2" + when "sqlserver" then "activerecord-sqlserver-adapter" when "jdbcmysql" then "activerecord-jdbcmysql-adapter" when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter" when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter" @@ -179,41 +186,54 @@ module Rails end end - def ruby_debugger_gemfile_entry - if RUBY_VERSION < "1.9" - "gem 'ruby-debug'" + def assets_gemfile_entry + return if options[:skip_sprockets] + + gemfile = if options.dev? || options.edge? + <<-GEMFILE + # Gems used only for assets and not required + # in production environments by default. + group :assets do + gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git' + gem 'sass-rails', :git => 'https://github.com/rails/sass-rails.git' + gem 'coffee-rails', :git => 'https://github.com/rails/coffee-rails.git' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + #{javascript_runtime_gemfile_entry} + gem 'uglifier', '>= 1.0.3' + end + GEMFILE else - "gem 'ruby-debug19', :require => 'ruby-debug'" - end - end - - def turn_gemfile_entry - unless RUBY_VERSION < "1.9.2" || options[:skip_test_unit] - <<-GEMFILE.strip_heredoc - group :test do - # Pretty printed test output - gem 'turn', :require => false + <<-GEMFILE + # Gems used only for assets and not required + # in production environments by default. + group :assets do + gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git' + gem 'sass-rails', '~> 4.0.0.beta' + gem 'coffee-rails', '~> 4.0.0.beta' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + #{javascript_runtime_gemfile_entry} + gem 'uglifier', '>= 1.0.3' end GEMFILE end - end - def assets_gemfile_entry - <<-GEMFILE.strip_heredoc - # Gems used only for assets and not required - # in production environments by default. - group :assets do - gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git' - gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails.git' - gem 'uglifier' - end - GEMFILE + gemfile.strip_heredoc.gsub(/^[ \t]*$/, '') end def javascript_gemfile_entry "gem '#{options[:javascript]}-rails'" unless options[:skip_javascript] end + def javascript_runtime_gemfile_entry + if defined?(JRUBY_VERSION) + "gem 'therubyrhino'\n" + else + "# gem 'therubyracer', :platform => :ruby\n" + end + end + def bundle_command(command) say_status :run, "bundle #{command}" @@ -231,7 +251,7 @@ module Rails end def run_bundle - bundle_command('install') unless options[:skip_gemfile] || options[:skip_bundle] + bundle_command('install') unless options[:skip_gemfile] || options[:skip_bundle] || options[:pretend] end def empty_directory_with_gitkeep(destination, config = {}) @@ -242,16 +262,6 @@ module Rails def git_keep(destination) create_file("#{destination}/.gitkeep") unless options[:skip_git] end - - # Returns Ruby 1.9 style key-value pair if current code is running on - # Ruby 1.9.x. Returns the old-style (with hash rocket) otherwise. - def key_value(key, value) - if options[:old_style_hash] || RUBY_VERSION < '1.9' - ":#{key} => #{value}" - else - "#{key}: #{value}" - end - end end end end |