From 28b809bc015d85174039f3338b4bf69e25c1143f Mon Sep 17 00:00:00 2001 From: Jeremy McAnally Date: Wed, 3 Feb 2010 10:58:52 -0600 Subject: [PATCH] Fix bug where our fake AC::Routing::Routes was stomping on the real one. --- lib/routes_upgrader.rb | 45 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/routes_upgrader.rb b/lib/routes_upgrader.rb index acf2e6c..48b9cf9 100644 --- a/lib/routes_upgrader.rb +++ b/lib/routes_upgrader.rb @@ -1,6 +1,27 @@ # TODO: Fix formatting on member/collection methods + module Rails module Upgrading + module FakeRouter + module ActionController + module Routing + class Routes + def self.setup + @redrawer = Rails::Upgrading::RouteRedrawer.new + end + + def self.redrawer + @redrawer + end + + def self.draw + yield @redrawer + end + end + end + end + end + class RoutesUpgrader def generate_new_routes if has_routes_file? @@ -19,14 +40,14 @@ module Rails end def upgrade_routes - ActionController::Routing::Routes.setup + FakeRouter::ActionController::Routing::Routes.setup # Read and eval the file; our fake route mapper will capture # the calls to draw routes and generate new route code - eval(routes_code) + FakeRouter.module_eval(routes_code) # Give the route set to the code generator and get its output - generator = RouteGenerator.new(ActionController::Routing::Routes.redrawer.routes) + generator = RouteGenerator.new(FakeRouter::ActionController::Routing::Routes.redrawer.routes) generator.generate end end @@ -315,22 +336,4 @@ module Rails end end end -end - -module ActionController - module Routing - class Routes - def self.setup - @redrawer = Rails::Upgrading::RouteRedrawer.new - end - - def self.redrawer - @redrawer - end - - def self.draw - yield @redrawer - end - end - end end \ No newline at end of file