Parent

Webby::AutoBuilder::WebServer

Wrapper class around the webrick web server.

Public Class Methods

new() click to toggle source

Create a new webrick server configured to serve pages from the output directory. Output will be directed to /dev/null.

# File lib/webby/auto_builder.rb, line 106
def initialize
  logger = WEBrick::Log.new(Kernel::DEV_NULL, WEBrick::Log::DEBUG)
  access_log = [[ logger, WEBrick::AccessLog::COMBINED_LOG_FORMAT ]]

  @thread = nil
  @running = false
  @server = WEBrick::HTTPServer.new(
    :BindAddress   => 'localhost',
    :Port          => ::Webby.site.web_port,
    :DocumentRoot  => ::Webby.site.output_dir,
    :FancyIndexing => true,
    :Logger        => logger,
    :AccessLog     => access_log
  )
end

Public Instance Methods

join() click to toggle source

Join on the webserver thread.

# File lib/webby/auto_builder.rb, line 147
def join
  return if not running?
  @thread.join
end
running?() click to toggle source

Returns true if the server is running.

# File lib/webby/auto_builder.rb, line 124
def running?
  @running
end
start() click to toggle source

Start the webrick server running in a separate thread (so we don’t block forever).

# File lib/webby/auto_builder.rb, line 131
def start
  return if running?
  @running = true
  @thread = Thread.new {@server.start}
end
stop() click to toggle source

Stop the webrick server.

# File lib/webby/auto_builder.rb, line 139
def stop
  return if not running?
  @running = false
  @server.shutdown
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.