synvert-core 1.28.5 → 1.29.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +6 -6
- data/README.md +1 -0
- data/lib/synvert/core/rewriter/instance.rb +11 -3
- data/lib/synvert/core/rewriter/scope/within_scope.rb +1 -3
- data/lib/synvert/core/rewriter.rb +8 -7
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/instance_spec.rb +7 -0
- data/spec/synvert/core/rewriter/scope/within_scope_spec.rb +1 -3
- data/synvert-core-ruby.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2aa0e52fd9c971abea870748a4b530313e366ec9be7741ea44ed7eb7cc9c13f
|
4
|
+
data.tar.gz: caa5bd171a6409ef4a6c1f887faf918063124f8cd7f06dfae88dd8d425c8282a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58d81bfed67b382a4cc656a350988c0144314252d1199213a44e85dc9359aa978287d2b46d43956bcf6f42e5ca7e900890c47ed1cf3b63e602517f3979017461
|
7
|
+
data.tar.gz: 255a09816a19e21dce776b62e786da8a6acb78e41460b833a5671ff2d86757615b51460ed4a6cda60867bc74123e42556e6da4831f6a6ffff6e3d87f2ec9c3a8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.29.1 (2023-09-29)
|
4
|
+
|
5
|
+
* Update `node-query` to 1.13.12
|
6
|
+
|
7
|
+
## 1.29.0 (2023-09-26)
|
8
|
+
|
9
|
+
* Update `node_mutation` to 1.21.0
|
10
|
+
* Revert "Combine actions within scope"
|
11
|
+
* Add `group` dsl
|
12
|
+
|
3
13
|
## 1.28.5 (2023-09-25)
|
4
14
|
|
5
15
|
* Update `node-query` to 1.13.11
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
synvert-core (1.
|
4
|
+
synvert-core (1.29.1)
|
5
5
|
activesupport (< 7.0.0)
|
6
|
-
node_mutation (>= 1.
|
7
|
-
node_query (>= 1.13.
|
6
|
+
node_mutation (>= 1.21.0)
|
7
|
+
node_query (>= 1.13.12)
|
8
8
|
parallel
|
9
9
|
parser
|
10
10
|
parser_node_ext (>= 1.2.0)
|
@@ -50,8 +50,8 @@ GEM
|
|
50
50
|
method_source (1.0.0)
|
51
51
|
minitest (5.20.0)
|
52
52
|
nenv (0.3.0)
|
53
|
-
node_mutation (1.
|
54
|
-
node_query (1.13.
|
53
|
+
node_mutation (1.21.0)
|
54
|
+
node_query (1.13.12)
|
55
55
|
notiffany (0.1.3)
|
56
56
|
nenv (~> 0.1)
|
57
57
|
shellany (~> 0.0)
|
@@ -91,7 +91,7 @@ GEM
|
|
91
91
|
thor (1.2.1)
|
92
92
|
tzinfo (2.0.6)
|
93
93
|
concurrent-ruby (~> 1.0)
|
94
|
-
zeitwerk (2.6.
|
94
|
+
zeitwerk (2.6.12)
|
95
95
|
|
96
96
|
PLATFORMS
|
97
97
|
ruby
|
data/README.md
CHANGED
@@ -101,6 +101,7 @@ Actions:
|
|
101
101
|
* [warn](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#warn-instance_method) - warn message
|
102
102
|
* [replace_erb_stmt_with_expr](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#replace_erb_stmt_with_expr-instance_method) - replace erb stmt code to expr code
|
103
103
|
* [noop](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#noop-instance_method) - no operation
|
104
|
+
* [group](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#group-instance_method) - group actions
|
104
105
|
* [add_action](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#add_action-instance_method) - add custom action
|
105
106
|
|
106
107
|
Others:
|
@@ -37,9 +37,7 @@ module Synvert::Core
|
|
37
37
|
# @return current ast node
|
38
38
|
# @!attribute [r] mutation_adapter
|
39
39
|
# @return NodeMutation Adapter
|
40
|
-
|
41
|
-
# @return current node mutation
|
42
|
-
attr_reader :file_path, :mutation_adapter, :current_mutation
|
40
|
+
attr_reader :file_path, :current_node, :mutation_adapter
|
43
41
|
attr_accessor :current_node
|
44
42
|
|
45
43
|
# Process the instance.
|
@@ -409,6 +407,16 @@ module Synvert::Core
|
|
409
407
|
@current_mutation.noop(@current_node)
|
410
408
|
end
|
411
409
|
|
410
|
+
# Group actions.
|
411
|
+
# @example
|
412
|
+
# group do
|
413
|
+
# delete :message, :dot
|
414
|
+
# replace 'receiver.caller.message', with: 'flat_map'
|
415
|
+
# end
|
416
|
+
def group(&block)
|
417
|
+
@current_mutation.group(&block)
|
418
|
+
end
|
419
|
+
|
412
420
|
# Add a custom action.
|
413
421
|
# @example
|
414
422
|
# remover_action = NodeMutation::RemoveAction.new(node)
|
@@ -29,9 +29,7 @@ module Synvert::Core
|
|
29
29
|
@instance.process_with_node current_node do
|
30
30
|
matching_nodes.each do |matching_node|
|
31
31
|
@instance.process_with_node matching_node do
|
32
|
-
@instance.
|
33
|
-
@instance.instance_eval(&@block)
|
34
|
-
end
|
32
|
+
@instance.instance_eval(&@block)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
@@ -156,14 +156,15 @@ module Synvert::Core
|
|
156
156
|
@test_results.map do |filename, test_results|
|
157
157
|
new_actions = test_results.map(&:actions).flatten.sort_by(&:end)
|
158
158
|
last_start = -1
|
159
|
-
conflicted =
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
159
|
+
conflicted =
|
160
|
+
new_actions.any? do |action|
|
161
|
+
if last_start > action.end
|
162
|
+
true
|
163
|
+
else
|
164
|
+
last_start = action.start
|
165
|
+
false
|
166
|
+
end
|
165
167
|
end
|
166
|
-
end
|
167
168
|
result = NodeMutation::Result.new(affected: true, conflicted: conflicted)
|
168
169
|
result.actions = new_actions
|
169
170
|
result.file_path = filename
|
data/lib/synvert/core/version.rb
CHANGED
@@ -262,6 +262,13 @@ module Synvert::Core
|
|
262
262
|
instance.noop
|
263
263
|
end
|
264
264
|
|
265
|
+
it 'parses group' do
|
266
|
+
instance.instance_variable_set(:@current_mutation, double)
|
267
|
+
instance.current_node = double
|
268
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:group)
|
269
|
+
instance.group {}
|
270
|
+
end
|
271
|
+
|
265
272
|
it 'parses warn' do
|
266
273
|
expect(Rewriter::Warning).to receive(:new).with(instance, 'foobar')
|
267
274
|
instance.warn 'foobar'
|
@@ -6,9 +6,7 @@ module Synvert::Core
|
|
6
6
|
describe Rewriter::WithinScope do
|
7
7
|
let(:instance) {
|
8
8
|
rewriter = Rewriter.new('foo', 'bar')
|
9
|
-
Rewriter::Instance.new(rewriter, 'file pattern')
|
10
|
-
instance.instance_variable_set(:@current_mutation, NodeMutation.new('source'))
|
11
|
-
end
|
9
|
+
Rewriter::Instance.new(rewriter, 'file pattern')
|
12
10
|
}
|
13
11
|
let(:source) { <<~EOS }
|
14
12
|
describe User do
|
data/synvert-core-ruby.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_runtime_dependency "activesupport", "< 7.0.0"
|
23
|
-
spec.add_runtime_dependency "node_query", ">= 1.13.
|
24
|
-
spec.add_runtime_dependency "node_mutation", ">= 1.
|
23
|
+
spec.add_runtime_dependency "node_query", ">= 1.13.12"
|
24
|
+
spec.add_runtime_dependency "node_mutation", ">= 1.21.0"
|
25
25
|
spec.add_runtime_dependency "parser"
|
26
26
|
spec.add_runtime_dependency "parser_node_ext", ">= 1.2.0"
|
27
27
|
spec.add_runtime_dependency "syntax_tree"
|
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.
|
4
|
+
version: 1.29.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: 2023-09-
|
11
|
+
date: 2023-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.13.
|
33
|
+
version: 1.13.12
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.13.
|
40
|
+
version: 1.13.12
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: node_mutation
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.21.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.21.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: parser
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|