Object
# File lib/rack/adapter/rails.rb, line 18 18: def initialize(options={}) 19: @root = options[:root] || Dir.pwd 20: @env = options[:environment] || 'development' 21: @prefix = options[:prefix] 22: 23: load_application 24: 25: @rails_app = if self.class.rack_based? 26: ActionController::Dispatcher.new 27: else 28: CgiApp.new 29: end 30: 31: @file_app = Rack::File.new(::File.join(RAILS_ROOT, "public")) 32: end
# File lib/rack/adapter/rails.rb, line 72 72: def self.rack_based? 73: rails_version = ::Rails::VERSION 74: return false if rails_version::MAJOR < 2 75: return false if rails_version::MAJOR == 2 && rails_version::MINOR < 2 76: return false if rails_version::MAJOR == 2 && rails_version::MINOR == 2 && rails_version::TINY < 3 77: true # >= 2.2.3 78: end
# File lib/rack/adapter/rails.rb, line 54 54: def call(env) 55: path = env['PATH_INFO'].chomp('/') 56: method = env['REQUEST_METHOD'] 57: cached_path = (path.empty? ? 'index' : path) + ActionController::Base.page_cache_extension 58: 59: if FILE_METHODS.include?(method) 60: if file_exist?(path) # Serve the file if it's there 61: return @file_app.call(env) 62: elsif file_exist?(cached_path) # Serve the page cache if it's there 63: env['PATH_INFO'] = cached_path 64: return @file_app.call(env) 65: end 66: end 67: 68: # No static file, let Rails handle it 69: @rails_app.call(env) 70: end
# File lib/rack/adapter/rails.rb, line 49 49: def file_exist?(path) 50: full_path = ::File.join(@file_app.root, Utils.unescape(path)) 51: ::File.file?(full_path) && ::File.readable_real?(full_path) 52: end
# File lib/rack/adapter/rails.rb, line 34 34: def load_application 35: ENV['RAILS_ENV'] = @env 36: 37: require "#{@root}/config/environment" 38: require 'dispatcher' 39: 40: if @prefix 41: if ActionController::Base.respond_to?(:relative_url_root=) 42: ActionController::Base.relative_url_root = @prefix # Rails 2.1.1 43: else 44: ActionController::AbstractRequest.relative_url_root = @prefix 45: end 46: end 47: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.