Class: Nitro::Webrick
- Inherits:
-
Object
- Object
- Nitro::Webrick
- Defined in:
- lib/nitro/adapter/webrick.rb
Overview
Helper methods for the WebrickAdapter.
Class Attribute Summary collapse
-
.webrick ⇒ Object
Returns the value of attribute webrick.
Class Method Summary collapse
-
.initialize_webrick(server) ⇒ Object
Override this method to perform customized webrick initialization.
-
.start(server) ⇒ Object
Start the Webrick adapter.
-
.stop ⇒ Object
Stop the Webrick adapter.
Class Attribute Details
.webrick ⇒ Object
Returns the value of attribute webrick.
19 20 21 |
# File 'lib/nitro/adapter/webrick.rb', line 19 def webrick @webrick end |
Class Method Details
.initialize_webrick(server) ⇒ Object
Override this method to perform customized webrick initialization.
78 79 |
# File 'lib/nitro/adapter/webrick.rb', line 78 def initialize_webrick(server) end |
.start(server) ⇒ Object
Start the Webrick adapter.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/nitro/adapter/webrick.rb', line 23 def start(server) if RUBY_PLATFORM !~ /mswin32/ wblog = WEBrick::BasicLog::new('/dev/null') elsif server.access_log wblog = WEBrick::BasicLog::new(server.access_log) elsif File.exist? 'log' wblog = WEBrick::BasicLog::new('log/access.log') else wblog = STDERR end = server..dup require 'webrick/https' if [:SSLEnable] .update( :BindAddress => server.address, :Port => server.port, :DocumentRoot => server.public_root, :AccessLog => [ [wblog, WEBrick::AccessLog::COMMON_LOG_FORMAT], [wblog, WEBrick::AccessLog::REFERER_LOG_FORMAT] ] ) if $record_session_filename require 'nitro/adapter/webrick/vcr' VCR.record($record_session_filename) end if $playback_session_filename require 'nitro/adapter/webrick/vcr' VCR.playback($playback_session_filename) end @webrick = WEBrick::HTTPServer.new() trap('INT') { stop } @webrick.mount('/', WebrickAdapter, server) initialize_webrick(server) @webrick.start end |
.stop ⇒ Object
Stop the Webrick adapter.
71 72 73 |
# File 'lib/nitro/adapter/webrick.rb', line 71 def stop @webrick.shutdown end |