diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/commands/dbconsole.rb | 18 | ||||
-rwxr-xr-x | railties/lib/commands/performance/request.rb | 6 | ||||
-rw-r--r-- | railties/lib/dispatcher.rb | 2 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 13 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/app_generator.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/template_runner.rb | 8 | ||||
-rw-r--r-- | railties/lib/tasks/gems.rake | 4 | ||||
-rw-r--r-- | railties/lib/tasks/misc.rake | 1 |
8 files changed, 40 insertions, 14 deletions
diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb index 06848d3c91..8002264f7e 100644 --- a/railties/lib/commands/dbconsole.rb +++ b/railties/lib/commands/dbconsole.rb @@ -3,12 +3,23 @@ require 'yaml' require 'optparse' include_password = false +options = {} OptionParser.new do |opt| opt.banner = "Usage: dbconsole [options] [environment]" opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v| include_password = true end + + opt.on("--mode [MODE]", ['html', 'list', 'line', 'column'], + "Automatically put the sqlite3 database in the specified mode (html, list, line, column).") do |mode| + options['mode'] = mode + end + + opt.on("-h", "--header") do |h| + options['header'] = h + end + opt.parse!(ARGV) abort opt.to_s unless (0..1).include?(ARGV.size) end @@ -60,8 +71,13 @@ when "sqlite" exec(find_cmd('sqlite'), config["database"]) when "sqlite3" - exec(find_cmd('sqlite3'), config["database"]) + args = [] + + args << "-#{options['mode']}" if options['mode'] + args << "-header" if options['header'] + args << config['database'] + exec(find_cmd('sqlite3'), *args) else abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!" end diff --git a/railties/lib/commands/performance/request.rb b/railties/lib/commands/performance/request.rb deleted file mode 100755 index 1773886487..0000000000 --- a/railties/lib/commands/performance/request.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -require 'config/environment' -require 'application' -require 'action_controller/request_profiler' - -ActionController::RequestProfiler.run(ARGV) diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb index 0bad45d9d8..9f8b59aa3d 100644 --- a/railties/lib/dispatcher.rb +++ b/railties/lib/dispatcher.rb @@ -1,5 +1,5 @@ #-- -# Copyright (c) 2004-2008 David Heinemeier Hansson +# Copyright (c) 2004-2009 David Heinemeier Hansson # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 824d1d6096..da064c86aa 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -302,7 +302,7 @@ module Rails if unloaded_gems.size > 0 @gems_dependencies_loaded = false # don't print if the gems rake tasks are being run - unless $rails_gem_installer + unless $rails_rake_task abort <<-end_error Missing these required gems: #{unloaded_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "} @@ -379,6 +379,7 @@ Run `rake gems:install` to install the missing gems. # Eager load application classes def load_application_classes + return if $rails_rake_task if configuration.cache_classes configuration.eager_load_paths.each do |load_path| matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/ @@ -408,12 +409,18 @@ Run `rake gems:install` to install the missing gems. if configuration.frameworks.include?(:active_record) ActiveRecord::Base.configurations = configuration.database_configuration ActiveRecord::Base.establish_connection + configuration.middleware.use ActiveRecord::QueryCache end end def initialize_cache unless defined?(RAILS_CACHE) silence_warnings { Object.const_set "RAILS_CACHE", ActiveSupport::Cache.lookup_store(configuration.cache_store) } + + if RAILS_CACHE.respond_to?(:middleware) + # Insert middleware to setup and teardown local cache for each request + configuration.middleware.insert_after(:"ActionController::Failsafe", RAILS_CACHE.middleware) + end end end @@ -537,7 +544,9 @@ Run `rake gems:install` to install the missing gems. end def initialize_metal - configuration.middleware.insert_before(:"ActionController::RewindableInput", Rails::Rack::Metal) + configuration.middleware.insert_before( + :"ActionController::RewindableInput", + Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?) end # Initializes framework-specific settings for each of the loaded frameworks diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index 795a0d7653..2c31d89538 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -151,7 +151,7 @@ class AppGenerator < Rails::Generator::Base def create_script_files(m) %w( about console dbconsole destroy generate runner server plugin - performance/benchmarker performance/profiler performance/request + performance/benchmarker performance/profiler ).each do |file| m.file "bin/#{file}", "script/#{file}", { :chmod => 0755, diff --git a/railties/lib/rails_generator/generators/applications/app/template_runner.rb b/railties/lib/rails_generator/generators/applications/app/template_runner.rb index bb7bd0e6f4..84e36ecc1b 100644 --- a/railties/lib/rails_generator/generators/applications/app/template_runner.rb +++ b/railties/lib/rails_generator/generators/applications/app/template_runner.rb @@ -338,6 +338,12 @@ module Rails !yes?(question) end + # Run a regular expression replacement on a file + # + # ==== Example + # + # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' + # def gsub_file(relative_destination, regexp, *args, &block) path = destination_path(relative_destination) content = File.read(path).gsub(regexp, *args, &block) @@ -366,4 +372,4 @@ module Rails end end -end
\ No newline at end of file +end diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake index 754e3ba5c9..e6731ab78c 100644 --- a/railties/lib/tasks/gems.rake +++ b/railties/lib/tasks/gems.rake @@ -17,13 +17,13 @@ end namespace :gems do task :base do - $rails_gem_installer = true + $rails_rake_task = true Rake::Task[:environment].invoke end desc "Build any native extensions for unpacked gems" task :build do - $rails_gem_installer = true + $rails_rake_task = true require 'rails/gem_builder' Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |gem_dir| spec_file = File.join(gem_dir, '.specification') diff --git a/railties/lib/tasks/misc.rake b/railties/lib/tasks/misc.rake index 411750bf40..9e6f96db5b 100644 --- a/railties/lib/tasks/misc.rake +++ b/railties/lib/tasks/misc.rake @@ -1,5 +1,6 @@ task :default => :test task :environment do + $rails_rake_task = true require(File.join(RAILS_ROOT, 'config', 'environment')) end |