Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/synvert-hq/synvert-ruby
write snippet code to rewrite your project code
https://github.com/synvert-hq/synvert-ruby
ruby synvert
Last synced: 3 months ago
JSON representation
write snippet code to rewrite your project code
- Host: GitHub
- URL: https://github.com/synvert-hq/synvert-ruby
- Owner: synvert-hq
- License: mit
- Created: 2014-02-24T06:53:46.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T01:19:07.000Z (7 months ago)
- Last Synced: 2024-04-13T13:08:32.582Z (7 months ago)
- Topics: ruby, synvert
- Language: Ruby
- Homepage: https://synvert.net
- Size: 421 KB
- Stars: 686
- Watchers: 8
- Forks: 19
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# synvert-ruby
[![AwesomeCode Status for synvert-hq/synvert-ruby](https://awesomecode.io/projects/47cd9805-171c-4c61-b927-baa46cd4020a/status)](https://awesomecode.io/repos/synvert-hq/synvert-ruby)
[![Build Status](https://github.com/synvert-hq/synvert-ruby/actions/workflows/main.yml/badge.svg)](https://github.com/synvert-hq/synvert-ruby/actions/workflows/main.yml)
[![Gem Version](https://badge.fury.io/rb/synvert.svg)](http://badge.fury.io/rb/synvert)`synvert-ruby` is a command tool to rewrite ruby code automatically, it depends on `synvert-core-ruby` and `synvert-snippets-ruby`.
[synvert-core-ruby](https://github.com/synvert-hq/synvert-core-ruby) provides a set of DSLs to rewrite ruby code.
[synvert-snippets-ruby](https://github.com/synvert-hq/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](https://github.com/synvert-hq/synvert-snippets-ruby) 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/synvert-hq/synvert-core-ruby
```Run a snippet from remote url
```
$ synvert-ruby -r https://raw.githubusercontent.com/synvert-hq/synvert-snippets-ruby/master/lib/factory_bot/use_short_syntax.rb ~/sites/synvert-hq/synvert-core-ruby
```Run a snippet from local path
```
$ synvert-ruby -r ~/.synvert-ruby/lib/factory_bot/use_short_syntax.rb ~/sites/synvert-hq/synvert-core-ruby
```Skip paths
```
$ synvert-ruby -r factory_bot/use_short_syntax --skip-paths vendor/ ~/sites/synvert-hq/synvert-core-ruby
```Only paths
```
$ synvert-ruby -r factory_bot/use_short_syntax --only-paths app/models/ ~/sites/synvert-hq/synvert-core-ruby
```Show processing files when running a snippet.
```
$ synvert-ruby -r factory_bot/use_short_syntax --show-run-process ~/Sites/synvert-hq/synvert-core-ruby
```### Generate a snippet
Generate a new snippet
```
$ synvert-ruby -g ruby/convert_foo_to_bar
```