How do I reformat ruby code from the command line?
Asked Answered
S

2

7

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)?

Supposal answered 17/5, 2011 at 21:26 Comment(0)
G
2

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

Gawky answered 17/5, 2011 at 21:34 Comment(2)
That was exactly the script I was looking for (thnx). Tried it, commit 15c34bf shows an example.Supposal
btw I suspect TextMate ships with built-in Ruby support, so that a plus. VIM will do it, but that needs adjustment. I wanted something that's available from the command line to prevent the editor minefield (for TextMate, you need a licence, for VIM you need plugins, etc.).Supposal
G
2

Haven't tried it myself:

http://www.arachnoid.com/ruby/rubyBeautifier.html

Garibaldi answered 17/5, 2011 at 21:33 Comment(0)
G
2

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

Gawky answered 17/5, 2011 at 21:34 Comment(2)
That was exactly the script I was looking for (thnx). Tried it, commit 15c34bf shows an example.Supposal
btw I suspect TextMate ships with built-in Ruby support, so that a plus. VIM will do it, but that needs adjustment. I wanted something that's available from the command line to prevent the editor minefield (for TextMate, you need a licence, for VIM you need plugins, etc.).Supposal

© 2022 - 2024 — McMap. All rights reserved.