aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/tasks')
-rw-r--r--railties/lib/tasks/databases.rake14
-rw-r--r--railties/lib/tasks/framework.rake22
-rw-r--r--railties/lib/tasks/middleware.rake7
-rw-r--r--railties/lib/tasks/misc.rake6
-rw-r--r--railties/lib/tasks/statistics.rake1
-rw-r--r--railties/lib/tasks/testing.rake8
6 files changed, 47 insertions, 11 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 5cb27f1f10..a90c1d4a77 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -1,7 +1,12 @@
namespace :db do
+ task :load_config => :rails_env do
+ require 'active_record'
+ ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration
+ end
+
namespace :create do
desc 'Create all the local databases defined in config/database.yml'
- task :all => :environment do
+ task :all => :load_config do
ActiveRecord::Base.configurations.each_value do |config|
# Skip entries that don't have a database key, such as the first entry here:
#
@@ -22,7 +27,7 @@ namespace :db do
end
desc 'Create the database defined in config/database.yml for the current RAILS_ENV'
- task :create => :environment do
+ task :create => :load_config do
create_database(ActiveRecord::Base.configurations[RAILS_ENV])
end
@@ -76,7 +81,7 @@ namespace :db do
namespace :drop do
desc 'Drops all the local databases defined in config/database.yml'
- task :all => :environment do
+ task :all => :load_config do
ActiveRecord::Base.configurations.each_value do |config|
# Skip entries that don't have a database key
next unless config['database']
@@ -87,7 +92,7 @@ namespace :db do
end
desc 'Drops the database for the current RAILS_ENV'
- task :drop => :environment do
+ task :drop => :load_config do
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
begin
drop_database(config)
@@ -393,6 +398,7 @@ end
def drop_database(config)
case config['adapter']
when 'mysql'
+ ActiveRecord::Base.establish_connection(config)
ActiveRecord::Base.connection.drop_database config['database']
when /^sqlite/
FileUtils.rm(File.join(RAILS_ROOT, config['database']))
diff --git a/railties/lib/tasks/framework.rake b/railties/lib/tasks/framework.rake
index 66ab78c3b2..d639214ffe 100644
--- a/railties/lib/tasks/framework.rake
+++ b/railties/lib/tasks/framework.rake
@@ -5,7 +5,6 @@ namespace :rails do
deps = %w(actionpack activerecord actionmailer activesupport activeresource)
require 'rubygems'
require 'rubygems/gem_runner'
- Gem.manage_gems
rails = (version = ENV['VERSION']) ?
Gem.cache.find_name('rails', "= #{version}").first :
@@ -79,7 +78,7 @@ namespace :rails do
end
desc "Update both configs, scripts and public/javascripts from Rails"
- task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
+ task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ]
namespace :update do
desc "Add new scripts to the application script/ directory"
@@ -115,5 +114,24 @@ namespace :rails do
require 'railties_path'
FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')
end
+
+ desc "Rename application.rb to application_controller.rb"
+ task :application_controller do
+ old_style = RAILS_ROOT + '/app/controllers/application.rb'
+ new_style = RAILS_ROOT + '/app/controllers/application_controller.rb'
+ if File.exists?(old_style) && !File.exists?(new_style)
+ FileUtils.mv(old_style, new_style)
+ puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary"
+ end
+ end
+
+ desc "Generate dispatcher files in RAILS_ROOT/public"
+ task :generate_dispatchers do
+ require 'railties_path'
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru')
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi')
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb')
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi')
+ end
end
end
diff --git a/railties/lib/tasks/middleware.rake b/railties/lib/tasks/middleware.rake
new file mode 100644
index 0000000000..e0dcf50307
--- /dev/null
+++ b/railties/lib/tasks/middleware.rake
@@ -0,0 +1,7 @@
+desc 'Prints out your Rack middleware stack'
+task :middleware => :environment do
+ ActionController::Dispatcher.middleware.each do |middleware|
+ puts "use #{middleware.inspect}"
+ end
+ puts "run ActionController::Dispatcher.new"
+end
diff --git a/railties/lib/tasks/misc.rake b/railties/lib/tasks/misc.rake
index 5c99725203..411750bf40 100644
--- a/railties/lib/tasks/misc.rake
+++ b/railties/lib/tasks/misc.rake
@@ -3,6 +3,12 @@ task :environment do
require(File.join(RAILS_ROOT, 'config', 'environment'))
end
+task :rails_env do
+ unless defined? RAILS_ENV
+ RAILS_ENV = ENV['RAILS_ENV'] ||= 'development'
+ end
+end
+
desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions.'
task :secret do
puts ActiveSupport::SecureRandom.hex(64)
diff --git a/railties/lib/tasks/statistics.rake b/railties/lib/tasks/statistics.rake
index dbd0773194..5ab27a0f62 100644
--- a/railties/lib/tasks/statistics.rake
+++ b/railties/lib/tasks/statistics.rake
@@ -4,7 +4,6 @@ STATS_DIRECTORIES = [
%w(Models app/models),
%w(Libraries lib/),
%w(APIs app/apis),
- %w(Components components),
%w(Integration\ tests test/integration),
%w(Functional\ tests test/functional),
%w(Unit\ tests test/unit)
diff --git a/railties/lib/tasks/testing.rake b/railties/lib/tasks/testing.rake
index 328bde7442..4242458672 100644
--- a/railties/lib/tasks/testing.rake
+++ b/railties/lib/tasks/testing.rake
@@ -7,7 +7,7 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
tests = []
source_dir = File.dirname(path).split("/")
source_file = File.basename(path, '.rb')
-
+
# Support subdirs in app/models and app/controllers
modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
@@ -18,7 +18,7 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
# For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
-
+
return tests
end
@@ -63,7 +63,7 @@ namespace :test do
t.test_files = touched.uniq
end
Rake::Task['test:recent'].comment = "Test recent changes"
-
+
Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t|
def t.file_list
if File.directory?(".svn")
@@ -82,7 +82,7 @@ namespace :test do
unit_tests.uniq + functional_tests.uniq
end
-
+
t.libs << 'test'
t.verbose = true
end