don't reinvent the wheel
This commit is contained in:
parent
f51f041b85
commit
d3c3e7bd7d
@ -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 => [
|
||||||
|
Loading…
Reference in New Issue
Block a user