lib/spire/router.rb in spire-0.4.10 vs lib/spire/router.rb in spire-0.4.11

- old
+ new

@@ -1,9 +1,11 @@ module Spire class Router - def initialize(map) + def initialize(map, app_root) @map = map + app_root["config.ru"] = "app" + @app_root = app_root end def route(env) request = Rack::Request.new(env) request_path = env["REQUEST_PATH"] @@ -23,14 +25,11 @@ return self.run(@map.get(request_path), request) end def run(maps_to, request) - path = File.expand_path(__FILE__) - path["lib/spire/router.rb"] = "app/controllers" - - require "#{path}/#{maps_to[:controller].capitalize}Controller.rb" - @class = Kernel.const_get(maps_to[:controller].capitalize).new(request) + require "#{@app_root}/controllers/#{maps_to[:controller].capitalize}Controller.rb" + @class = Kernel.const_get(maps_to[:controller].capitalize).new(request, @app_root) result = @class.method(maps_to[:action]).call buffer = @class.get_buffer if !buffer && !result