Object
# File lib/ferret/browser.rb, line 10 10: def run(env) 11: controller, action, args = :home, :index, nil 12: query_string = env['QUERY_STRING']||'' 13: params = parse_query_string(query_string) 14: req_path = env['PATH_INFO'].gsub(/\/+/, '/') 15: case req_path 16: when '/' 17: # nothing to do 18: when /^\/?([-a-zA-Z]+)\/?$/ 19: controller = $1 20: when /^\/?([-a-zA-Z]+)\/([-a-zA-Z]+)\/?(.*)?$/ 21: controller = $1 22: action = $2 23: args = $3 24: else 25: controller = :error 26: args = req_path 27: end 28: controller_vars = { 29: :params => params, 30: :req_path => req_path, 31: :query_string => query_string, 32: } 33: delegate(controller, action, args, controller_vars) 34: end
# File lib/ferret/browser.rb, line 38 38: def delegate(controller, action, args, controller_vars) 39: begin 40: controller = to_const(controller, 'Controller'). 41: new(@reader, @path, controller_vars) 42: controller.send(action, args) 43: rescue Exception => e 44: puts e.to_s 45: controller_vars[:params][:error] = e 46: ErrorController.new(@reader, @path, controller_vars).index 47: end 48: end
# File lib/ferret/browser.rb, line 60 60: def parse_query_string(query_string, delim = '&;') 61: m = proc {|_,o,n| o.update(n, &m) rescue ([*o] << n)} 62: (query_string||'').split(/[#{delim}] */). 63: inject({}) { |hash, param| key, val = unescape_uri(param).split('=',2) 64: hash.update(key.split(/[\]\[]+/).reverse. 65: inject(val) { |x,i| Hash[i,x] }, &m) 66: } 67: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.