You could have noticed already that Ruby is our language of choice. It’s too awesome not to use it! And we are never tired of reminding you that. But it seems we never told you about Rubyfmt before. We will try to fix that in today’s article. Rubyfmt is a Ruby autoformatter that we want to share with you.
Rubyfmt is a Ruby autoformatter in the style of gofmt. Unlike rubocop, it is intended to only be a formatter, and not any kind of deeper analysis tool. Rubyfmt is currently “functional” in the sense that it can execute over the entirety of rspec/rspec-core and not break any of the tests.
Rubyfmt is a standalone script that only loads the standard library of Ruby, as such, it is not packaged as a gem. It is intended to be in your editor’s save hook and run really fast.
~/binto your PATH (e.g.
echo "$HOME/bin:$PATH" >> ~/.bash_profile)
- Set your editor to run
rubyfmt file_name > file_nameon save.
Rubyfmt considers any file going through the formatter, and coming out the other side with changed semantics to be a bug. Please find all the necessary information here.
By the way, you have a chance to take Ruby Certification with us. Are you in?