Module: Rack::Adapter

### Home Classes Methods

### In Files

- lib/rack/adapter/loader.rb
- lib/rack/adapter/rails.rb
- lib/thin.rb

### Namespace

- CLASS Rack::Adapter::Rails

### Methods

- ::for
- ::guess
- ::load

### Class/Module Index

Quicksearch

- Thin
- Thin::Backends
- Thin::Backends::Base
- Thin::Backends::SwiftiplyClient
- Thin::Backends::TcpServer
- Thin::Backends::UnixServer
- Thin::Command
- Thin::Connection
- Thin::Controllers
- Thin::Controllers::Cluster
- Thin::Controllers::Controller
- Thin::Controllers::Service
- Thin::Daemonizable
- Thin::Daemonizable::ClassMethods
- Thin::Headers
- Thin::InvalidOption
- Thin::InvalidRequest
- Thin::Logging
- Thin::Logging::SimpleFormatter
- Thin::OptionRequired
- Thin::PidFileExist
- Thin::PidFileNotFound
- Thin::PlatformNotSupported
- Thin::Request
- Thin::Response
- Thin::RestartTimeout
- Thin::Runner
- Thin::RunnerError
- Thin::Server
- Thin::Stats
- Thin::Stats::Adapter
- Thin::SwiftiplyConnection
- Thin::UnixConnection
- Rack
- Rack::Adapter
- Rack::Adapter::Rails
- Rack::Adapter::Rails::CGIWrapper
- Rack::Adapter::Rails::CgiApp
- Rack::AdapterNotFound
- Process

No matching classes.

# Rack::Adapter

### Public Class Methods

for(name, options={}) click to toggle source

Loads an adapter identified by `name` using `options` hash.

    # File lib/rack/adapter/loader.rb, line 37
    def self.for(name, options={})
      ENV['RACK_ENV'] = options[:environment]

      case name.to_sym
      when :rack
        return load(::File.join(options[:chdir], "config.ru"))

      when :rails
        return Rails.new(options.merge(:root => options[:chdir]))

      when :ramaze
        require "#{options[:chdir]}/start"

        Ramaze.trait[:essentials].delete Ramaze::Adapter
        Ramaze.start :force => true

        return Ramaze::Adapter::Base

      when :merb
        require 'merb-core'

        Merb::Config.setup(:merb_root   => options[:chdir],
                           :environment => options[:environment])
        Merb.environment = Merb::Config[:environment]
        Merb.root = Merb::Config[:merb_root]
        Merb::BootLoader.run

        return Merb::Rack::Application.new

      when :file
        return Rack::File.new(options[:chdir])

      else
        raise AdapterNotFound, "Adapter not found: #{name}"

      end
    end

guess(dir) click to toggle source

Guess which adapter to use based on the directory structure or file content. Returns a symbol representing the name of the adapter to use to load the application under `dir/`.

    # File lib/rack/adapter/loader.rb, line 23
    def self.guess(dir)
      ADAPTERS.each do |adapter, file|
        return adapter if file && ::File.exist?(::File.join(dir, file))
      end
      raise AdapterNotFound, "No adapter found for #{dir}"
    end

load(config) click to toggle source

Load a Rack application from a Rack config file (.ru).

    # File lib/rack/adapter/loader.rb, line 31
    def self.load(config)
      rackup_code = ::File.read(config)
      eval("Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, config)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.