Class: Camping::Server

### Home Classes Methods

### In Files

- lib/camping/server.rb

### Parent

Rack::Server

### Namespace

- CLASS Camping::Server::Options
- CLASS Camping::Server::XSendfile

### Methods

- ::new
- #app
- #call
- #current_app
- #default_options
- #middleware
- #opt_parser
- #public_dir
- #start

### Files

- CHANGELOG
- COPYING

### Class/Module Index

Quicksearch

- Camping
- Camping::Base
- Camping::Controllers
- Camping::Cookies
- Camping::H
- Camping::Helpers
- Camping::Models
- Camping::Models::Base
- Camping::Reloader
- Camping::Server
- Camping::Server::Options
- Camping::Server::XSendfile
- Camping::Session
- Camping::Views
- Camping::X

No matching classes.

# Camping::Server

### Public Class Methods

new(*) click to toggle source

    # File lib/camping/server.rb, line 98
    def initialize(*)
      super
      @reloader = Camping::Reloader.new(options[:script]) do |app|
        if !app.options.has_key?(:dynamic_templates)
                      app.options[:dynamic_templates] = true
              end

        if !Camping::Models.autoload?(:Base) && options[:database]
          Camping::Models::Base.establish_connection(
            :adapter => 'sqlite3',
            :database => options[:database]
          )
        end
      end
    end

### Public Instance Methods

app() click to toggle source

    # File lib/camping/server.rb, line 151
    def app
      Rack::Cascade.new([Rack::File.new(public_dir), self], [405, 404, 403])
    end

call(env) click to toggle source

    # File lib/camping/server.rb, line 164
    def call(env)
      app = current_app || raise("Could not find an app called `#{@reloader.name}`")
      app.call(env)
    end

current_app() click to toggle source

    # File lib/camping/server.rb, line 155
    def current_app
      @reloader.reload
      apps = @reloader.apps
      return apps.values.first if apps.size == 1
      if key = apps.keys.grep(/^#{@reloader.name}$/)[0]
        apps[key]
      end
    end

default_options() click to toggle source

    # File lib/camping/server.rb, line 118
    def default_options
      super.merge({
        :Port => 3301,
        :database => Options::DB
      })
    end

middleware() click to toggle source

    # File lib/camping/server.rb, line 125
    def middleware
      h = super
      h["development"] << [XSendfile]
      h
    end

opt_parser() click to toggle source

    # File lib/camping/server.rb, line 114
    def opt_parser
      Options.new
    end

public_dir() click to toggle source

    # File lib/camping/server.rb, line 147
    def public_dir
      File.expand_path('../public', @reloader.file)
    end

start() click to toggle source

    # File lib/camping/server.rb, line 131
    def start
      if options[:server] == "console"
        puts "** Starting console"
        @reloader.reload!
        r = @reloader
        eval("self", TOPLEVEL_BINDING).meta_def(:reload!) { r.reload!; nil }
        ARGV.clear
        IRB.start
        exit
      else
        name = server.name[/\w+$/]
        puts "** Starting #{name} on #{options[:Host]}:#{options[:Port]}"
        super
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.