class ASF::DocumentRoot

compute document root for the site. Needed by Rack/Passenger applications that wish to use support site wide assets (stylesheets, javascripts).

Public Class Methods

new(app) click to toggle source

capture the application

# File lib/whimsy/asf/rack.rb, line 210
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source

compute the document root by stripping the PASSENGER_BASE_URI from the the current working directory.

# File lib/whimsy/asf/rack.rb, line 216
def call(env)
  if ENV['PASSENGER_BASE_URI'] and not ENV['DOCUMENT_ROOT']
    base = Dir.pwd
    if base.end_with? ENV['PASSENGER_BASE_URI']
      base = base[0...-ENV['PASSENGER_BASE_URI'].length]
    end
    ENV['DOCUMENT_ROOT'] = base
  end

  return @app.call(env)
end