synvert 1.1.2 → 1.2.0

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: 1d1c0fbeb63275ae605f0b709a33ee2b0cae147e503d775316f4aac6fb613d98
4
- data.tar.gz: d971eaab50b37a77e7b2949bd65e764a1011424da5ecd7b6cae9f74a1e27c7d0
3
+ metadata.gz: 21d219aaf7db59c0b63d0e4ef6458168e13b76ace165b8990e82efd34097ea2f
4
+ data.tar.gz: 938601896e1bbf2651ac78cf348af5edec9370c39d69e5a2129c47f01745bc33
5
5
  SHA512:
6
- metadata.gz: 0b7f15432a9f4e5da206c155df3129d1b583c23098b506cd34b3ba82f6aab96504671600a2c64510e199ddd67a5a00c060f3b774bd4b24b3eec8335c86128c78
7
- data.tar.gz: 294a5b5ee299a9e7702a4f0b17d883ddc253d5a8978c609f12d2246ae67489ab7442d1536d34961aec586c58e540537f2c9750d2cb01884c781841d4893ceb1a
6
+ metadata.gz: 4fa0c007a3d150cf2508bd30049b8fe527154b5847211dce2fc3f08ebbcd9a26e031162a875390900117c2b6cc03667a67f9dab2a4a3507a58fbdd27c9c6bb8d
7
+ data.tar.gz: 2027f1f6daa49fbd78d3d47667148811b14d182d215f8c47ea41e4c2d50782cea4fa2e8515fb2678991508a48df6cbb606ed41bf1c516dc8ac825ddd2116ce03
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.0 (2022-10-11)
4
+
5
+ * Add `--number-of-workers` option
6
+
7
+ ## 1.1.3 (2022-10-09)
8
+
9
+ * No need to read rewriters before run or test a snippet
10
+ * Reuse `Synvert::Core::Utils.eval_snippet`
11
+ * `rewriter.test` already returns all results
12
+
3
13
  ## 1.1.2 (2022-10-06)
4
14
 
5
15
  * Convert github url to github raw url
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert (1.1.2)
5
- synvert-core (>= 1.9.2)
4
+ synvert (1.2.0)
5
+ synvert-core (>= 1.11.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -38,6 +38,7 @@ GEM
38
38
  erubis
39
39
  node_query (1.7.0)
40
40
  activesupport (< 7.0.0)
41
+ parallel (1.22.1)
41
42
  parser (3.1.2.1)
42
43
  ast (~> 2.4.1)
43
44
  parser_node_ext (0.4.0)
@@ -64,11 +65,12 @@ GEM
64
65
  simplecov-html (~> 0.10.0)
65
66
  simplecov-html (0.10.2)
66
67
  sync (0.5.0)
67
- synvert-core (1.9.2)
68
+ synvert-core (1.11.0)
68
69
  activesupport (< 7.0.0)
69
70
  erubis
70
71
  node_mutation
71
72
  node_query
73
+ parallel
72
74
  parser
73
75
  parser_node_ext
74
76
  term-ansicolor (1.7.1)
data/lib/synvert/cli.rb CHANGED
@@ -43,15 +43,12 @@ module Synvert
43
43
  when 'generate'
44
44
  generate_snippet
45
45
  when 'execute'
46
- read_rewriters
47
46
  execute_snippet(@options[:execute_command])
48
47
  when 'test'
49
- read_rewriters
50
- rewriter = eval_snippet(@options[:snippet_name])
48
+ rewriter = Synvert::Core::Utils.eval_snippet(@options[:snippet_name])
51
49
  test_snippet(rewriter)
52
50
  when 'run'
53
- read_rewriters
54
- rewriter = eval_snippet(@options[:snippet_name])
51
+ rewriter = Synvert::Core::Utils.eval_snippet(@options[:snippet_name])
55
52
  run_snippet(rewriter)
56
53
  else
57
54
  # nothing to do
@@ -64,9 +61,6 @@ module Synvert
64
61
  puts "file #{e.diagnostic.location.source_buffer.name}"
65
62
  puts "line #{e.diagnostic.location.line}"
66
63
  false
67
- rescue Synvert::Core::RewriterNotFound => e
68
- puts e.message
69
- false
70
64
  end
71
65
 
72
66
  private
@@ -126,6 +120,9 @@ module Synvert
126
120
  opts.on '-f', '--format FORMAT', 'output format' do |format|
127
121
  @options[:format] = format
128
122
  end
123
+ opts.on '--number-of-workers NUMBER_OF_WORKERS', 'set the number of workers, if it is greater than 1, it tests snippet in parallel' do |number_of_workers|
124
+ Core::Configuration.number_of_workers = number_of_workers.to_i
125
+ end
129
126
  opts.on '-v', '--version', 'show this version' do
130
127
  puts "#{VERSION} (with synvert-core #{Core::VERSION} and parser #{Parser::VERSION})"
131
128
  exit
@@ -233,22 +230,6 @@ module Synvert
233
230
  end
234
231
  end
235
232
 
236
- # eval snippet by name
237
- # it can eval by explicit snippet name,
238
- # or from local path or http url.
239
- def eval_snippet(snippet_name)
240
- if /^http/.match?(snippet_name)
241
- uri = URI.parse(Utils.format_url(snippet_name))
242
- eval(uri.open.read)
243
- elsif File.exists?(snippet_name)
244
- eval(File.read(snippet_name))
245
- else
246
- require(File.join(default_snippets_home, 'lib', "#{snippet_name}.rb"))
247
- group, name = snippet_name.split('/')
248
- Core::Rewriter.fetch(group, name)
249
- end
250
- end
251
-
252
233
  # eval snippet name by user input
253
234
  def eval_snippet_name_by_input(input)
254
235
  eval(input)
@@ -256,15 +237,16 @@ module Synvert
256
237
 
257
238
  # run a snippet
258
239
  def run_snippet(rewriter)
259
- rewriter.process
260
240
  if plain_output?
261
241
  puts "===== #{rewriter.group}/#{rewriter.name} started ====="
242
+ rewriter.process
262
243
  rewriter.warnings.each do |warning|
263
244
  puts '[Warn] ' + warning.message
264
245
  end
265
246
  puts rewriter.todo if rewriter.todo
266
247
  puts "===== #{rewriter.group}/#{rewriter.name} done ====="
267
248
  elsif json_output?
249
+ rewriter.process
268
250
  output = {
269
251
  affected_files: rewriter.affected_files.union(rewriter.sub_snippets.sum(Set.new, &:affected_files)).to_a,
270
252
  warnings: rewriter.warnings.union(rewriter.sub_snippets.sum([], &:warnings)),
@@ -277,9 +259,6 @@ module Synvert
277
259
  # test a snippet
278
260
  def test_snippet(rewriter)
279
261
  results = rewriter.test
280
- rewriter.sub_snippets.each do |sub_snippet|
281
- results += sub_snippet.test_results
282
- end
283
262
  puts JSON.generate(results)
284
263
  end
285
264
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Synvert
4
- VERSION = '1.1.2'
4
+ VERSION = '1.2.0'
5
5
  end
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', '>= 1.9.2'
23
+ spec.add_runtime_dependency 'synvert-core', '>= 1.11.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: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-06 00:00:00.000000000 Z
11
+ date: 2022-10-11 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: 1.9.2
19
+ version: 1.11.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: 1.9.2
26
+ version: 1.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement