Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reformat ruby code from the command line?

Given a source file with bad indentation, incorrect white space management, and so on. How do I reformat the code such a file and apply the Ruby's style guide (if present)?

like image 760
Ties Avatar asked May 17 '11 21:05

Ties


1 Answers

This should be a task of your editor. In vim (configured for Ruby), just press gg=G xD

A Ruby script that does it is available at: http://www.arachnoid.com/ruby/rbeautify.rb.html

like image 197
J-_-L Avatar answered Oct 11 '22 13:10

J-_-L