Class: YARD::Server::WebrickAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/yard/server/webrick_adapter.rb

Overview

The main adapter to initialize a WEBrick server.

Since:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

This class inherits a constructor from YARD::Server::Adapter

Instance Attribute Details

- (String) document_root Originally defined in class Adapter

Returns the location where static files are located, if any. To set this field on initialization, pass :DocumentRoot to the server_opts argument in #initialize

Returns:

  • (String)

    the location where static files are located, if any. To set this field on initialization, pass :DocumentRoot to the server_opts argument in #initialize

Since:

  • 0.6.0

- (Hash{String=>Array<LibraryVersion>}) libraries Originally defined in class Adapter

Returns a map of libraries.

- (Hash) options Originally defined in class Adapter

Returns options passed and processed by adapters. The actual options mostly depend on the adapters themselves.

Returns:

  • (Hash)

    options passed and processed by adapters. The actual options mostly depend on the adapters themselves.

Since:

  • 0.6.0

- (Router) router Originally defined in class Adapter

Returns the router object used to route URLs to commands

Returns:

  • (Router)

    the router object used to route URLs to commands

Since:

  • 0.6.0

- (Hash) server_options Originally defined in class Adapter

Returns a set of options to pass to the server backend. Note that :DocumentRoot also sets the #document_root.

Returns:

  • (Hash)

    a set of options to pass to the server backend. Note that :DocumentRoot also sets the #document_root.

Since:

  • 0.6.0

Instance Method Details

- (Object) start

Initializes a WEBrick server. If Adapter#server_options contains a :daemonize key set to true, the server will be daemonized.

Since:

  • 0.6.0



9
10
11
12
13
14
15
# File 'lib/yard/server/webrick_adapter.rb', line 9

def start
  server_options[:ServerType] = WEBrick::Daemon if server_options[:daemonize]
  server = WEBrick::HTTPServer.new(server_options)
  server.mount('/', WebrickServlet, self)
  trap("INT") { server.shutdown }
  server.start
end