synvert 0.18.3 → 0.19.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 030b18c7d1eecde7a29eb47590f7104937467693f1ab3475016c0cccbc8ca3b2
4
- data.tar.gz: 73839b855d8bbb9ded39cb99dce1645a109516a5e4c0cb229aa26f3076ce9ab5
3
+ metadata.gz: b4168dd627a46add1e09b6faa57d839ecddcbed0ab39de07f647175513e63aff
4
+ data.tar.gz: 66f24286910b065ffa404e312e09b843cfa311bf5637345819f9062af51d56e2
5
5
  SHA512:
6
- metadata.gz: 5939468037e810437a1910ceb02b91e65f4d3e0bd7bc1399e9f79fa9b9fd93377ae60ecde9067446c75ed12be264e6007d8980504d522be6b68807f23ff83a31
7
- data.tar.gz: 42a3021aa5229deac6fef388471fd5a8d21b789dde17b7cae6e479198f07adbf7b5db1b290b9c6f8282b24db03f61ac8211df8bd48db5e6b5dd27f535253f13e
6
+ metadata.gz: 4e18d9c4180772fe62b3ade9d834abf757e51821113804d7ec4c1155b53ef613d4023ee5663b022c42c025c3da33cfe1b24b770a687de7258f81e1910be180a2
7
+ data.tar.gz: 368c327ff1f89074939402e283191f33f2b1106a3a2cdcff7e9851323e80ae51f9c5a85cf451b01a30ab00327ab8f2e5bba71f43fcab3b28392e3741102f4b41
@@ -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,16 +1,18 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 0.18.3 (2021-08-22)
3
+ ## 0.19.2 (2021-12-15)
4
4
 
5
- * Update synvert-snippets url
6
- * Deprecate synvert, use synvert-ruby instead
5
+ * List sub_snippets group and name
7
6
 
8
- ## 0.18.2 (2021-08-12)
7
+ ## 0.19.1 (2021-10-23)
9
8
 
10
- * Require `fileutils`
9
+ * Make URI.open work in ruby 2.4
11
10
 
12
- ## 0.18.1 (2021-07-23)
11
+ ## 0.19.0 (2021-09-10)
13
12
 
13
+ * Add `--show-run-process` option
14
+ * Deprecate `synvert`, use `synvert-ruby` instead
15
+ * Update `synvert-snippets` url
14
16
  * Fix `affected_files` is Set
15
17
 
16
18
  ## 0.18.0 (2021-07-14)
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Synvert
2
2
 
3
- <img src="https://xinminlabs.github.io/synvert/img/logo_96.png" alt="logo" width="32" height="32" />
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.github.io/synvert/][3]
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.github.io/synvert/
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/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 '-g', '--generate NEW_SNIPPET_NAME', 'generate a new snippet' do |name|
106
- @options[:command] = 'generate'
107
- @options[:snippet_name] = name
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
@@ -163,11 +165,14 @@ module Synvert
163
165
  Core::Rewriter.availables.each do |group, rewriters|
164
166
  rewriters.each do |name, rewriter|
165
167
  rewriter.process_with_sandbox
168
+ sub_snippets = rewriter.sub_snippets.map { |sub_snippet|
169
+ { group: sub_snippet.group, name: sub_snippet.name }
170
+ }
166
171
  item = {
167
172
  group: group,
168
173
  name: name,
169
174
  description: rewriter.description,
170
- sub_snippets: rewriter.sub_snippets.map(&:name)
175
+ sub_snippets: sub_snippets
171
176
  }
172
177
  item[:ruby_version] = rewriter.ruby_version.version if rewriter.ruby_version
173
178
  item[:gem_spec] = { name: rewriter.gem_spec.name, version: rewriter.gem_spec.version } if rewriter.gem_spec
@@ -185,7 +190,7 @@ module Synvert
185
190
  return puts 'To open a synvert snippet, set $EDITOR or $SYNVERT_EDITOR' unless editor
186
191
 
187
192
  path = File.expand_path(File.join(default_snippets_home, "lib/#{@options[:snippet_name]}.rb"))
188
- if File.exist? path
193
+ if File.exist?(path)
189
194
  system editor, path
190
195
  else
191
196
  puts "Can't run #{editor} #{path}"
@@ -8,7 +8,7 @@ module Synvert
8
8
  # Manage synvert snippets.
9
9
  class Snippet
10
10
  def self.fetch_core_version
11
- content = URI.open('https://rubygems.org/api/v1/versions/synvert-core.json').read
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
 
@@ -25,5 +25,13 @@ module Synvert
25
25
  Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets-ruby.git #{@snippets_path}")
26
26
  end
27
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)
34
+ end
35
+ end
28
36
  end
29
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Synvert
4
- VERSION = '0.18.3'
4
+ VERSION = '0.19.2'
5
5
  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.53.0'
23
+ spec.add_runtime_dependency 'synvert-core', '>= 0.61.1'
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.18.3
4
+ version: 0.19.2
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-08-22 00:00:00.000000000 Z
11
+ date: 2021-12-15 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.53.0
19
+ version: 0.61.1
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.53.0
26
+ version: 0.61.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -105,12 +105,12 @@ files:
105
105
  - lib/synvert/version.rb
106
106
  - spec/spec_helper.rb
107
107
  - spec/synvert/snippet_spec.rb
108
- - synvert.gemspec
109
- homepage: https://github.com/xinminlabs/synvert
108
+ - synvert-ruby.gemspec
109
+ homepage: https://github.com/xinminlabs/synvert-ruby
110
110
  licenses:
111
111
  - MIT
112
112
  metadata: {}
113
- 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.
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib