Eden is a source-code formatter for Ruby. It's designed around a robust lexical analyzer able to handle most of the dark corners of Ruby syntax, and able to be easily modified and extended.
Eden is available as a gem. To install it, simply run:
gem install eden
Eden's formatter modules are able to be configured using a Ruby configuration DSL. Eden loads defaults when it
starts, but if you wish to override options on a project-specific basis, you can do so by creating
config/eden.rb. For example, if you wish to use tabs instead of spaces to indent a project's code, put
the following in
Indenter.configure do |i| i.indent_characters_per_step 1 i.indent_character "\t" end
lib/eden/defaults.rb for full configuration options.
Eden is designed to be used with a source-control system, so when it formats Ruby source files, it writes changes to the file in place. The basic format for running Eden is:
eden command options filenames
Eden understands 2 commands:
colorize- Displays a ANSI colorized version of the source. This is mainly used for debugging the lexer.
rewrite- Rewrites the source files in place to be correctly formatted
Valid options are:
--backup- make backup copies of any changed files when rewriting. The backup files are the same file name with a tilde ('~') appended.
eden rewrite source_file.rb
will rewrite source_file.rb
eden rewrite ./**/*.rb
will rewrite all the .rb files in the current directory and any subdirectories.
Eden was created by Jason Langenauer (email@example.com or @jasonlangenauer on Twitter). Any feedback/comments/suggestions gratefully received.