synvert 0.19.2 → 0.19.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +78 -26
- data/lib/synvert/cli.rb +6 -9
- data/lib/synvert/version.rb +1 -1
- data/synvert-ruby.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2cb7297283566f1929523ec1bd27886170ce2c8dc8b4ddf6e07a13d9139ba0
|
4
|
+
data.tar.gz: 64d388db47dd58a7d40e4a97d7ad954c474b795fd52cfcc39c850e9271b1ad01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c005363c25b19c5253732c9f262643fab4ea4c928aaf10bcc11aa5672cf55464864cc7518b1f74d81ae7fb1876f075a699beb9d0444b3de05aaee98d5a15725
|
7
|
+
data.tar.gz: c6d1bb9f75b6f8a06dfd37e7bf94df5bb9750911bc00c4b9059616dddeb4629e30619b7f1fe38daf6de7f7a806b4f8cc3effd90f740addf9a2f9babb39a04e63
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,34 +2,39 @@
|
|
2
2
|
|
3
3
|
<img src="https://synvert.xinminlabs.com/img/logo_96.png" alt="logo" width="32" height="32" />
|
4
4
|
|
5
|
+
[![AwesomeCode Status for xinminlabs/synvert-ruby](https://awesomecode.io/projects/47cd9805-171c-4c61-b927-baa46cd4020a/status)](https://awesomecode.io/repos/xinminlabs/synvert-ruby)
|
5
6
|
![Main workflow](https://github.com/xinminlabs/synvert-ruby/actions/workflows/main.yml/badge.svg)
|
6
|
-
[![Coverage Status](https://coveralls.io/repos/xinminlabs/synvert/badge.svg?branch=master)](https://coveralls.io/r/xinminlabs/synvert)
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/synvert.svg)](http://badge.fury.io/rb/synvert)
|
8
8
|
|
9
|
-
|
10
|
-
automatically.
|
9
|
+
`synvert-ruby` is a command tool to rewrite ruby code automatically, it depends on `synvert-core-ruby` and `synvert-snippets-ruby`.
|
11
10
|
|
12
|
-
|
11
|
+
[synvert-core-ruby](https://github.com/xinminlabs/synvert-core-ruby) provides a set of DSLs to rewrite ruby code.
|
13
12
|
|
14
|
-
[synvert-
|
15
|
-
|
16
|
-
[synvert-snippets][2] lists all snippets to convert ruby code based on
|
17
|
-
synvert-core.
|
13
|
+
[synvert-snippets-ruby](https://github.com/xinminlabs/synvert-snippets-ruby) provides official snippets to rewrite ruby code.
|
18
14
|
|
19
15
|
## Installation
|
20
16
|
|
21
|
-
|
17
|
+
To install the latest version, run
|
18
|
+
|
22
19
|
|
23
20
|
```
|
24
21
|
$ gem install synvert
|
25
22
|
```
|
26
23
|
|
27
|
-
|
24
|
+
This will also install `synvert-core-ruby`.
|
25
|
+
|
26
|
+
Before using synvert, you need to sync all official snippets first.
|
28
27
|
|
29
28
|
```
|
30
29
|
$ synvert-ruby --sync
|
31
30
|
```
|
32
31
|
|
32
|
+
Then you can use synvert to rewrite your ruby code, e.g.
|
33
|
+
|
34
|
+
```
|
35
|
+
$ synvert-ruby -r factory_bot/use_short_syntax
|
36
|
+
```
|
37
|
+
|
33
38
|
## Usage
|
34
39
|
|
35
40
|
```
|
@@ -38,31 +43,78 @@ Usage: synvert-ruby [project_path]
|
|
38
43
|
-d, --load SNIPPET_PATHS load custom snippets, snippet paths can be local file path or remote http url
|
39
44
|
-l, --list list all available snippets
|
40
45
|
-q, --query QUERY query specified snippets
|
41
|
-
|
42
|
-
-
|
46
|
+
-s, --show SNIPPET_NAME show specified snippet description, SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax
|
47
|
+
-o, --open SNIPPET_NAME Open a snippet
|
48
|
+
-g, --generate NEW_SNIPPET_NAME generate a new snippet
|
43
49
|
--sync sync snippets
|
44
|
-
|
50
|
+
--execute execute snippet
|
51
|
+
-r, --run SNIPPET_NAME run specified snippet, e.g. ruby/new_hash_syntax
|
52
|
+
--show-run-process show processing files when running a snippet
|
53
|
+
--skip FILE_PATTERNS skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb
|
54
|
+
-f, --format FORMAT output format
|
45
55
|
-v, --version show this version
|
46
56
|
```
|
47
57
|
|
48
|
-
|
58
|
+
#### Sync snippets
|
59
|
+
|
60
|
+
[Official Snippets](https://github.com/xinminlabs/synvert-snippets-ruby) are available on github,
|
61
|
+
you can sync them any time you want.
|
62
|
+
|
63
|
+
```
|
64
|
+
$ synvert-ruby --sync
|
65
|
+
```
|
66
|
+
|
67
|
+
#### List snippets
|
68
|
+
|
69
|
+
List all available snippets
|
70
|
+
|
71
|
+
```
|
72
|
+
$ synvert-ruby -l
|
73
|
+
|
74
|
+
$ synvert-ruby --list --form json
|
75
|
+
```
|
76
|
+
|
77
|
+
#### Show a snippet
|
78
|
+
|
79
|
+
Describe what a snippet does.
|
80
|
+
|
81
|
+
```
|
82
|
+
$ synvert-ruby -s factory_bot/use_short_syntax
|
83
|
+
```
|
84
|
+
|
85
|
+
#### Open a snippet
|
86
|
+
|
87
|
+
Open a snippet in your editor, editor is defined in
|
88
|
+
`ENV['SNIPPET_EDITOR']` or `ENV['EDITOR']`
|
89
|
+
|
90
|
+
```
|
91
|
+
$ synvert-ruby -o factory_bot/use_short_syntax
|
92
|
+
```
|
93
|
+
|
94
|
+
#### Run a snippet
|
95
|
+
|
96
|
+
Run a snippet, analyze and then rewrite code.
|
97
|
+
|
98
|
+
```
|
99
|
+
$ synvert-ruby -r factory_bot/use_short_syntax ~/Sites/xinminlabs/synvert-core-ruby
|
100
|
+
```
|
101
|
+
|
102
|
+
Load custom snippet
|
49
103
|
|
50
104
|
```
|
51
|
-
$ synvert-ruby -r
|
105
|
+
$ synvert-ruby --load ~/.custom-snippets/my-own-snippet.rb -r my-own-snippet ~/Sites/xinminlabs/synvert-core-ruby
|
52
106
|
```
|
53
107
|
|
54
|
-
|
108
|
+
Show processing files when running a snippet.
|
55
109
|
|
56
|
-
|
110
|
+
```
|
111
|
+
$ synvert-ruby -r factory_bot/use_short_syntax --show-run-process ~/Sites/xinminlabs/synvert-core-ruby
|
112
|
+
```
|
57
113
|
|
58
|
-
|
114
|
+
#### Generate a snippet
|
59
115
|
|
60
|
-
|
61
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
-
5. Create new Pull Request
|
116
|
+
Generate a new snippet
|
65
117
|
|
66
|
-
|
67
|
-
|
68
|
-
|
118
|
+
```
|
119
|
+
$ synvert-ruby -g ruby/convert_foo_to_bar
|
120
|
+
```
|
data/lib/synvert/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'optparse'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
module Synvert
|
6
7
|
# Synvert command line interface.
|
@@ -165,15 +166,11 @@ module Synvert
|
|
165
166
|
Core::Rewriter.availables.each do |group, rewriters|
|
166
167
|
rewriters.each do |name, rewriter|
|
167
168
|
rewriter.process_with_sandbox
|
168
|
-
sub_snippets =
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
name: name,
|
174
|
-
description: rewriter.description,
|
175
|
-
sub_snippets: sub_snippets
|
176
|
-
}
|
169
|
+
sub_snippets =
|
170
|
+
rewriter.sub_snippets.map { |sub_snippet|
|
171
|
+
{ group: sub_snippet.group, name: sub_snippet.name }
|
172
|
+
}
|
173
|
+
item = { group: group, name: name, description: rewriter.description, sub_snippets: sub_snippets }
|
177
174
|
item[:ruby_version] = rewriter.ruby_version.version if rewriter.ruby_version
|
178
175
|
item[:gem_spec] = { name: rewriter.gem_spec.name, version: rewriter.gem_spec.version } if rewriter.gem_spec
|
179
176
|
output << item
|
data/lib/synvert/version.rb
CHANGED
data/synvert-ruby.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
spec.post_install_message = 'Please run `synvert-ruby --sync` first to sync snippets remotely.'
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'synvert-core', '>=
|
23
|
+
spec.add_runtime_dependency 'synvert-core', '>= 1.5.0'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.
|
4
|
+
version: 0.19.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: synvert-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.3.7
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: synvert = syntax + convert.
|