Are there any programs or IDEs that support refactoring for Ruby or RoR?
8 Answers
The best refactoring tool is good test coverage. If your tests cover your code and they all past you can just make whatever changes you want and the tests will find any dependencies you have broken. This is the main reason why IDE-based refactoring tools are less prevalent in Ruby than elsewhere.
-
Refactoring tools are less prevalent in Ruby because refactoring a dynamic language is really hard. Imagine you were renaming a method.. in a strongly typed language you look for all calls to that method on that typed variable. In ruby.... you just don't know! With Method Missing... doubly so. Jul 20, 2012 at 12:03
-
1The fact that it's harder to do than in a static language doesn't mean tools can't do anything helpful. Here's an example of local refactorings, and for global ones, you can always ask the user to confirm each renaming, it's still faster than doing them all unassisted.– DmitryDec 26, 2012 at 17:10
IntelliJ IDEA with Ruby plugin supports some refactorings.
-
-
RubyMine does support automated refactoring so it's worth a look RubyMine May 12, 2012 at 8:41
I believe net-beans and eclipse both support some refactoring within their 'ruby-mode' - also the emacs code browser (ECB) and the various ruby support tools (e.g. rinari) for emacs have some support.
Aptana has some simple refactoring tools. I often extract into partials and they have a simple shortcut for pulling things out, creating a file and inserting the right call to the partial. Not the most amazing ever but it's useful
I'd be bold and say that Rubymine has the best rails/ruby refactoring in all RoR IDEs. Give it a try and see for your self.
There's also 3rdRail from CodeGear (from Delphi fame). The only catch is that it's not free.
I've used the refactoring in netbeans. I didn't find it that much more useful than find and replace.