don't reinvent the wheel

This commit is contained in:
John Bintz 2012-01-13 07:45:27 -05:00
parent f51f041b85
commit d3c3e7bd7d

View File

@ -125,24 +125,14 @@ module Jasmine
end end
def wrap_in_server def wrap_in_server
require 'rack'
require 'webrick' require 'webrick'
require 'thread' require 'thread'
require 'rack'
require 'net/http' require 'net/http'
server = Thread.new do server = Thread.new do
responder = lambda do |env|
file = Pathname(env['PATH_INFO'])
if file.file?
[ 200, { 'Content-Type' => 'text/html' }, [ file.read ] ]
else
[ 404, {}, [ 'Not found' ] ]
end
end
Rack::Handler::WEBrick.run( Rack::Handler::WEBrick.run(
responder, Rack::File.new('/'),
:Port => server_port, :Port => server_port,
:Logger => Logger.new(StringIO.new), :Logger => Logger.new(StringIO.new),
:AccessLog => [ :AccessLog => [