Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/progrhyme/ruby-align
Code Alignment Tool for Ruby
https://github.com/progrhyme/ruby-align
Last synced: 18 days ago
JSON representation
Code Alignment Tool for Ruby
- Host: GitHub
- URL: https://github.com/progrhyme/ruby-align
- Owner: progrhyme
- License: mit
- Created: 2016-03-27T07:05:17.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-24T02:22:04.000Z (over 8 years ago)
- Last Synced: 2024-11-05T22:41:52.653Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ruby-align [![Build Status](https://travis-ci.org/key-amb/ruby-align.svg?branch=master)](https://travis-ci.org/key-amb/ruby-align)
A code formatter for Ruby to make alignment.
# Usage
```
ruby-align your_program.rb
ruby-align --[f]ile=your_program.rb
```Or it can receive input from _STDIN_ and output formatted code.
# How this works?
This script provides functionality of aligning code elements such as variable
assignments or hash declarations.Here's an example:
```ruby
## before
a = 1
dddd ||= (1..3)
bb -= 20
e = { foo: 1, bar: 'Bar' }stash = {
foo: 123,
'bar' => 'Bar',
"bazz" => %w[ x y z ]
}## after
a = 1
dddd ||= (1..3)
bb -= 20
e = { foo: 1, bar: 'Bar' }stash = {
foo: 123,
'bar' => 'Bar',
"bazz" => %w[ x y z ]
}
```If you are curious, you can see formatting examples under `spec/` directory.
In `spec/subjects/` directory, there are some unformatted code snippets.
And formatted results of them are in `spec/expects/` directory.# Call `ruby-align` in Text Editors
Because I am a _vimmer_, here is only example of `.vimrc`.
```vim
" == ruby-align ==
" set your favorite leader key
let mapleader = ","
noremap ra :%! /path/to/ruby-align
noremap rav :'<,'>! /path/to/ruby-align
```If you add this into your `.vimrc`, you can call `ruby-align` to whole your
buffer by typing `,ra`.
Or you can partially apply it by `,rav` for selected area in visual mode.Settings for other editors are welcome.
# CAUTION
This program might have bugs.
Please take a backup before you apply this to your code.For known issues, see the [issue list](https://github.com/key-amb/ruby-align/issues)
in this project.# LICENSE
The MIT License (MIT)
Copyright (c) 2016 IKEDA Kiyoshi