synvert-core 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 966c0db8262c57bb94be47d44c5638c9c9607728da335b4bde9d39c49f7bc665
4
- data.tar.gz: e2be9da04e58da3b236d03006883778f6e202d9bbb5a8fa922dd6339117a6a2a
3
+ metadata.gz: 0663ba61695ae5b47f27e9a23f1edbfe31d3746f9b3e02a79315a827fae6f36c
4
+ data.tar.gz: 8199c6c8a122555bfbf0df0ef79f6bd96ade0cdfe472d81d6abe4cccde3b6c59
5
5
  SHA512:
6
- metadata.gz: 1e1f6a8a25817ebe46c03bdbf6e7982f559c426bf5537c2ae28549215ad77a03c45768af6b3f74ba84e34105c6d1e8c9cbb365cb1f431220b59028678c373dcd
7
- data.tar.gz: 44f57f854c537825acb57217b216294f226df391b1eb185fd1558f463084a91ad9fcc296f54eba05c5b66e1d995a40c897d267fff662ff5bf85472d83d993be1
6
+ metadata.gz: 3609b9bdb845681c9dd71d9d0eca4985d43203ce28fb1e874e9538322f8205995d77f5b8c2b43fb11caf698a69772c3e7bdd5114a709e4513313339870576a5e
7
+ data.tar.gz: 952578268a2c8cba6dcd2883141fe5977917594ea01b76e51e93032fc71225c813b9021ec1852c3a93d76f6438f30f9975ac47b36c5da3d7c5805fa15763fa9e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.11.0 (2022-10-11)
4
+
5
+ * Add `Configuration.number_of_workers`
6
+ * Test rewriter in parallel
7
+
3
8
  ## 1.10.1 (2022-10-09)
4
9
 
5
10
  * Do not reset `@options`
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.10.1)
4
+ synvert-core (1.11.0)
5
5
  activesupport (< 7.0.0)
6
6
  erubis
7
7
  node_mutation
8
8
  node_query
9
+ parallel
9
10
  parser
10
11
  parser_node_ext
11
12
 
@@ -57,6 +58,7 @@ GEM
57
58
  notiffany (0.1.3)
58
59
  nenv (~> 0.1)
59
60
  shellany (~> 0.0)
61
+ parallel (1.22.1)
60
62
  parser (3.1.2.1)
61
63
  ast (~> 2.4.1)
62
64
  parser_node_ext (0.4.0)
@@ -8,7 +8,8 @@ module Synvert::Core
8
8
  # @!attribute [w] skip_paths
9
9
  # @!attribute [w] only_paths
10
10
  # @!attribute [w] show_run_process
11
- attr_writer :root_path, :skip_paths, :only_paths, :show_run_process
11
+ # @!attribute [w] number_of_workers
12
+ attr_writer :root_path, :skip_paths, :only_paths, :show_run_process, :number_of_workers
12
13
 
13
14
  # Get the path.
14
15
  #
@@ -37,6 +38,13 @@ module Synvert::Core
37
38
  def show_run_process
38
39
  @show_run_process || false
39
40
  end
41
+
42
+ # Number of workers
43
+ #
44
+ # @return [Integer] default is 1
45
+ def number_of_workers
46
+ @number_of_workers || 1
47
+ end
40
48
  end
41
49
  end
42
50
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'parallel'
2
3
 
3
4
  module Synvert::Core
4
5
  # Instance is an execution unit, it finds specified ast nodes,
@@ -41,8 +42,14 @@ module Synvert::Core
41
42
  # It finds specified files, for each file, it executes the block code, tests the original code,
42
43
  # then returns the actions.
43
44
  def test
44
- get_file_paths.map do |file_path|
45
- test_file(file_path)
45
+ if Configuration.number_of_workers > 1
46
+ Parallel.map(get_file_paths, in_processes: Configuration.number_of_workers) do |file_path|
47
+ test_file(file_path)
48
+ end
49
+ else
50
+ get_file_paths.map do |file_path|
51
+ test_file(file_path)
52
+ end
46
53
  end
47
54
  end
48
55
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.10.1'
5
+ VERSION = '1.11.0'
6
6
  end
7
7
  end
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency "node_mutation"
26
26
  spec.add_runtime_dependency "parser"
27
27
  spec.add_runtime_dependency "parser_node_ext"
28
+ spec.add_runtime_dependency "parallel"
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.11.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-09 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: activesupport
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: parallel
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: convert ruby code to better syntax automatically.
98
112
  email:
99
113
  - flyerhzm@gmail.com