Class: Massimo::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/massimo/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site = Massimo.site) ⇒ Server

Returns a new instance of Server.



20
21
22
23
24
# File 'lib/massimo/server.rb', line 20

def initialize(site = Massimo.site)
  @site        = site
  @file_server = Rack::File.new(site.config.output_path)
  @watcher     = Massimo::Watcher.new(site)
end

Class Method Details

.start(site, port = 3000) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/massimo/server.rb', line 7

def start(site, port = 3000)
  handler = Rack::Handler.default
  trap(:INT) do
    if handler.respond_to?(:shutdown)
      handler.shutdown
    else
      exit
    end
  end
  handler.run(self.new(site), :Port => port)
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
# File 'lib/massimo/server.rb', line 26

def call(env)
  @watcher.process
  env['PATH_INFO'] << 'index.html' if env['PATH_INFO'].ends_with? '/'
  @file_server.call(env)
end