synvert 0.18.2 → 0.19.1
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 +2 -2
- data/CHANGELOG.md +6 -3
- data/README.md +10 -22
- data/bin/synvert +2 -0
- data/bin/synvert-ruby +8 -0
- data/lib/synvert/cli.rb +18 -16
- data/lib/synvert/snippet.rb +10 -2
- data/lib/synvert/version.rb +1 -1
- data/spec/synvert/snippet_spec.rb +1 -1
- data/{synvert.gemspec → synvert-ruby.gemspec} +3 -3
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62c51dd8a7a0d58c47644593a0a85a14ab201c8a842187f7fc1bb0b9c185c798
|
4
|
+
data.tar.gz: 72dc55fe685d1149ab875eb04a9dfd81d3f199d2930de46589a4e4d9b0d9173f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2a3eee39999e331d9d3f24b6fe0c6fc1c512cd9ace5d03a23c111c29a212dad3f80f325d0079fff7c0d302d9ad8e077f546ace95e5dfed53d00feef934504d1
|
7
|
+
data.tar.gz: 40f6e3423153314c72ae434e6abf34640d08313909d2389f9355e410d02ddf312bff4a51d602ac7ea0b5eed514c6b8a0cc515a9c973911c723256a2d49128a06
|
data/.github/workflows/main.yml
CHANGED
@@ -19,7 +19,7 @@ jobs:
|
|
19
19
|
runs-on: ubuntu-latest
|
20
20
|
strategy:
|
21
21
|
matrix:
|
22
|
-
ruby-version: ['2.5', '2.6', '2.7', '3.0']
|
22
|
+
ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0']
|
23
23
|
|
24
24
|
steps:
|
25
25
|
- uses: actions/checkout@v2
|
@@ -29,4 +29,4 @@ jobs:
|
|
29
29
|
ruby-version: ${{ matrix.ruby-version }}
|
30
30
|
bundler-cache: true
|
31
31
|
- name: Run tests
|
32
|
-
run: bundle exec rake
|
32
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 0.19.1 (2021-10-23)
|
4
4
|
|
5
|
-
*
|
5
|
+
* Make URI.open work in ruby 2.4
|
6
6
|
|
7
|
-
## 0.
|
7
|
+
## 0.19.0 (2021-09-10)
|
8
8
|
|
9
|
+
* Add `--show-run-process` option
|
10
|
+
* Deprecate `synvert`, use `synvert-ruby` instead
|
11
|
+
* Update `synvert-snippets` url
|
9
12
|
* Fix `affected_files` is Set
|
10
13
|
|
11
14
|
## 0.18.0 (2021-07-14)
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Synvert
|
2
2
|
|
3
|
-
<img src="https://xinminlabs.
|
3
|
+
<img src="https://synvert.xinminlabs.com/img/logo_96.png" alt="logo" width="32" height="32" />
|
4
4
|
|
5
|
-
![Main workflow](https://github.com/xinminlabs/synvert/actions/workflows/main.yml/badge.svg)
|
5
|
+
![Main workflow](https://github.com/xinminlabs/synvert-ruby/actions/workflows/main.yml/badge.svg)
|
6
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
|
|
@@ -27,14 +27,14 @@ $ gem install synvert
|
|
27
27
|
then run
|
28
28
|
|
29
29
|
```
|
30
|
-
$ synvert --sync
|
30
|
+
$ synvert-ruby --sync
|
31
31
|
```
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
35
|
```
|
36
|
-
$ synvert -h
|
37
|
-
Usage: synvert [project_path]
|
36
|
+
$ synvert-ruby -h
|
37
|
+
Usage: synvert-ruby [project_path]
|
38
38
|
-d, --load SNIPPET_PATHS load custom snippets, snippet paths can be local file path or remote http url
|
39
39
|
-l, --list list all available snippets
|
40
40
|
-q, --query QUERY query specified snippets
|
@@ -48,24 +48,12 @@ Usage: synvert [project_path]
|
|
48
48
|
e.g.
|
49
49
|
|
50
50
|
```
|
51
|
-
$ synvert -r factory_girl/use_short_syntax,rails/upgrade_3_2_to_4_0 ~/Sites/railsbp/rails-bestpractices.com
|
52
|
-
```
|
53
|
-
|
54
|
-
## Docker
|
55
|
-
|
56
|
-
We have a docker image to run synvert
|
57
|
-
|
58
|
-
```
|
59
|
-
$ docker pull xinminlabs/awesomecode-synvert
|
60
|
-
|
61
|
-
$ docker run xinminlabs/awesomecode-synvert synvert --list
|
62
|
-
|
63
|
-
$ docker run -v <your project path>:/app xinminlabs/awesomecode-synvert synvert --run default/check_syntax /app
|
51
|
+
$ synvert-ruby -r factory_girl/use_short_syntax,rails/upgrade_3_2_to_4_0 ~/Sites/railsbp/rails-bestpractices.com
|
64
52
|
```
|
65
53
|
|
66
54
|
## Documentation
|
67
55
|
|
68
|
-
[https://xinminlabs.
|
56
|
+
[https://synvert.xinminlabs.com][3]
|
69
57
|
|
70
58
|
## Contributing
|
71
59
|
|
@@ -75,6 +63,6 @@ $ docker run -v <your project path>:/app xinminlabs/awesomecode-synvert synvert
|
|
75
63
|
4. Push to the branch (`git push origin my-new-feature`)
|
76
64
|
5. Create new Pull Request
|
77
65
|
|
78
|
-
[1]: https://github.com/xinminlabs/synvert-core/
|
79
|
-
[2]: https://github.com/xinminlabs/synvert-snippets/
|
80
|
-
[3]: https://xinminlabs.
|
66
|
+
[1]: https://github.com/xinminlabs/synvert-core-ruby/
|
67
|
+
[2]: https://github.com/xinminlabs/synvert-snippets-ruby/
|
68
|
+
[3]: https://synvert.xinminlabs.com
|
data/bin/synvert
CHANGED
data/bin/synvert-ruby
ADDED
data/lib/synvert/cli.rb
CHANGED
@@ -34,7 +34,6 @@ module Synvert
|
|
34
34
|
load_rewriters
|
35
35
|
query_available_rewriters
|
36
36
|
when 'show'
|
37
|
-
load_rewriters
|
38
37
|
show_rewriter
|
39
38
|
when 'sync'
|
40
39
|
sync_snippets
|
@@ -66,7 +65,7 @@ module Synvert
|
|
66
65
|
def run_option_parser(args)
|
67
66
|
optparse =
|
68
67
|
OptionParser.new do |opts|
|
69
|
-
opts.banner = 'Usage: synvert [project_path]'
|
68
|
+
opts.banner = 'Usage: synvert-ruby [project_path]'
|
70
69
|
opts.on '-d',
|
71
70
|
'--load SNIPPET_PATHS',
|
72
71
|
'load custom snippets, snippet paths can be local file path or remote http url' do |snippet_paths|
|
@@ -75,24 +74,24 @@ module Synvert
|
|
75
74
|
opts.on '-l', '--list', 'list all available snippets' do
|
76
75
|
@options[:command] = 'list'
|
77
76
|
end
|
78
|
-
opts.on '-o', '--open SNIPPET_NAME', 'Open a snippet' do |snippet_name|
|
79
|
-
@options[:command] = 'open'
|
80
|
-
@options[:snippet_name] = snippet_name
|
81
|
-
end
|
82
77
|
opts.on '-q', '--query QUERY', 'query specified snippets' do |query|
|
83
78
|
@options[:command] = 'query'
|
84
79
|
@options[:query] = query
|
85
80
|
end
|
86
|
-
opts.on '--skip FILE_PATTERNS',
|
87
|
-
'skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb' do |file_patterns|
|
88
|
-
@options[:skip_file_patterns] = file_patterns.split(',')
|
89
|
-
end
|
90
81
|
opts.on '-s',
|
91
82
|
'--show SNIPPET_NAME',
|
92
83
|
'show specified snippet description, SNIPPET_NAME is combined by group and name, e.g. ruby/new_hash_syntax' do |snippet_name|
|
93
84
|
@options[:command] = 'show'
|
94
85
|
@options[:snippet_name] = snippet_name
|
95
86
|
end
|
87
|
+
opts.on '-o', '--open SNIPPET_NAME', 'Open a snippet' do |snippet_name|
|
88
|
+
@options[:command] = 'open'
|
89
|
+
@options[:snippet_name] = snippet_name
|
90
|
+
end
|
91
|
+
opts.on '-g', '--generate NEW_SNIPPET_NAME', 'generate a new snippet' do |name|
|
92
|
+
@options[:command] = 'generate'
|
93
|
+
@options[:snippet_name] = name
|
94
|
+
end
|
96
95
|
opts.on '--sync', 'sync snippets' do
|
97
96
|
@options[:command] = 'sync'
|
98
97
|
end
|
@@ -102,9 +101,12 @@ module Synvert
|
|
102
101
|
opts.on '-r', '--run SNIPPET_NAME', 'run specified snippet, e.g. ruby/new_hash_syntax' do |snippet_name|
|
103
102
|
@options[:snippet_name] = snippet_name
|
104
103
|
end
|
105
|
-
opts.on '-
|
106
|
-
|
107
|
-
|
104
|
+
opts.on '--show-run-process', 'show processing files when running a snippet' do
|
105
|
+
Core::Configuration.show_run_process = true
|
106
|
+
end
|
107
|
+
opts.on '--skip FILE_PATTERNS',
|
108
|
+
'skip specified files or directories, separated by comma, e.g. app/models/post.rb,vendor/plugins/**/*.rb' do |file_patterns|
|
109
|
+
@options[:skip_file_patterns] = file_patterns.split(',')
|
108
110
|
end
|
109
111
|
opts.on '-f', '--format FORMAT', 'output format' do |format|
|
110
112
|
@options[:format] = format
|
@@ -146,7 +148,7 @@ module Synvert
|
|
146
148
|
# List and print all available rewriters.
|
147
149
|
def list_available_rewriters
|
148
150
|
if Core::Rewriter.availables.empty?
|
149
|
-
puts 'There is no snippet under ~/.synvert, please run `synvert --sync` to fetch snippets.'
|
151
|
+
puts 'There is no snippet under ~/.synvert-ruby, please run `synvert-ruby --sync` to fetch snippets.'
|
150
152
|
return
|
151
153
|
end
|
152
154
|
|
@@ -185,7 +187,7 @@ module Synvert
|
|
185
187
|
return puts 'To open a synvert snippet, set $EDITOR or $SYNVERT_EDITOR' unless editor
|
186
188
|
|
187
189
|
path = File.expand_path(File.join(default_snippets_home, "lib/#{@options[:snippet_name]}.rb"))
|
188
|
-
if File.exist?
|
190
|
+
if File.exist?(path)
|
189
191
|
system editor, path
|
190
192
|
else
|
191
193
|
puts "Can't run #{editor} #{path}"
|
@@ -326,7 +328,7 @@ module Synvert
|
|
326
328
|
end
|
327
329
|
|
328
330
|
def default_snippets_home
|
329
|
-
ENV['SYNVERT_SNIPPETS_HOME'] || File.join(ENV['HOME'], '.synvert')
|
331
|
+
ENV['SYNVERT_SNIPPETS_HOME'] || File.join(ENV['HOME'], '.synvert-ruby')
|
330
332
|
end
|
331
333
|
|
332
334
|
def plain_output?
|
data/lib/synvert/snippet.rb
CHANGED
@@ -8,7 +8,7 @@ module Synvert
|
|
8
8
|
# Manage synvert snippets.
|
9
9
|
class Snippet
|
10
10
|
def self.fetch_core_version
|
11
|
-
content =
|
11
|
+
content = uri_open('https://rubygems.org/api/v1/versions/synvert-core.json').read
|
12
12
|
JSON.parse(content).first['number']
|
13
13
|
end
|
14
14
|
|
@@ -22,7 +22,15 @@ module Synvert
|
|
22
22
|
FileUtils.cd @snippets_path
|
23
23
|
Kernel.system('git checkout .; git pull --rebase')
|
24
24
|
else
|
25
|
-
Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets.git #{@snippets_path}")
|
25
|
+
Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets-ruby.git #{@snippets_path}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.uri_open(url)
|
30
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
|
31
|
+
URI.open(url)
|
32
|
+
else
|
33
|
+
open(url)
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
data/lib/synvert/version.rb
CHANGED
@@ -20,7 +20,7 @@ module Synvert
|
|
20
20
|
describe 'sync' do
|
21
21
|
it 'git clones snippets' do
|
22
22
|
expect(Kernel).to receive(:system).with(
|
23
|
-
"git clone https://github.com/xinminlabs/synvert-snippets.git #{snippets_path}"
|
23
|
+
"git clone https://github.com/xinminlabs/synvert-snippets-ruby.git #{snippets_path}"
|
24
24
|
)
|
25
25
|
snippet.sync
|
26
26
|
end
|
@@ -11,16 +11,16 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['flyerhzm@gmail.com']
|
12
12
|
spec.description = 'synvert is used to convert ruby code to better syntax.'
|
13
13
|
spec.summary = 'synvert = syntax + convert.'
|
14
|
-
spec.homepage = 'https://github.com/xinminlabs/synvert'
|
14
|
+
spec.homepage = 'https://github.com/xinminlabs/synvert-ruby'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files`.split($/)
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
|
-
spec.post_install_message = 'Please run `synvert --sync` first to sync snippets remotely.'
|
21
|
+
spec.post_install_message = 'Please run `synvert-ruby --sync` first to sync snippets remotely.'
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'synvert-core', '>= 0.
|
23
|
+
spec.add_runtime_dependency 'synvert-core', '>= 0.58.2'
|
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.
|
4
|
+
version: 0.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-22 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: 0.
|
19
|
+
version: 0.58.2
|
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: 0.
|
26
|
+
version: 0.58.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,6 +85,7 @@ email:
|
|
85
85
|
- flyerhzm@gmail.com
|
86
86
|
executables:
|
87
87
|
- synvert
|
88
|
+
- synvert-ruby
|
88
89
|
extensions: []
|
89
90
|
extra_rdoc_files: []
|
90
91
|
files:
|
@@ -97,18 +98,19 @@ files:
|
|
97
98
|
- README.md
|
98
99
|
- Rakefile
|
99
100
|
- bin/synvert
|
101
|
+
- bin/synvert-ruby
|
100
102
|
- lib/synvert.rb
|
101
103
|
- lib/synvert/cli.rb
|
102
104
|
- lib/synvert/snippet.rb
|
103
105
|
- lib/synvert/version.rb
|
104
106
|
- spec/spec_helper.rb
|
105
107
|
- spec/synvert/snippet_spec.rb
|
106
|
-
- synvert.gemspec
|
107
|
-
homepage: https://github.com/xinminlabs/synvert
|
108
|
+
- synvert-ruby.gemspec
|
109
|
+
homepage: https://github.com/xinminlabs/synvert-ruby
|
108
110
|
licenses:
|
109
111
|
- MIT
|
110
112
|
metadata: {}
|
111
|
-
post_install_message: Please run `synvert --sync` first to sync snippets remotely.
|
113
|
+
post_install_message: Please run `synvert-ruby --sync` first to sync snippets remotely.
|
112
114
|
rdoc_options: []
|
113
115
|
require_paths:
|
114
116
|
- lib
|