Get Started

Installation

Synvert is distributed using RubyGems.

To install the latest version, run

$ gem install synvert

This will install synvert, along with synvert-core and other dependencies.

Usage

Now you can use synvert to convert your ruby code.

$ synvert -h
Usage: synvert [project_path]
    -d, --load SNIPPET_PATHS         load custom snippets, snippet paths can be local file path or remote http url
    -l, --list                       list all available snippets
    -o, --open SNIPPET_NAME          open a snippet in editor
    -q, --query QUERY                query specified snippets
        --skip FILE_PATTERNS         skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb
    -s, --show SNIPPET_NAME          show specified snippet description, SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax
        --sync                       sync snippets
    -r, --run SNIPPET_NAMES          run specified snippets, each SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax,ruby/new_lambda_syntax
    -v, --version                    show this version
Sync snippets

snippets are available on github, you can sync them any time you want.

$ synvert --sync
List snippets

List all available snippets

$ synvert -l
Show a snippet

Describe what a snippet does.

$ synvert -s factory_girl/use_short_syntax
Open a snippet

Open a snippet in your editor, editor is defined in ENV['SNIPPET_EDITOR'] or ENV['EDITOR']

$ synvert -o factory_girl/use_short_syntax
Run a snippet

Run a snippet, analyze and then change code.

$ synvert -r factory_girl/use_short_syntax ~/Sites/railsbp/rails-bestpractices.com

It’s recommended that you use version control software like git, after using synvert, you can use check what changes synvert does to your ruby code.

You can write your own snippets then load them by --load.

Dependencies

Synvert uses parser and ast, parser helps to parse ruby source code and rewrite ast nodes, ast is a small library for working with immutable abstract syntax trees. It’s highly recommended to look through these 2 libraries.