Sha256: 79ab676f8f4cbc8b8d0cc9ba5efd42d402707ccdf807bd23ef8c1b619bf4d7d7

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

module Frank
  class Statik
 
    def initialize(app, options={})
      @app = app
      frank_root = File.expand_path(File.dirname(__FILE__)) + '/templates'
      root = options[:root] || Dir.pwd
      @frank_server = Rack::File.new(frank_root)
      @static_server = Rack::File.new(root)
    end
 
    # handles serving from __frank__
    # looks for static access, if not found,
    # passes request to frank
    def call(env)
      path = env['PATH_INFO']
 
      if path.include? '__frank__'
        env['PATH_INFO'].gsub!('/__frank__', '')
        result = @frank_server.call(env)
      elsif path.index('/') == 0
        result = @static_server.call(env)
      end
      return result if result[0] == 200
      @app.call(env)
    end
 
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
frank-0.2.0 lib/frank/statik.rb