Do not use ActionController::Base.page_cache_extension in initialize to not load more ActiveSupport than we need

This commit is contained in:
Piotr Sarnacki 2010-09-03 23:25:57 +02:00
parent 9f0a1ae14e
commit c3c1a1e148

@ -7,16 +7,13 @@ def initialize(at, root)
@compiled_at = Regexp.compile(/^#{Regexp.escape(at)}/) unless @at.blank?
@compiled_root = Regexp.compile(/^#{Regexp.escape(root)}/)
@file_server = ::Rack::File.new(root)
ext = ::ActionController::Base.page_cache_extension
@ext = "{,#{ext},/index#{ext}}"
end
def match?(path)
path = path.dup
if @compiled_at.blank? || path.sub!(@compiled_at, '')
full_path = File.join(@root, ::Rack::Utils.unescape(path))
paths = "#{full_path}#{@ext}"
paths = "#{full_path}#{ext}"
matches = Dir[paths]
match = matches.detect { |m| File.file?(m) }
@ -30,6 +27,13 @@ def match?(path)
def call(env)
@file_server.call(env)
end
def ext
@ext ||= begin
ext = ::ActionController::Base.page_cache_extension
"{,#{ext},/index#{ext}}"
end
end
end
class Static