$:.unshift File.dirname(__FILE__) require 'webrick' require 'source_file_handler' module BuildMaster class SiteServer def initialize(port_number=2000, log_file=$stdout, level=WEBrick::Log::INFO, access_log=nil) mime_types = WEBrick::HTTPUtils::DefaultMimeTypes.update( {"textile" => "text/plain"} ) @server = WEBrick::HTTPServer.new( :Port => port_number, :Logger => WEBrick::Log.new(log_file, level), :MimeTypes => mime_types, :AccessLog => access_log ) end def start(spec) @server.mount('/', SourceFileHandler, spec) @server.mount('/source', WEBrick::HTTPServlet::FileHandler, spec.content_dir, true) ['INT', 'TERM'].each { |signal| trap(signal){ stop} } @server.start end def stop @server.shutdown end end end