Module: Middleman::CoreExtensions::Request::ServerMethods
- Defined in:
- middleman-core/lib/middleman-core/core_extensions/request.rb
Instance Method Summary (collapse)
-
- (Class) server(&block)
Create a new Class which is based on Middleman::Application Used to create a safe sandbox into which extensions and configuration can be included later without impacting other classes and instances.
-
- (Rack::Server) start_server(options = {})
Creates a new Rack::Server.
Instance Method Details
- (Class) server(&block)
Create a new Class which is based on Middleman::Application Used to create a safe sandbox into which extensions and configuration can be included later without impacting other classes and instances.
131 132 133 134 135 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 131 def server(&block) @@servercounter ||= 0 @@servercounter += 1 const_set("MiddlemanApplication#{@@servercounter}", Class.new(Middleman::Application)) end |
- (Rack::Server) start_server(options = {})
Creates a new Rack::Server
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'middleman-core/lib/middleman-core/core_extensions/request.rb', line 141 def start_server(={}) opts = { :Port => [:port] || 4567, :Host => [:host] || "0.0.0.0", :AccessLog => [] } app_class = [:app] ||= ::Middleman.server.inst opts[:app] = app_class require "webrick" opts[:Logger] = WEBrick::Log::new(RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/i ? 'NUL:' : '/dev/null', 7) if ![:logging] opts[:server] = 'webrick' server = ::Rack::Server.new(opts) server.start server end |