Skip to content

Instantly share code, notes, and snippets.

@kristianmandrup
Created February 10, 2010 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristianmandrup/300297 to your computer and use it in GitHub Desktop.
Save kristianmandrup/300297 to your computer and use it in GitHub Desktop.
Example - Upgrade an old Rails 2 app to Rails 3 app.
---
Copy existing project (just in case!)
Use Rails template approach combined with Rails generators and a special Code refactoring library with Code refactoring operations.
- define different types of artifacts
- rails ruby file (*.rb)
- model file (app/models/**/*.rb)
- view file (app/views/**/*.rb)
- environment (config/environment.rb)
...
Define a Chain of Refactor steps for each type of artifact.
Each file is matched to one or more types of artifacts, and then chain of refactor steps is executed.
Common code matchings:
CONSTANT(::CONSTANT)*.message(args)
variable.(variable)*.message(args)
message(args)
# match on first end with same indentation (any tab converted to single space!)
statement do |args|
end
--
DSL for code refactor operations using block, yield
Community should commit patches for different parts of app, plugin migrations etc.
Sweet!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment