class Rack::JekyllDispatch

Constants

VERSION

Public Class Methods

new(app,opts={}) click to toggle source
# File lib/rack/jekyll_dispatch.rb, line 6
def initialize(app,opts={})
  @app = app
  path = (opts[:source].nil?) ? Dir.pwd + "/public/jekyll" : opts[:source]
  @file_handler = FileHandler.new(path)
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/jekyll_dispatch.rb, line 12
def call(env)
  case env['REQUEST_METHOD']
  when 'GET', 'HEAD'
    path = env['PATH_INFO'].chomp('/')
    if match = @file_handler.match?(path)
      env["PATH_INFO"] = match
      return @file_handler.call(env)
    end
  end

  @app.call(env)
end