require 'rubygems' if ENV['SWIFT'] require 'swiftcore/swiftiplied_mongrel' puts "Using Swiftiplied Mongrel" elsif ENV['EVENT'] require 'swiftcore/evented_mongrel' puts "Using Evented Mongrel" else require 'mongrel' end require 'fileutils' require 'erubis' require 'logger' begin require 'fjson' rescue LoadError require 'json' end module Merb VERSION='0.3.1' unless defined?VERSION class Server class << self def config @@merb_opts ||= {} end def method_missing(meth, *args, &block) if meth.to_s[-1..-1] == '=' key = meth.to_s[0..-2].to_sym config.send("[]=", key, *args) elsif args.empty? config[meth] else super end end end end end module Erubis class MEruby < Erubis::Eruby include PercentLineEnhancer include StringBufferEnhancer end end def __DIR__; File.dirname(__FILE__); end require File.join(__DIR__, 'merb/core_ext') MERB_FRAMEWORK_ROOT = __DIR__ MERB_ROOT = Merb::Server.merb_root || Dir.pwd DIST_ROOT = Merb::Server.dist_root || Dir.pwd+'/dist' MERB_ENV = Merb::Server.config[:environment] logpath = $TESTING ? "/tmp/merb_test.log" : "#{MERB_ROOT}/log/merb.#{Merb::Server.port}.log" MERB_LOGGER = Logger.new(logpath) # DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN MERB_LOGGER.level = case (Merb::Server.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 module Mongrel::Const HTTP_COOKIE = 'HTTP_COOKIE'.freeze QUERY_STRING = 'QUERY_STRING'.freeze APPLICATION_JSON = 'application/json'.freeze TEXT_JSON = 'text/x-json'.freeze UPCASE_CONTENT_TYPE = 'CONTENT_TYPE'.freeze end lib = File.join(__DIR__, 'merb') Dir.entries(lib).sort.select{|f| f !~ /merb\/session\// }.each {|fn| require File.join(lib, fn) if fn =~ /\.rb$/} require File.join(__DIR__, 'merb/vendor/paginator/paginator') class Merb::Controller if Merb::Server.memory_session require "merb/session/merb_memory_session" Merb::MemorySession.setup include ::Merb::SessionMixin puts "memory session mixed in" end if Merb::Server.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 Thread.new{ loop{ sleep(60*60); ActiveRecord::Base.verify_active_connections! } }.priority = -10 end if Merb::Server.basic_auth require "merb/mixins/basic_authentication_mixin" include ::Merb::Authentication puts "Basic Authentication mixed in" end end