• Stars
    star
    142
  • Rank 253,308 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a cli tool to beautify ruby output to screen.

Ruby Beautify Build Status Gitter

This gem provides a cli binary named 'ruby-beautify' that will pretty up ruby code.

Currenty, 'rbeautify' is included for backwards compatibility but will likely be phased out at some point.

Installation

gem install ruby-beautify

Usage

To Pretty up a file:

ruby-beautify filename

Without a filename it reads from STDIN, suitable for piping:

curl https://raw.githubusercontent.com/erniebrodeur/ruby-beautify/master/spec/monolithic_example.rb | ruby-beautify

It has help:

ruby-beautify --help

You can pick your indent character:

ruby-beautify --(t)abs

ruby-beautify --(s)paces

You can also pick the count of characters:

ruby-beautify --indent_(c)ount 1

Examples:

ruby-beautify -c 2 -s filename

ruby-beautify filename

ruby-beautify -t -c 2 filename

Advanced Usage

You can over write files in place, this is useful for doing an entire directory of files at once. This will not over write any files that fail syntax check.

ruby-beautify --overwrite **/*.rb

Configuration file

It can use a configuration file like some of the other ruby projects out there. The config file consists of each argument on a new line. Something like this:

--spaces
--indent_count=2

Note, you'll have to add the equal sign between value and argument (tricky bit, that).

Placing this into a .ruby-beautify anywhere in your tree (like git) will work. This allows you to put it at the root of a project and have it change the defaults anywhere in the project.

Bugs

Please feel free to open issues, I am actively working on this project again, thanks entirely to the ripper gem.

The gaps are getting smaller. I think we have most of the basic ruby use cases in place. I don't use rails/dsl's too often so I haven't tested those. I suspect it should 'just work' since the way we do syntax matching is really agnostic to what a DSL can change.

Todo

  • Add vim style comment hinting.
  • add specs/pipe testing (epic).
  • remove the link to rbeautify (by 1.0).

Longer term I'd like to do some more to assignment, line wrapping, and spacing in/around keywords.

Contributing

Please see the Contribution Guide file for specifics on how to contribute to this project.

History

The original analyzer is available at: http://www.arachnoid.com/ruby/rubyBeautifier.html.

My work is based off of this sublime-text2 plugin: https://github.com/CraigWilliams/BeautifyRuby but cleaned up and made suitable for use directly in a shell.

I've recently re-written this to use the stdlib ripper gem to do the lexical analyzing. Consequently I've dropped all of the old legacy code that did this.

More Repositories

1

pushover

A gem to interface with pushover.net
Ruby
64
star
2

guard-rubybeautify

A guard to automatically beautify ruby files in a project.
Ruby
4
star
3

bini

A series of ruby snippets that help me on the shell.
Ruby
3
star
4

chef-recipe-rake

a chef recipe to interact and pass arbitrary commands to rake.
Ruby
3
star
5

AUR-Projects

These are the PKGBUILD's I maintain my aur packs with.
Perl
2
star
6

xscreen_usb_unlocker

A tool to lock and unlock xscreensaver based on a device being plugged in (or not) to usb.
Ruby
2
star
7

dotfiles-xfce4

2
star
8

dotfiles-cairo-dock

Cairo-dock
Python
2
star
9

dotfiles-compiz

My compiz configuration settings.
2
star
10

arch32micro

Various shell scripts related to arch in an AWS instance.
Shell
2
star
11

hilight

Hilight will highlight CLI based applications based on regular expressions.
Ruby
2
star
12

nehe-ruby

NeHe Tutorials in Ruby
Ruby
1
star
13

creatable

extension for ruby to mixin a create method and dynamic attributes to go with.
Ruby
1
star
14

dotfiles-powerline

1
star
15

next_background

TODO: one-line summary of your gem
Ruby
1
star
16

dotfiles-tilda

My tilda files.
1
star
17

arch-runit

A series of runit style configs I've created for less common applications.
Shell
1
star
18

speedy_terminal

How fast is your screen? Or a pointless endeavor for clockcycles I didn't need.
Ruby
1
star
19

dotfiles-themes

Not a specific theme, more my exported settings so I can replicate my desktop between my work and home.
1
star
20

threejs-sandbox

A threejs sandbox.
Ruby
1
star
21

chef-jabberd

Ruby
1
star
22

goprompt

A fast colorized prompt for the shell
Go
1
star