Skip to content

Commit

Permalink
Try speeding up rails booting
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehuda Katz + Carl Lerche committed Jun 25, 2009
1 parent c117e8e commit 8ee6066
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
3 changes: 1 addition & 2 deletions actionpack/lib/action_view/template/handlers/builder.rb
@@ -1,5 +1,3 @@
require 'builder'

module ActionView
module TemplateHandlers
class Builder < TemplateHandler
Expand All @@ -8,6 +6,7 @@ class Builder < TemplateHandler
self.default_format = Mime::XML

def compile(template)
require 'builder'
"xml = ::Builder::XmlMarkup.new(:indent => 2);" +
"self.output_buffer = xml.target!;" +
template.source +
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_view/template/handlers/erb.rb
@@ -1,4 +1,3 @@
require 'erb'
require 'active_support/core_ext/class/attribute_accessors'

module ActionView
Expand All @@ -16,6 +15,8 @@ class ERB < TemplateHandler
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
Expand Down
7 changes: 6 additions & 1 deletion activesupport/lib/active_support/cache.rb
Expand Up @@ -2,7 +2,12 @@
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.
Expand Down
16 changes: 10 additions & 6 deletions railties/lib/initializer.rb
Expand Up @@ -177,7 +177,8 @@ def self.run(initializer = nil, config = nil)
# 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.
Expand Down Expand Up @@ -397,12 +398,15 @@ def self.run(initializer = nil, config = nil)
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
Expand Down
1 change: 0 additions & 1 deletion railties/lib/rails/configuration.rb
Expand Up @@ -93,7 +93,6 @@ def framework_root_path

# TODO: Fix this when there is an application object
def middleware
require 'action_controller'
ActionController::Dispatcher.middleware
end

Expand Down

0 comments on commit 8ee6066

Please sign in to comment.