Sha256: 1d7a35e1a057d9a02c0048fdee07b717f66e87637d38cc8150cc6ef70e3a8f73

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

$:.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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
BuildMaster-0.8.0 lib/buildmaster/site_server.rb
BuildMaster-0.8.1 lib/buildmaster/site_server.rb
BuildMaster-0.9.0 lib/buildmaster/site_server.rb
BuildMaster-0.9.1 lib/buildmaster/site_server.rb