I'm a big fan of Resharper in Visual Studio. It has some awesome refactoring tools, similar to what you get in Eclipse for Java. Is there anything like this for Ruby? Better yet, is there a plugin or something into Vim that does refactoring for Ruby code like renaming all instances of a method or variable, renaming classes sitewide, etc?
You can check out Vim Ruby Refactoring. It has several useful refactoring patterns.
The problem with some refactorings in Ruby and other dynamic typed languages, is the lack of information of the type being refactored.
From Cedric Beust blog entry:
A few months ago, I offered the following code snippet to the author of the Ruby Refactoring Browser:
def f1(o)
o.init
end
def f2(o)
o.init
end
class C
def init
...
end
end
And I asked him: "If I rename C.init to C.init2, how do you know which o.init must be renamed in f1 and f2?".
His response was unequivocal:
"This problem is difficult for dynamically typed language. I think computer can't determine whether those must be renamed or not."
"Therefore Ruby Refactoring Browser provides two functions, one is renaming all methods that have same name, and another is renaming only methods and calls that cleary belong the class. The former renames o.init in f1 and f2, and the latter doesn't rename them."
Read the whole entry here: Dynamic language, refactoring IDE. Pick one.
Having said that, Jetbrains has the Ruby Mine IDE which has a good number of refactorings. I'm not sure how they manage this scenario though.
Ruby Mine refactorings http://img709.imageshack.us/img709/917/refactoringsonrubymine.png
There is nothing similar for VIM that I'm aware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With