I fairly often find myself changing the name of a class, as a project alters over time.

In a rails project, this means I have to;

  • Rename the source code (e.g. app/models/foo.rb -> app/models/bar.rb)
  • Rename the spec file (e.g. spec/models/foo_spec.rb -> spec/models/bar_spec.rb)
  • Search and replace in my code, changing e.g. ‘Foo’ to ‘Bar’ but not changing ‘FooBaz’ etc.

Although I really like working in vim, this is one time when I miss having a refactoring IDE.

So, I’ve written a little tool to make this easier.

Here is the repository on GitHub;

https://github.com/digitalronin/rails-class-renamer

It’s pretty basic, but I think it does enough to be useful, and should save me a bit of time – hopefully, you too.

Merry Xmas.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s