Method: Whisper::Handler#initialize

Defined in:
lib/whisper/handler.rb

#initialize(request_method, pathspec, &page_creator) ⇒ Handler

Returns a new instance of Handler.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/whisper/handler.rb', line 17

def initialize request_method, pathspec, &page_creator
  @request_method = request_method
  @pathspec = pathspec
  @page_creator = page_creator
  @map = TimedMap.new
  @uses_page = @uses_format = false

  re = @pathspec.gsub(/\+(\w+)/) do
    '([^\.\/][^\/]*?)' # regular path components must start with a non-., non-/, followed by 0 or more non-/es
  end.sub(/\/:page:format$/) do
    @uses_page = @uses_format = true
    '\/?(\d+)?(?:\.([^\/]+))?'
  end.sub(/:format$/) do
    @uses_format = true
    '(?:\.([a-zA-Z]+))?'
  end
  @re = /^#{re}$/
end