From d9c39c3ae9aa9d0f50a4b557781be39e39e5b752 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 2 May 2011 00:59:57 +0200 Subject: 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. --- railties/lib/rails/generators/app_base.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/generators/app_base.rb') 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? -- cgit v1.2.3