How to reformat Ruby code?


#1

I just started using the editor and curious what should I use to reformat the code, like a beautifier script etc.


#2

There are some packages to do that but only for HTML, CSS and Javascript files.

Nothing for Ruby yet.

But, this is a great opportunity to contribute if you feel like, you can get inspiration from those packages and create a beautifier for ruby or add support for Ruby on one of the existing packages.


#3

So I started on this and tried to convert this textmate bundle I had been using with these instructions.

apm init --package ~/.atom/packages/code-beautifier --convert https://github.com/mocoso/code-beautifier.tmbundle.git

There are no errors thrown but an empty package is created with simply a Readme file and a default package.json file.


#4

The reason why Ruby formatting doesn’t yet exist seems to be that Ruby reformatters are generally written in Ruby. But the current reformatting packes are all written in Javascript. And so a Ruby formatter will need to do a little more work - running the Ruby code in a new process, etc.