• Stars
    star
    678
  • Rank 64,326 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 10 years ago
  • Updated 3 months ago

Reviews

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

Repository Details

write snippet code to rewrite your project code

synvert-ruby

logo

AwesomeCode Status for xinminlabs/synvert-ruby Main workflow Gem Version

synvert-ruby is a command tool to rewrite ruby code automatically, it depends on synvert-core-ruby and synvert-snippets-ruby.

synvert-core-ruby provides a set of DSLs to rewrite ruby code.

synvert-snippets-ruby provides official snippets to rewrite ruby code.

Installation

To install the latest version, run

$ gem install synvert

This will also install synvert-core-ruby.

Synvert is completely working with remote snippets on github, but you can sync all official snippets locally to make it run faster.

$ synvert-ruby --sync

Then you can use synvert to rewrite your ruby code, e.g.

$ synvert-ruby -r factory_bot/use_short_syntax

Usage

$ synvert-ruby -h
Usage: synvert-ruby [project_path]
    -l, --list                       list all available snippets
    -q, --query QUERY                query specified snippets
    -s, --show SNIPPET_NAME          show specified snippet description, SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax
    -o, --open SNIPPET_NAME          Open a snippet
    -g, --generate NEW_SNIPPET_NAME  generate a new snippet
        --sync                       sync snippets
        --execute EXECUTE_COMMAND    execute snippet
    -r, --run SNIPPET_NAME           run a snippet with snippet name, e.g. ruby/new_hash_syntax, or remote url, or local file path
    -t, --test SNIPPET_NAME          test a snippet with snippet name, e.g. ruby/new_hash_syntax, or remote url, or local file path
        --show-run-process           show processing files when running a snippet
        --only-paths DIRECTORIES     only specified files or directories, separated by comma, e.g. app/models,app/controllers
        --skip-paths FILE_PATTERNS   skip specified files or directories, separated by comma, e.g. vendor/,lib/**/*.rb
    -f, --format FORMAT              output format
        --number-of-workers NUMBER_OF_WORKERS
                                     set the number of workers, if it is greater than 1, it tests snippet in parallel
        --double-quote               prefer double quote, it uses single quote by default
        --tab-width TAB_WIDTH        prefer tab width, it uses 2 by default
    -v, --version                    show this version

Sync snippets

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

$ synvert-ruby --sync

List snippets

List all available snippets

$ synvert-ruby -l

$ synvert-ruby --list --format json

Show a snippet

Describe what a snippet does.

$ synvert-ruby -s factory_bot/use_short_syntax

Open a snippet

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

$ synvert-ruby -o factory_bot/use_short_syntax

Run a snippet

Run a snippet, analyze and then rewrite code.

$ synvert-ruby -r factory_bot/use_short_syntax ~/Sites/xinminlabs/synvert-core-ruby

Run a snippet from remote url

$ synvert-ruby -r https://raw.githubusercontent.com/xinminlabs/synvert-snippets-ruby/master/lib/factory_bot/use_short_syntax.rb ~/sites/xinminlabs/synvert-core-ruby

Run a snippet from local path

$ synvert-ruby -r ~/.synvert-ruby/lib/factory_bot/use_short_syntax.rb ~/sites/xinminlabs/synvert-core-ruby

Skip paths

$ synvert-ruby -r factory_bot/use_short_syntax --skip-paths vendor/ ~/sites/xinminlabs/synvert-core-ruby

Only paths

$ synvert-ruby -r factory_bot/use_short_syntax --only-paths app/models/ ~/sites/xinminlabs/synvert-core-ruby

Show processing files when running a snippet.

$ synvert-ruby -r factory_bot/use_short_syntax --show-run-process ~/Sites/xinminlabs/synvert-core-ruby

Generate a snippet

Generate a new snippet

$ synvert-ruby -g ruby/convert_foo_to_bar

More Repositories

1

newrelic-grape

newrelic instrument for grape
Ruby
120
star
2

synvert-snippets-ruby

write snippet code to rewrite your project code
Ruby
94
star
3

openfire-apns-plugin

openfire-apns-plugin is used to integrate Apple Push Notification Service to Openfire.
Java
58
star
4

synvert-core-ruby

write snippet code to rewrite your project code
Ruby
44
star
5

newrelic-rake

NewRelic instrument for rake task
Ruby
29
star
6

rubocop-config-prettier

Turns off all rules that are unnecessary or might conflict with prettier plugin ruby
Ruby
21
star
7

simple_paginate

Simple pagination solution for previous and next page navigation
Ruby
20
star
8

node-query-ruby

It defines a NQL (node query language) and node rules to query AST nodes.
Ruby
9
star
9

rails-performance-tips-code

Ruby
7
star
10

rubocop-config-rufo

Turns off all rubocop cops that are unnecessary or might conflict with rufo.
Ruby
6
star
11

synvert

write snippet code to rewrite your source code.
5
star
12

node-mutation-ruby

It provides a set of APIs to rewrite AST node source code.
Ruby
4
star
13

synvert-javascript

write snippet code to rewrite your project code
TypeScript
4
star
14

synvert-playground

synvert playground
TypeScript
2
star
15

SerializedUser

Serialize user with NSUserDefaults and save sensitive token with SSKeychain
Objective-C
2
star
16

synvert-snippets-javascript

write snippet code to rewrite your project code
JavaScript
2
star
17

parser_node_ext

extend parser node, add parent and sibling, assign names to the child nodes.
Ruby
2
star
18

guard-bower_rails

Ruby
2
star
19

node-mutation-javascript

It provides a set of APIs to rewrite AST node source code.
TypeScript
2
star
20

synvert-tools

Ruby
2
star
21

node-query-javascript

It defines a NQL (node query language) and node rules to query AST nodes.
TypeScript
2
star
22

rails-performance-tips-au

Rails Performance Tips
JavaScript
1
star
23

synvert-core-javascript

write snippet code to rewrite your project code
TypeScript
1
star
24

awesomecode-synvert-ruby

Shell
1
star
25

blog.xinminlabs.com

http://blog.xinminlabs.com
HTML
1
star
26

synvert-gui

JavaScript
1
star
27

synvert-vscode-extension

synvert vscode extension
TypeScript
1
star
28

syntax_tree_ext

extend syntax_tree, add parent and sibling
Ruby
1
star
29

synvert-api-javascript

TypeScript
1
star
30

acts_as_viewable

Make models to be viewable
Ruby
1
star
31

synvert-ui-common

common methods for synvert ui (GUI, vscode extension and web)
TypeScript
1
star
32

prism_ext

prism ext
Ruby
1
star