lib/frank/statik.rb in frank-0.1.3 vs lib/frank/statik.rb in frank-0.2.0

- old
+ new

@@ -1,27 +1,29 @@ -class Rack::Statik +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 + 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'] + # 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) + 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 - return result if result[0] == 200 - @app.call(env) - end + end end \ No newline at end of file