synvert-core 1.21.0 → 1.21.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +5 -5
- data/lib/synvert/core/rewriter/instance.rb +3 -2
- data/lib/synvert/core/rewriter/scope/goto_scope.rb +10 -2
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/instance_spec.rb +1 -0
- data/spec/synvert/core/rewriter/scope/goto_scope_spec.rb +14 -1
- data/synvert-core-ruby.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 915cd8e6315447109e8088653613c14e536228cba9bbd14b7da5470488a186cf
|
4
|
+
data.tar.gz: aac013556d193b8f5948e7b227dcfe7716eb70daa02bc32983b6f60d13804921
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2d6997dc73ec8bbe4b1b96691f457fd9050be0fb1757651931fbe0f522fce2495e070a20d50905f47495c72034e82e00fecc4a35e56b1088e194390e406b3d3
|
7
|
+
data.tar.gz: 44f4c940be6497eeaf54aaa0f6d2688bb0da2319250dc2a6f8ace0756bfcf51f1fdd15ea7e25baa4f899cdc860e746ea9bfe9a669bfb7d39c2aa6c1306048d67
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.21.2 (2023-02-11)
|
4
|
+
|
5
|
+
* Call block multiple times when goto node array
|
6
|
+
* Update `node_mutation` to 1.9.2
|
7
|
+
|
8
|
+
## 1.21.1 (2023-02-10)
|
9
|
+
|
10
|
+
* Add `tab_size` option to `add_leading_spaces`
|
11
|
+
|
3
12
|
## 1.21.0 (2023-02-08)
|
4
13
|
|
5
14
|
* Add `Configuration#tab_width`
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
synvert-core (1.21.
|
4
|
+
synvert-core (1.21.2)
|
5
5
|
activesupport (< 7.0.0)
|
6
6
|
erubis
|
7
|
-
node_mutation (>= 1.9.
|
7
|
+
node_mutation (>= 1.9.2)
|
8
8
|
node_query (>= 1.12.0)
|
9
9
|
parallel
|
10
10
|
parser
|
@@ -50,14 +50,14 @@ GEM
|
|
50
50
|
method_source (1.0.0)
|
51
51
|
minitest (5.17.0)
|
52
52
|
nenv (0.3.0)
|
53
|
-
node_mutation (1.9.
|
53
|
+
node_mutation (1.9.2)
|
54
54
|
erubis
|
55
55
|
node_query (1.12.0)
|
56
56
|
notiffany (0.1.3)
|
57
57
|
nenv (~> 0.1)
|
58
58
|
shellany (~> 0.0)
|
59
59
|
parallel (1.22.1)
|
60
|
-
parser (3.2.
|
60
|
+
parser (3.2.1.0)
|
61
61
|
ast (~> 2.4.1)
|
62
62
|
parser_node_ext (0.10.0)
|
63
63
|
parser
|
@@ -85,7 +85,7 @@ GEM
|
|
85
85
|
thor (1.2.1)
|
86
86
|
tzinfo (2.0.6)
|
87
87
|
concurrent-ruby (~> 1.0)
|
88
|
-
zeitwerk (2.6.
|
88
|
+
zeitwerk (2.6.7)
|
89
89
|
|
90
90
|
PLATFORMS
|
91
91
|
ruby
|
@@ -425,9 +425,10 @@ module Synvert::Core
|
|
425
425
|
|
426
426
|
# Add leading spaces before the str according to Configuration.tab_width.
|
427
427
|
# @param str [String]
|
428
|
+
# @param tab_size [Integer] tab size
|
428
429
|
# @return [String]
|
429
|
-
def add_leading_spaces(str)
|
430
|
-
" " * Configuration.tab_width + str;
|
430
|
+
def add_leading_spaces(str, tab_size: 1)
|
431
|
+
" " * Configuration.tab_width * tab_size + str;
|
431
432
|
end
|
432
433
|
|
433
434
|
private
|
@@ -22,8 +22,16 @@ module Synvert::Core
|
|
22
22
|
@child_node_name.to_s.split('.').each do |child_node_name|
|
23
23
|
child_node = child_node_name.is_a?(Parser::AST::Node) ? child_node_name : child_node.send(child_node_name)
|
24
24
|
end
|
25
|
-
|
26
|
-
|
25
|
+
if child_node.is_a?(Array)
|
26
|
+
child_node.each do |child_child_node|
|
27
|
+
@instance.process_with_other_node child_child_node do
|
28
|
+
@instance.instance_eval(&@block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
else
|
32
|
+
@instance.process_with_other_node child_node do
|
33
|
+
@instance.instance_eval(&@block)
|
34
|
+
end
|
27
35
|
end
|
28
36
|
end
|
29
37
|
end
|
data/lib/synvert/core/version.rb
CHANGED
@@ -10,6 +10,8 @@ module Synvert::Core
|
|
10
10
|
}
|
11
11
|
let(:source) { <<~EOS }
|
12
12
|
Factory.define :user do |user|
|
13
|
+
user.first_name 'First'
|
14
|
+
user.last_name 'Last'
|
13
15
|
end
|
14
16
|
EOS
|
15
17
|
|
@@ -17,7 +19,7 @@ module Synvert::Core
|
|
17
19
|
before { instance.current_node = node }
|
18
20
|
|
19
21
|
describe '#process' do
|
20
|
-
it '
|
22
|
+
it 'calls block with child node' do
|
21
23
|
run = false
|
22
24
|
type_in_scope = nil
|
23
25
|
scope =
|
@@ -30,6 +32,17 @@ module Synvert::Core
|
|
30
32
|
expect(type_in_scope).to eq :const
|
31
33
|
expect(instance.current_node.type).to eq :block
|
32
34
|
end
|
35
|
+
|
36
|
+
it 'calls block multiple times with blok body' do
|
37
|
+
count = 0
|
38
|
+
scope =
|
39
|
+
Rewriter::GotoScope.new instance, 'body' do
|
40
|
+
count += 1
|
41
|
+
end
|
42
|
+
scope.process
|
43
|
+
expect(count).to eq 2
|
44
|
+
expect(instance.current_node.type).to eq :block
|
45
|
+
end
|
33
46
|
end
|
34
47
|
end
|
35
48
|
end
|
data/synvert-core-ruby.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "activesupport", "< 7.0.0"
|
23
23
|
spec.add_runtime_dependency "erubis"
|
24
24
|
spec.add_runtime_dependency "node_query", ">= 1.12.0"
|
25
|
-
spec.add_runtime_dependency "node_mutation", ">= 1.9.
|
25
|
+
spec.add_runtime_dependency "node_mutation", ">= 1.9.2"
|
26
26
|
spec.add_runtime_dependency "parser"
|
27
27
|
spec.add_runtime_dependency "parser_node_ext", ">= 0.9.0"
|
28
28
|
spec.add_runtime_dependency "parallel"
|
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.21.
|
4
|
+
version: 1.21.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: 2023-02-
|
11
|
+
date: 2023-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.9.
|
61
|
+
version: 1.9.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.9.
|
68
|
+
version: 1.9.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: parser
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|