diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-11-23 16:35:13 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-11-23 16:35:47 -0600 |
commit | 31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f (patch) | |
tree | ec452cb5dd933f0fc89f9b230a35f70528145950 | |
parent | 6de1060eb555b5053f7d95269ceb23fce04e0523 (diff) | |
download | rails-31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f.tar.gz rails-31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f.tar.bz2 rails-31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f.zip |
Use autoload instead of explicit requires for ActionController
23 files changed, 73 insertions, 96 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index ff8ec0d2fc..5f87429aca 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -32,47 +32,63 @@ rescue LoadError end $:.unshift "#{File.dirname(__FILE__)}/action_controller/vendor/html-scanner" -require 'action_controller/vendor/rack' -require 'action_controller/base' -require 'action_controller/request' -require 'action_controller/rescue' -require 'action_controller/benchmarking' -require 'action_controller/flash' -require 'action_controller/filters' -require 'action_controller/layout' -require 'action_controller/mime_responds' -require 'action_controller/helpers' -require 'action_controller/cookies' -require 'action_controller/cgi_process' -require 'action_controller/caching' -require 'action_controller/verification' -require 'action_controller/streaming' -require 'action_controller/session_management' -require 'action_controller/http_authentication' -require 'action_controller/rack_process' -require 'action_controller/record_identifier' -require 'action_controller/request_forgery_protection' -require 'action_controller/headers' -require 'action_controller/translation' +module ActionController + # TODO: Review explicit to see if they will automatically be handled by + # the initilizer if they are really needed. + def self.load_all! + [Base, CgiRequest, CgiResponse, RackRequest, RackRequest, Http::Headers, UrlRewriter, UrlWriter] + end -require 'action_view' + autoload :AbstractRequest, 'action_controller/request' + autoload :AbstractResponse, 'action_controller/response' + autoload :Base, 'action_controller/base' + autoload :Benchmarking, 'action_controller/benchmarking' + autoload :Caching, 'action_controller/caching' + autoload :CgiRequest, 'action_controller/cgi_process' + autoload :CgiResponse, 'action_controller/cgi_process' + autoload :Cookies, 'action_controller/cookies' + autoload :Dispatcher, 'action_controller/dispatcher' + autoload :Filters, 'action_controller/filters' + autoload :Flash, 'action_controller/flash' + autoload :Helpers, 'action_controller/helpers' + autoload :HttpAuthentication, 'action_controller/http_authentication' + autoload :IntegrationTest, 'action_controller/integration' + autoload :Layout, 'action_controller/layout' + autoload :MimeResponds, 'action_controller/mime_responds' + autoload :PolymorphicRoutes, 'action_controller/polymorphic_routes' + autoload :RackRequest, 'action_controller/rack_process' + autoload :RackResponse, 'action_controller/rack_process' + autoload :RecordIdentifier, 'action_controller/record_identifier' + autoload :RequestForgeryProtection, 'action_controller/request_forgery_protection' + autoload :Rescue, 'action_controller/rescue' + autoload :Resources, 'action_controller/resources' + autoload :Routing, 'action_controller/routing' + autoload :SessionManagement, 'action_controller/session_management' + autoload :StatusCodes, 'action_controller/status_codes' + autoload :Streaming, 'action_controller/streaming' + autoload :TestCase, 'action_controller/test_case' + autoload :TestProcess, 'action_controller/test_process' + autoload :Translation, 'action_controller/translation' + autoload :UrlRewriter, 'action_controller/url_rewriter' + autoload :UrlWriter, 'action_controller/url_rewriter' + autoload :Verification, 'action_controller/verification' -ActionController::Base.class_eval do - include ActionController::Flash - include ActionController::Filters - include ActionController::Layout - include ActionController::Benchmarking - include ActionController::Rescue - include ActionController::MimeResponds - include ActionController::Helpers - include ActionController::Cookies - include ActionController::Caching - include ActionController::Verification - include ActionController::Streaming - include ActionController::SessionManagement - include ActionController::HttpAuthentication::Basic::ControllerMethods - include ActionController::RecordIdentifier - include ActionController::RequestForgeryProtection - include ActionController::Translation + module Http + autoload :Headers, 'action_controller/headers' + end end + +class CGI + class Session + autoload :ActiveRecordStore, 'action_controller/session/active_record_store' + autoload :CookieStore, 'action_controller/session/cookie_store' + autoload :DRbStore, 'action_controller/session/drb_store' + autoload :MemCacheStore, 'action_controller/session/mem_cache_store' + end +end + +autoload :Mime, 'action_controller/mime_type' +autoload :Rack, 'action_controller/vendor/rack' + +ActionController.load_all! diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index ad6562024a..a42c1c38b9 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -1,10 +1,3 @@ -require 'action_controller/mime_type' -require 'action_controller/request' -require 'action_controller/response' -require 'action_controller/routing' -require 'action_controller/resources' -require 'action_controller/url_rewriter' -require 'action_controller/status_codes' require 'action_view' require 'drb' require 'set' @@ -1332,4 +1325,11 @@ module ActionController #:nodoc: close_session end end + + Base.class_eval do + include Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers + include Cookies, Caching, Verification, Streaming + include SessionManagement, HttpAuthentication::Basic::ControllerMethods + include RecordIdentifier, RequestForgeryProtection, Translation + end end diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index c4063dfb4b..b4d251eb3c 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -2,13 +2,6 @@ require 'fileutils' require 'uri' require 'set' -require 'action_controller/caching/pages' -require 'action_controller/caching/actions' -require 'action_controller/caching/sql_cache' -require 'action_controller/caching/sweeping' -require 'action_controller/caching/fragments' - - module ActionController #:nodoc: # Caching is a cheap way of speeding up slow applications by keeping the result of calculations, renderings, and database calls # around for subsequent requests. Action Controller affords you three approaches in varying levels of granularity: Page, Action, Fragment. @@ -31,6 +24,12 @@ module ActionController #:nodoc: # ActionController::Base.cache_store = :mem_cache_store, "localhost" # ActionController::Base.cache_store = MyOwnStore.new("parameter") module Caching + autoload :Actions, 'action_controller/caching/actions' + autoload :Fragments, 'action_controller/caching/fragments' + autoload :Pages, 'action_controller/caching/pages' + autoload :SqlCache, 'action_controller/caching/sql_cache' + autoload :Sweeping, 'action_controller/caching/sweeping' + def self.included(base) #:nodoc: base.class_eval do @@cache_store = nil @@ -63,10 +62,9 @@ module ActionController #:nodoc: end end - - private + private def cache_configured? self.class.cache_configured? end end -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index fabacd9b83..45b51a7488 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -1,5 +1,4 @@ require 'action_controller/cgi_ext' -require 'action_controller/session/cookie_store' module ActionController #:nodoc: class Base diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb index b3771c1ebc..333fb742e4 100644 --- a/actionpack/lib/action_controller/integration.rb +++ b/actionpack/lib/action_controller/integration.rb @@ -1,7 +1,3 @@ -require 'action_controller/test_case' -require 'action_controller/dispatcher' -require 'action_controller/test_process' - require 'stringio' require 'uri' diff --git a/actionpack/lib/action_controller/performance_test.rb b/actionpack/lib/action_controller/performance_test.rb index 85543fffae..d88180087d 100644 --- a/actionpack/lib/action_controller/performance_test.rb +++ b/actionpack/lib/action_controller/performance_test.rb @@ -1,4 +1,3 @@ -require 'action_controller/integration' require 'active_support/testing/performance' require 'active_support/testing/default' diff --git a/actionpack/lib/action_controller/rack_process.rb b/actionpack/lib/action_controller/rack_process.rb index e8ea3704a8..58d7b53e31 100644 --- a/actionpack/lib/action_controller/rack_process.rb +++ b/actionpack/lib/action_controller/rack_process.rb @@ -1,5 +1,4 @@ require 'action_controller/cgi_ext' -require 'action_controller/session/cookie_store' module ActionController #:nodoc: class RackRequest < AbstractRequest #:nodoc: diff --git a/actionpack/lib/action_controller/request_profiler.rb b/actionpack/lib/action_controller/request_profiler.rb index a6471d0c08..70bb77e7ac 100644 --- a/actionpack/lib/action_controller/request_profiler.rb +++ b/actionpack/lib/action_controller/request_profiler.rb @@ -1,5 +1,4 @@ require 'optparse' -require 'action_controller/integration' module ActionController class RequestProfiler diff --git a/actionpack/lib/action_controller/resources.rb b/actionpack/lib/action_controller/resources.rb index 7700b9d4d0..b5ea764911 100644 --- a/actionpack/lib/action_controller/resources.rb +++ b/actionpack/lib/action_controller/resources.rb @@ -669,7 +669,3 @@ module ActionController end end end - -class ActionController::Routing::RouteSet::Mapper - include ActionController::Resources -end diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 8d51e823a6..efd474097e 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -1,6 +1,5 @@ require 'cgi' require 'uri' -require 'action_controller/polymorphic_routes' require 'action_controller/routing/optimisations' require 'action_controller/routing/routing_ext' require 'action_controller/routing/route' diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb index 1b8b52ad10..3bb25dbba9 100644 --- a/actionpack/lib/action_controller/routing/route_set.rb +++ b/actionpack/lib/action_controller/routing/route_set.rb @@ -7,6 +7,8 @@ module ActionController # Mapper instances have relatively few instance methods, in order to avoid # clashes with named routes. class Mapper #:doc: + include ActionController::Resources + def initialize(set) #:nodoc: @set = set end diff --git a/actionpack/lib/action_controller/session_management.rb b/actionpack/lib/action_controller/session_management.rb index fd3d94ed97..60a9aec39c 100644 --- a/actionpack/lib/action_controller/session_management.rb +++ b/actionpack/lib/action_controller/session_management.rb @@ -1,10 +1,3 @@ -require 'action_controller/session/cookie_store' -require 'action_controller/session/drb_store' -require 'action_controller/session/mem_cache_store' -if Object.const_defined?(:ActiveRecord) - require 'action_controller/session/active_record_store' -end - module ActionController #:nodoc: module SessionManagement #:nodoc: def self.included(base) diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index cdea1def92..4ab4ed233f 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -1,5 +1,3 @@ -require 'action_controller/test_case' - module ActionView class TestCase < ActiveSupport::TestCase include ActionController::TestCase::Assertions diff --git a/actionpack/test/activerecord/active_record_store_test.rb b/actionpack/test/activerecord/active_record_store_test.rb index fd7da89aa7..677d434f9c 100644 --- a/actionpack/test/activerecord/active_record_store_test.rb +++ b/actionpack/test/activerecord/active_record_store_test.rb @@ -1,7 +1,6 @@ # These tests exercise CGI::Session::ActiveRecordStore, so you're going to # need AR in a sibling directory to AP and have SQLite installed. require 'active_record_unit' -require 'action_controller/session/active_record_store' module CommonActiveRecordStoreTests def test_basics diff --git a/actionpack/test/controller/cgi_test.rb b/actionpack/test/controller/cgi_test.rb index 87fbf1a4cd..ac1c8abc59 100644 --- a/actionpack/test/controller/cgi_test.rb +++ b/actionpack/test/controller/cgi_test.rb @@ -1,5 +1,4 @@ require 'abstract_unit' -require 'action_controller/cgi_process' class BaseCgiTest < Test::Unit::TestCase def setup diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb index 3ee78a6156..61bfb2b6e9 100644 --- a/actionpack/test/controller/dispatcher_test.rb +++ b/actionpack/test/controller/dispatcher_test.rb @@ -2,8 +2,6 @@ require 'abstract_unit' uses_mocha 'dispatcher tests' do -require 'action_controller/dispatcher' - class DispatcherTest < Test::Unit::TestCase Dispatcher = ActionController::Dispatcher diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 7e4c3e171a..b39d35930d 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -1,6 +1,4 @@ require 'abstract_unit' -require 'action_controller/integration' -require 'action_controller/routing' uses_mocha 'integration' do diff --git a/actionpack/test/controller/integration_upload_test.rb b/actionpack/test/controller/integration_upload_test.rb index 4af9b7e697..b1dd6a6341 100644 --- a/actionpack/test/controller/integration_upload_test.rb +++ b/actionpack/test/controller/integration_upload_test.rb @@ -1,6 +1,4 @@ require 'abstract_unit' -require 'action_controller/integration' -require 'action_controller/routing' unless defined? ApplicationController class ApplicationController < ActionController::Base diff --git a/actionpack/test/controller/rack_test.rb b/actionpack/test/controller/rack_test.rb index d5e56b9584..7e8b0f9bf2 100644 --- a/actionpack/test/controller/rack_test.rb +++ b/actionpack/test/controller/rack_test.rb @@ -1,5 +1,4 @@ require 'abstract_unit' -require 'action_controller/rack_process' class BaseRackTest < Test::Unit::TestCase def setup diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 7e264289e6..316a203e97 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -1,5 +1,4 @@ require 'abstract_unit' -require 'action_controller/integration' class RequestTest < ActiveSupport::TestCase def setup diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index b8a143cfd9..d62c7a1743 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1,6 +1,5 @@ require 'abstract_unit' require 'controller/fake_controllers' -require 'action_controller/routing' class MilestonesController < ActionController::Base def index() head :ok end diff --git a/actionpack/test/controller/session/cookie_store_test.rb b/actionpack/test/controller/session/cookie_store_test.rb index 52c1f7559c..b5f14acc1f 100644 --- a/actionpack/test/controller/session/cookie_store_test.rb +++ b/actionpack/test/controller/session/cookie_store_test.rb @@ -1,7 +1,4 @@ require 'abstract_unit' -require 'action_controller/cgi_process' -require 'action_controller/cgi_ext' - require 'stringio' diff --git a/actionpack/test/controller/session/mem_cache_store_test.rb b/actionpack/test/controller/session/mem_cache_store_test.rb index a7d48431f8..9ab927a01f 100644 --- a/actionpack/test/controller/session/mem_cache_store_test.rb +++ b/actionpack/test/controller/session/mem_cache_store_test.rb @@ -1,7 +1,4 @@ require 'abstract_unit' -require 'action_controller/cgi_process' -require 'action_controller/cgi_ext' - class CGI::Session def cache |