Class: RailsUpgrade::Upgraders::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-upgrade/upgraders/routes.rb

Instance Method Summary collapse

Instance Method Details

#upgrade!(args) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/rails-upgrade/upgraders/routes.rb', line 8

def upgrade!(args)
  if File.exists?("config/routes.rb")
    upgrade_routes
  else
    raise FileNotFoundError, "Can't find your routes file [config/routes.rb]!"
  end
end

#upgrade_routesObject



16
17
18
19
20
21
22
23
# File 'lib/rails-upgrade/upgraders/routes.rb', line 16

def upgrade_routes
  ActionController::Routing::Routes.setup

  eval(File.read("config/routes.rb"))

  generator = RouteGenerator.new(ActionController::Routing::Routes.redrawer.routes)
  puts generator.generate
end