Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/iamsolankiamit/prettier-ruby

Prettier for ruby
https://github.com/iamsolankiamit/prettier-ruby

prettier ruby

Last synced: about 2 months ago
JSON representation

Prettier for ruby

Awesome Lists containing this project

README

        

# Please Check the official repo here [prettier-plugin-ruby](https://github.com/prettier/plugin-ruby)

This repo is deprecated

---

# Prettier Ruby Plugin
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)


:construction: Work in Progress! :construction:

## 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](https://docs.ruby-lang.org/en/2.5.0/Ripper.html), 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](https://github.com/prettier/prettier/blob/master/commands.md) 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](https://github.com/prettier/prettier/blob/master/CONTRIBUTING.md),
as it all applies to this repository too.

### Development

Prettier-Ruby makes use of Ruby's official lexer and parser, [Ripper](https://docs.ruby-lang.org/en/2.5.0/Ripper.html).
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:

```bash
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](./documentation/debug-example.png)

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:

```bash
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](https://github.com/kentcdodds/all-contributors#emoji-key)):

| [
Alan Foster](http://www.alanfoster.me/)
[📖](https://github.com/iamsolankiamit/prettier-ruby/commits?author=AlanFoster "Documentation") [🐛](https://github.com/iamsolankiamit/prettier-ruby/issues?q=author%3AAlanFoster "Bug reports") [💻](https://github.com/iamsolankiamit/prettier-ruby/commits?author=AlanFoster "Code") [🤔](#ideas-AlanFoster "Ideas, Planning, & Feedback") | [
Amit Solanki](http://solankiamit.com)
[📖](https://github.com/iamsolankiamit/prettier-ruby/commits?author=iamsolankiamit "Documentation") [🐛](https://github.com/iamsolankiamit/prettier-ruby/issues?q=author%3Aiamsolankiamit "Bug reports") [💻](https://github.com/iamsolankiamit/prettier-ruby/commits?author=iamsolankiamit "Code") [🤔](#ideas-iamsolankiamit "Ideas, Planning, & Feedback") [💡](#example-iamsolankiamit "Examples") [👀](#review-iamsolankiamit "Reviewed Pull Requests") [⚠️](https://github.com/iamsolankiamit/prettier-ruby/commits?author=iamsolankiamit "Tests") |
| :---: | :---: |

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!