Sha256: 82b747379a369c3b5e4d1a7624ae5ef2cc0e126d57216ed6dfd0e259f22abfcb
Contents?: true
Size: 955 Bytes
Versions: 1
Compression:
Stored size: 955 Bytes
Contents
require 'webrick' module TestUtil class WebServer class << self def start(*args) new(*args).tap {|x| x.start} end end def initialize(document_root, option={}) logger = WEBrick::Log.new(StringIO.new("", "w")) # modify document root document_root = document_root.local.path if document_root.kind_of?(Location::DataLocation) # setup options _option = {DocumentRoot: document_root} _option[:Port] = 54673 unless option[:Port] _option[:Logger] = logger unless option[:Logger] _option[:AccessLog] = logger unless option[:AccessLog] # make webrick @server = WEBrick::HTTPServer.new(_option) end def root Location["http://localhost:%s/" % port] end def port @server.config[:Port] end def start @thread = Thread.new { @server.start } end def terminate @server.shutdown @thread.kill end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pione-0.2.2 | test/test-util/webserver.rb |