Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

iamsolankiamit/prettier-ruby

Repository files navigation

Please Check the official repo here prettier-plugin-ruby

This repo is deprecated


Prettier Ruby Plugin

All Contributors

🚧 Work in Progress! 🚧

WORK IN PROGRESS

Please note that this plugin is under active development, and might not be ready to run on production code yet.

How it works

Prettier-Ruby relies on Ripper, the official parser of Ruby to understand your code. Once your code has been read and parsed, it is then reformatted using the formatting commands provided by Prettier.

Contributing

If you're interested in contributing to the development of Prettier for Ruby:

  • Clone this repository
  • Run yarn to install dependencies
  • Ensure all tests run with yarn run test

You will find it useful to read the CONTRIBUTING guide from Prettier, as it all applies to this repository too.

Development

Prettier-Ruby makes use of Ruby's official lexer and parser, Ripper. You can see the output of Ripper's tokens, sexpressions, the intermediate representation that prettier-ruby uses, as well as the final prettier-ruby result by appending DEBUG=true when running tests:

DEBUG=true yarn run test --watch

You should now see some useful debug output in your console:

Debug mode enabled, showing the parsed Ruby tokens and more

You can run the Ruby AST Exporter directly with a given string too:

$ ruby vendor/ruby/astexport.rb "puts 'hello world'"

To run an individual test folder:

DEBUG=true yarn run test tests/defs --watch

Usage

Until this package is officially released to npm you must clone it yourself, and run it directly:

  • Clone this repository
  • Run yarn to install dependencies
  • Run yarn prettier test.rb to check the output of a single file
  • Run on multiple files with yarn prettier your_folder/**/*.rb
  • Save the result with yarn prettier your_folder/**/*.rb --write

Contributors

Thanks goes to these wonderful people (emoji key):


Alan Foster

📖 🐛 💻 🤔

Amit Solanki

📖 🐛 💻 🤔 💡 👀 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •