require 'rubygems' require 'mongrel' require 'fileutils' require 'erubis' require 'logger' require 'mime/types' module Merb VERSION='0.0.8' unless defined?VERSION class Server def self.config @@merb_opts ||= {} end end end class MerbControllerError < RuntimeError; end MERB_FRAMEWORK_ROOT = File.dirname(__FILE__) MERB_ROOT = Merb::Server.config[:merb_root] || Dir.pwd DIST_ROOT = Merb::Server.config[:dist_root] || Dir.pwd+'/dist' MERB_LOGGER = Logger.new("#{MERB_ROOT}/log/merb.#{Merb::Server.config[:port]}.log") # DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN MERB_LOGGER.level = case (Merb::Server.config[:log_level].downcase rescue '') when 'debug' Logger::DEBUG when 'info' Logger::INFO when 'warn' Logger::WARN when 'error' Logger::ERROR when 'fatal' Logger::FATAL when 'unknown' Logger::UNKNOWN else Logger::INFO end corelib = File.join(File.dirname(__FILE__), 'merb/core_ext') Dir.entries(corelib).sort.each {|fn| require File.join(corelib, fn) if fn =~ /\.rb$/} lib = File.join(File.dirname(__FILE__), 'merb') Dir.entries(lib).sort.each {|fn| require File.join(lib, fn) if fn =~ /\.rb$/} class Merb::Controller if Merb::Server.config[:session] require "drb" DRb.start_service('druby://localhost:0') Merb.const_set :DRbSession, DRbObject.new(nil, "druby://#{Merb::Server.config[:host]}:#{Merb::Server.config[:session]}") require "merb/session/merb_drb_session" include ::Merb::SessionMixin puts "drb session mixed in" end if Merb::Server.config[:sql_session] puts "ActiveRecord session mixed in" begin require 'action_controller/flash' puts "Rails session compatibilty on." rescue LoadError puts "Rails session compatibilty disabled. If you need this then install the actionpack gem" end require "merb/session/merb_ar_session" include ::Merb::SessionMixin end if Merb::Server.config[:basic_auth] require "merb/mixins/basic_authentication_mixin" include ::Merb::Authentication puts "Basic Authentication mixed in" end end