Try speeding up rails booting

This commit is contained in:
Yehuda Katz + Carl Lerche 2009-06-25 14:23:03 -07:00
parent c117e8e848
commit 8ee60660ce
5 changed files with 19 additions and 11 deletions

View File

@ -1,5 +1,3 @@
require 'builder'
module ActionView
module TemplateHandlers
class Builder < TemplateHandler
@ -8,6 +6,7 @@ module ActionView
self.default_format = Mime::XML
def compile(template)
require 'builder'
"xml = ::Builder::XmlMarkup.new(:indent => 2);" +
"self.output_buffer = xml.target!;" +
template.source +

View File

@ -1,4 +1,3 @@
require 'erb'
require 'active_support/core_ext/class/attribute_accessors'
module ActionView
@ -16,6 +15,8 @@ module ActionView
self.default_format = Mime::HTML
def compile(template)
require 'erb'
magic = $1 if template.source =~ /\A(<%#.*coding:\s*(\S+)\s*-?%>)/
erb = "#{magic}<% __in_erb_template=true %>#{template.source}"
::ERB.new(erb, nil, erb_trim_mode, '@output_buffer').src

View File

@ -2,7 +2,12 @@ require 'benchmark'
require 'active_support/core_ext/benchmark'
require 'active_support/core_ext/exception'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext' # FIXME: pulling in all to_param extensions
%w(hash nil string time date date_time array big_decimal range object boolean).each do |library|
require "active_support/core_ext/#{library}/conversions"
end
# require 'active_support/core_ext' # FIXME: pulling in all to_param extensions
module ActiveSupport
# See ActiveSupport::Cache::Store for documentation.

View File

@ -177,7 +177,8 @@ module Rails
# Action Pack, Action Mailer, and Active Resource) are loaded.
Initializer.default.add :require_frameworks do
begin
require 'active_support/all'
require 'active_support'
require 'active_support/core_ext/kernel/reporting'
configuration.frameworks.each { |framework| require(framework.to_s) }
rescue LoadError => e
# Re-raise as RuntimeError because Mongrel would swallow LoadError.
@ -397,12 +398,15 @@ module Rails
end
Initializer.default.add :initialize_metal do
Rails::Rack::Metal.requested_metals = configuration.metals
Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
# TODO: Make Rails and metal work without ActionController
if defined?(ActionController)
Rails::Rack::Metal.requested_metals = configuration.metals
Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
configuration.middleware.insert_before(
:"ActionDispatch::ParamsParser",
Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?)
configuration.middleware.insert_before(
:"ActionDispatch::ParamsParser",
Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?)
end
end
# Add the load paths used by support functions such as the info controller

View File

@ -93,7 +93,6 @@ module Rails
# TODO: Fix this when there is an application object
def middleware
require 'action_controller'
ActionController::Dispatcher.middleware
end