aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/app_base.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r--railties/lib/rails/generators/app_base.rb51
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