aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/app_base.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2011-05-02 00:59:57 +0200
committerXavier Noria <fxn@hashref.com>2011-05-04 10:33:53 +0200
commitd9c39c3ae9aa9d0f50a4b557781be39e39e5b752 (patch)
treefeab3d5b27ae177f71cdcd043aadb5d8cb6bbf23 /railties/lib/rails/generators/app_base.rb
parent5d2cdb190ad4eb35ab78180b2fd2e72a3d7a61f7 (diff)
downloadrails-d9c39c3ae9aa9d0f50a4b557781be39e39e5b752.tar.gz
rails-d9c39c3ae9aa9d0f50a4b557781be39e39e5b752.tar.bz2
rails-d9c39c3ae9aa9d0f50a4b557781be39e39e5b752.zip
restores the -j option, but now it accepts the name of any library
If passed "foo", a gem "foo-rails" is added to the Gemfile and "foo" and "foo_ujs" are required in the application JavaScript manifest.
Diffstat (limited to 'railties/lib/rails/generators/app_base.rb')
-rw-r--r--railties/lib/rails/generators/app_base.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index b5110fa9b7..998957f313 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -12,7 +12,6 @@ module Rails
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql )
DATABASES.concat(JDBC_DATABASES)
- JAVASCRIPTS = %w( jquery prototype )
attr_accessor :rails_template
add_shebang_option!
@@ -38,6 +37,9 @@ 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'
+
class_option :skip_javascript, :type => :boolean, :aliases => "-J", :default => false,
:desc => "Skip JavaScript files"
@@ -178,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?