Class: Rack::JekyllDispatch
- Inherits:
-
Object
- Object
- Rack::JekyllDispatch
- Defined in:
- lib/rack/jekyll_dispatch.rb,
lib/rack/jekyll_dispatch/version.rb,
lib/rack/jekyll_dispatch/file_handler.rb
Defined Under Namespace
Classes: FileHandler
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ JekyllDispatch
constructor
A new instance of JekyllDispatch.
Constructor Details
#initialize(app, opts = {}) ⇒ JekyllDispatch
Returns a new instance of JekyllDispatch.
6 7 8 9 10 |
# 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 |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# 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 |