synvert-core 1.16.0 → 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +12 -14
- data/README.md +39 -31
- data/lib/synvert/core/rewriter/instance.rb +10 -11
- data/lib/synvert/core/rewriter.rb +0 -22
- data/lib/synvert/core/version.rb +1 -1
- data/lib/synvert/core.rb +1 -0
- data/spec/synvert/core/rewriter/instance_spec.rb +20 -15
- data/spec/synvert/core/rewriter_spec.rb +0 -9
- data/synvert-core-ruby.gemspec +3 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32daaff5e515783785e74b94839328eb08fc1a0c48e6bae047079f0575bba411
|
4
|
+
data.tar.gz: fde8c7b9081f4a32e6f63e9ee9e6ced1878debf41541f822da788e26b756233f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8608a8c3576c5ce5f778c8547a74dfefa99ff166b0137a758972fa910cf7ffa9a7ed4642b8724c6789cf8b203cccd06315ee956451053c577c54899a299405dd
|
7
|
+
data.tar.gz: d400c921693d29c5ffded99b0874514724f29604e974aee1c69fb551c0f2cf25b09b3230bcb816fed6b1e9903965d01feb2d9912fe4fcd0d4bc86cf3df03f9f8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.18.0 (2023-02-01)
|
4
|
+
|
5
|
+
* Remove `todo` dsl
|
6
|
+
* Update `parser_node_ext` to 0.9.0
|
7
|
+
|
8
|
+
## 1.17.0 (2023-01-21)
|
9
|
+
|
10
|
+
* Add `add_action` dsl
|
11
|
+
* Remove `any_value`
|
12
|
+
* No access to `Instance#current_mutation`
|
13
|
+
|
3
14
|
## 1.16.0 (2022-12-29)
|
4
15
|
|
5
16
|
* Add `Instance#query_adapter` and `Instance#mutation_adapter`
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
synvert-core (1.
|
4
|
+
synvert-core (1.18.0)
|
5
5
|
activesupport (< 7.0.0)
|
6
6
|
erubis
|
7
|
-
node_mutation (>= 1.8.
|
8
|
-
node_query (>= 1.
|
7
|
+
node_mutation (>= 1.8.2)
|
8
|
+
node_query (>= 1.12.0)
|
9
9
|
parallel
|
10
10
|
parser
|
11
|
-
parser_node_ext (>= 0.
|
11
|
+
parser_node_ext (>= 0.9.0)
|
12
12
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
|
-
activesupport (6.1.7)
|
16
|
+
activesupport (6.1.7.2)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 1.6, < 2)
|
19
19
|
minitest (>= 5.1)
|
@@ -21,7 +21,7 @@ GEM
|
|
21
21
|
zeitwerk (~> 2.3)
|
22
22
|
ast (2.4.2)
|
23
23
|
coderay (1.1.3)
|
24
|
-
concurrent-ruby (1.
|
24
|
+
concurrent-ruby (1.2.0)
|
25
25
|
diff-lcs (1.5.0)
|
26
26
|
erubis (2.7.0)
|
27
27
|
fakefs (1.8.0)
|
@@ -48,20 +48,18 @@ GEM
|
|
48
48
|
rb-inotify (~> 0.9, >= 0.9.10)
|
49
49
|
lumberjack (1.2.8)
|
50
50
|
method_source (1.0.0)
|
51
|
-
minitest (5.
|
51
|
+
minitest (5.17.0)
|
52
52
|
nenv (0.3.0)
|
53
|
-
node_mutation (1.8.
|
54
|
-
activesupport (< 7.0.0)
|
53
|
+
node_mutation (1.8.2)
|
55
54
|
erubis
|
56
|
-
node_query (1.
|
57
|
-
activesupport (< 7.0.0)
|
55
|
+
node_query (1.12.0)
|
58
56
|
notiffany (0.1.3)
|
59
57
|
nenv (~> 0.1)
|
60
58
|
shellany (~> 0.0)
|
61
59
|
parallel (1.22.1)
|
62
|
-
parser (3.
|
60
|
+
parser (3.2.0.0)
|
63
61
|
ast (~> 2.4.1)
|
64
|
-
parser_node_ext (0.
|
62
|
+
parser_node_ext (0.9.0)
|
65
63
|
parser
|
66
64
|
pry (0.14.1)
|
67
65
|
coderay (~> 1.1)
|
@@ -85,7 +83,7 @@ GEM
|
|
85
83
|
rspec-support (3.10.3)
|
86
84
|
shellany (0.0.1)
|
87
85
|
thor (1.2.1)
|
88
|
-
tzinfo (2.0.
|
86
|
+
tzinfo (2.0.6)
|
89
87
|
concurrent-ruby (~> 1.0)
|
90
88
|
zeitwerk (2.6.6)
|
91
89
|
|
data/README.md
CHANGED
@@ -59,43 +59,51 @@ Want to use the CLI, check out [synvert-ruby](https://github.com/xinminlabs/synv
|
|
59
59
|
|
60
60
|
DSLs are as follows
|
61
61
|
|
62
|
-
* [configure](
|
63
|
-
* [description](
|
64
|
-
* [if_ruby](
|
65
|
-
* [if_gem](
|
66
|
-
* [within_files](
|
67
|
-
* [within_file](
|
68
|
-
* [add_file](
|
69
|
-
* [remove_file](
|
70
|
-
* [helper_method](
|
71
|
-
* [add_snippet](
|
72
|
-
* [
|
73
|
-
* [redo_until_no_change](./Synvert/Core/Rewriter.html#redo_until_no_change-instance_method) - run the snippet until no change
|
62
|
+
* [configure](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#configure-instance_method) - configure the rewriter
|
63
|
+
* [description](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#description-instance_method) - describe what the rewriter does
|
64
|
+
* [if_ruby](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#if_ruby-instance_method) - check if ruby version is greater than or equal to the specified ruby version
|
65
|
+
* [if_gem](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#if_gem-instance_method) - compare version of specified gem
|
66
|
+
* [within_files](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#within_files-instance_method) - find specified files
|
67
|
+
* [within_file](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#within_file-instance_method) - alias to within_files
|
68
|
+
* [add_file](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#add_file-instance_method) - add a new file
|
69
|
+
* [remove_file](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#remove_file-instance_method) - remove a file
|
70
|
+
* [helper_method](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#helper_method-instance_method) - define a helper method
|
71
|
+
* [add_snippet](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#add_snippet-instance_method) - call another rewriter
|
72
|
+
* [redo_until_no_change](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter.html#redo_until_no_change-instance_method) - run the snippet until no change
|
74
73
|
|
75
74
|
Scopes:
|
76
75
|
|
77
|
-
* [within_node](
|
78
|
-
* [with_node](
|
79
|
-
* [find_node](
|
80
|
-
* [goto_node](
|
76
|
+
* [within_node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#within_node-instance_method) - recursively find matching ast nodes
|
77
|
+
* [with_node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#with_node-instance_method) - alias to within_node
|
78
|
+
* [find_node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#find_node-instance_method) - alias to within_node
|
79
|
+
* [goto_node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#goto_node-instance_method) - go to a child node
|
81
80
|
|
82
81
|
Conditions:
|
83
82
|
|
84
|
-
* [if_exist_node](
|
85
|
-
* [unless_exist_node](
|
86
|
-
* [if_only_exist_node](
|
83
|
+
* [if_exist_node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#if_exist_node-instance_method) - check if matching node exist in the child nodes
|
84
|
+
* [unless_exist_node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#unless_exist_node-instance_method) - check if matching node doesn't exist in the child nodes
|
85
|
+
* [if_only_exist_node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#if_only_exist_node-instance_method) - check if current node has only one child node and the child node matches
|
87
86
|
|
88
87
|
Actions:
|
89
88
|
|
90
|
-
* [append](
|
91
|
-
* [prepend](
|
92
|
-
* [insert](
|
93
|
-
* [insert_after](
|
94
|
-
* [insert_before](
|
95
|
-
* [replace](
|
96
|
-
* [delete](
|
97
|
-
* [
|
98
|
-
* [
|
99
|
-
* [
|
100
|
-
* [
|
101
|
-
* [
|
89
|
+
* [append](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#append-instance_method) - append the code to the bottom of current node body
|
90
|
+
* [prepend](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#prepend-instance_method) - prepend the code to the bottom of current node body
|
91
|
+
* [insert](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#insert-instance_method) - insert code
|
92
|
+
* [insert_after](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#insert_after-instance_method) - insert the code next to the current node
|
93
|
+
* [insert_before](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#insert_before-instance_method) - insert the code previous to the current node
|
94
|
+
* [replace](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#replace-instance_method) - replace the code of specified child nodes
|
95
|
+
* [delete](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#delete-instance_method) - delete the code in specified child nodes
|
96
|
+
* [remove](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#remove-instance_method) - remove the whole code of current node
|
97
|
+
* [wrap](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#wrap-instance_method) - wrap the current node with code
|
98
|
+
* [replace_with](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#replace_with-instance_method) - replace the whole code of current node
|
99
|
+
* [warn](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#warn-instance_method) - warn message
|
100
|
+
* [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
|
101
|
+
* [noop](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#noop-instance_method) - no operation
|
102
|
+
* [add_action](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#add_action-instance_method) - add custom action
|
103
|
+
|
104
|
+
Attributes:
|
105
|
+
|
106
|
+
* [file_path](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#file_path-instance_method) - current file path
|
107
|
+
* [node](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#node-instance_method) - current ast node
|
108
|
+
* [query_adapter](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#query_adapter-instance_method) - [query adapter](https://xinminlabs.github.io/node-query-ruby/NodeQuery/Adapter.html) to get some helper methods
|
109
|
+
* [mutation_adapter](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#mutation_adapter-instance_method) - [mutation adapter](https://xinminlabs.github.io/node-mutation-ruby/NodeMutation/Adapter.html) to get some helper methods
|
@@ -30,13 +30,11 @@ module Synvert::Core
|
|
30
30
|
# @return file path
|
31
31
|
# @!attribute [rw] current_node
|
32
32
|
# @return current ast node
|
33
|
-
# @!attribute [r] current_mutation
|
34
|
-
# @return current mutation
|
35
33
|
# @!attribute [r] query_adapter
|
36
34
|
# @return NodeQuery Adapter
|
37
35
|
# @!attribute [r] mutation_adapter
|
38
36
|
# @return NodeMutation Adapter
|
39
|
-
attr_reader :file_path, :current_node, :
|
37
|
+
attr_reader :file_path, :current_node, :query_adapter, :mutation_adapter
|
40
38
|
attr_accessor :current_node
|
41
39
|
|
42
40
|
# Process the instance.
|
@@ -397,6 +395,15 @@ module Synvert::Core
|
|
397
395
|
@current_mutation.noop(@current_node)
|
398
396
|
end
|
399
397
|
|
398
|
+
# Add a custom action.
|
399
|
+
# @example
|
400
|
+
# remover_action = NodeMutation::RemoveAction.new(node)
|
401
|
+
# add_action(remover_action)
|
402
|
+
# @param action [Synvert::Core::Rewriter::Action] action
|
403
|
+
def add_action(action)
|
404
|
+
@current_mutation.actions << action.process
|
405
|
+
end
|
406
|
+
|
400
407
|
# It creates a {Synvert::Core::Rewriter::Warning} to save warning message.
|
401
408
|
# @example
|
402
409
|
# within_files 'vendor/plugins' do
|
@@ -407,14 +414,6 @@ module Synvert::Core
|
|
407
414
|
@rewriter.add_warning Rewriter::Warning.new(self, message)
|
408
415
|
end
|
409
416
|
|
410
|
-
# Match any value but nil.
|
411
|
-
# @example
|
412
|
-
# type: 'hash', nothing_value: 'true', status_value: any_value
|
413
|
-
# @return [NodeQuery::AnyValue]
|
414
|
-
def any_value
|
415
|
-
NodeQuery::AnyValue.new
|
416
|
-
end
|
417
|
-
|
418
417
|
private
|
419
418
|
|
420
419
|
# Read file source.
|
@@ -330,28 +330,6 @@ module Synvert::Core
|
|
330
330
|
@helpers << { name: name, block: block }
|
331
331
|
end
|
332
332
|
|
333
|
-
# It sets todo of the rewriter.
|
334
|
-
# Or get todo.
|
335
|
-
# @example
|
336
|
-
# Synvert::Rewriter.new 'rails', 'upgrade_3_2_to_4_0' do
|
337
|
-
# todo <<~EOS
|
338
|
-
# 1. Rails 4.0 no longer supports loading plugins from vendor/plugins. You must replace any plugins by extracting them to gems and adding them to your Gemfile. If you choose not to make them gems, you can move them into, say, lib/my_plugin/* and add an appropriate initializer in config/initializers/my_plugin.rb.
|
339
|
-
# 2. Make the following changes to your Gemfile.
|
340
|
-
# gem 'sass-rails', '~> 4.0.0'
|
341
|
-
# gem 'coffee-rails', '~> 4.0.0'
|
342
|
-
# gem 'uglifier', '>= 1.3.0'
|
343
|
-
# EOS
|
344
|
-
# end
|
345
|
-
# @param todo [String] rewriter todo.
|
346
|
-
# @return [String] rewriter todo.
|
347
|
-
def todo(todo = nil)
|
348
|
-
if todo
|
349
|
-
@todo = todo
|
350
|
-
else
|
351
|
-
@todo
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
333
|
# Rerun the snippet until no change.
|
356
334
|
# @example
|
357
335
|
# Synvert::Rewriter.new 'ruby', 'nested_class_definition' do
|
data/lib/synvert/core/version.rb
CHANGED
data/lib/synvert/core.rb
CHANGED
@@ -99,28 +99,28 @@ module Synvert::Core
|
|
99
99
|
it 'parses append' do
|
100
100
|
instance.instance_variable_set(:@current_mutation, double)
|
101
101
|
instance.current_node = double
|
102
|
-
expect(instance.current_mutation).to receive(:append).with(instance.current_node, 'Foobar')
|
102
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:append).with(instance.current_node, 'Foobar')
|
103
103
|
instance.append 'Foobar'
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'parses prepend' do
|
107
107
|
instance.instance_variable_set(:@current_mutation, double)
|
108
108
|
instance.current_node = double
|
109
|
-
expect(instance.current_mutation).to receive(:prepend).with(instance.current_node, 'Foobar')
|
109
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:prepend).with(instance.current_node, 'Foobar')
|
110
110
|
instance.prepend 'Foobar'
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'parses insert at end' do
|
114
114
|
instance.instance_variable_set(:@current_mutation, double)
|
115
115
|
instance.current_node = double
|
116
|
-
expect(instance.current_mutation).to receive(:insert).with(instance.current_node, 'Foobar', at: 'end', to: 'receiver')
|
116
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:insert).with(instance.current_node, 'Foobar', at: 'end', to: 'receiver')
|
117
117
|
instance.insert 'Foobar', to: 'receiver'
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'parses insert at beginning' do
|
121
121
|
instance.instance_variable_set(:@current_mutation, double)
|
122
122
|
instance.current_node = double
|
123
|
-
expect(instance.current_mutation).to receive(:insert).with(instance.current_node, 'Foobar', at: 'beginning', to: nil)
|
123
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:insert).with(instance.current_node, 'Foobar', at: 'beginning', to: nil)
|
124
124
|
instance.insert 'Foobar', at: 'beginning'
|
125
125
|
end
|
126
126
|
|
@@ -128,7 +128,7 @@ module Synvert::Core
|
|
128
128
|
instance.instance_variable_set(:@current_mutation, double)
|
129
129
|
instance.current_node = double
|
130
130
|
expect(NodeMutation).to receive_message_chain(:adapter, :get_start_loc, :column).and_return(2)
|
131
|
-
expect(instance.current_mutation).to receive(:insert).with(instance.current_node, "\n Foobar", at: 'end', to: nil)
|
131
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:insert).with(instance.current_node, "\n Foobar", at: 'end', to: nil)
|
132
132
|
instance.insert_after 'Foobar'
|
133
133
|
end
|
134
134
|
|
@@ -136,7 +136,7 @@ module Synvert::Core
|
|
136
136
|
instance.instance_variable_set(:@current_mutation, double)
|
137
137
|
instance.current_node = double
|
138
138
|
expect(NodeMutation).to receive_message_chain(:adapter, :get_start_loc, :column).and_return(2)
|
139
|
-
expect(instance.current_mutation).to receive(:insert).with(instance.current_node, "Foobar\n ", at: 'beginning', to: nil)
|
139
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:insert).with(instance.current_node, "Foobar\n ", at: 'beginning', to: nil)
|
140
140
|
instance.insert_before 'Foobar'
|
141
141
|
end
|
142
142
|
|
@@ -144,7 +144,7 @@ module Synvert::Core
|
|
144
144
|
instance.instance_variable_set(:@current_mutation, double)
|
145
145
|
instance.current_node = double
|
146
146
|
action = double
|
147
|
-
expect(instance.current_mutation).to receive(:actions).and_return([])
|
147
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:actions).and_return([])
|
148
148
|
expect(Rewriter::ReplaceErbStmtWithExprAction).to receive(:new).with(instance.current_node).and_return(action)
|
149
149
|
expect(action).to receive(:process)
|
150
150
|
instance.replace_erb_stmt_with_expr
|
@@ -153,42 +153,42 @@ module Synvert::Core
|
|
153
153
|
it 'parses replace_with' do
|
154
154
|
instance.instance_variable_set(:@current_mutation, double)
|
155
155
|
instance.current_node = double
|
156
|
-
expect(instance.current_mutation).to receive(:replace_with).with(instance.current_node, 'Foobar')
|
156
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:replace_with).with(instance.current_node, 'Foobar')
|
157
157
|
instance.replace_with 'Foobar'
|
158
158
|
end
|
159
159
|
|
160
160
|
it 'parses replace with' do
|
161
161
|
instance.instance_variable_set(:@current_mutation, double)
|
162
162
|
instance.current_node = double
|
163
|
-
expect(instance.current_mutation).to receive(:replace).with(instance.current_node, :message, with: 'Foobar')
|
163
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:replace).with(instance.current_node, :message, with: 'Foobar')
|
164
164
|
instance.replace :message, with: 'Foobar'
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'parses remove' do
|
168
168
|
instance.instance_variable_set(:@current_mutation, double)
|
169
169
|
instance.current_node = double
|
170
|
-
expect(instance.current_mutation).to receive(:remove).with(instance.current_node, and_comma: true)
|
170
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:remove).with(instance.current_node, and_comma: true)
|
171
171
|
instance.remove and_comma: true
|
172
172
|
end
|
173
173
|
|
174
174
|
it 'parses delete' do
|
175
175
|
instance.instance_variable_set(:@current_mutation, double)
|
176
176
|
instance.current_node = double
|
177
|
-
expect(instance.current_mutation).to receive(:delete).with(instance.current_node, :dot, :message, and_comma: true)
|
177
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:delete).with(instance.current_node, :dot, :message, and_comma: true)
|
178
178
|
instance.delete :dot, :message, and_comma: true
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'parses wrap with' do
|
182
182
|
instance.instance_variable_set(:@current_mutation, double)
|
183
183
|
instance.current_node = double
|
184
|
-
expect(instance.current_mutation).to receive(:wrap).with(instance.current_node, with: 'module Foobar')
|
184
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:wrap).with(instance.current_node, with: 'module Foobar')
|
185
185
|
instance.wrap with: 'module Foobar'
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'parses noop' do
|
189
189
|
instance.instance_variable_set(:@current_mutation, double)
|
190
190
|
instance.current_node = double
|
191
|
-
expect(instance.current_mutation).to receive(:noop).with(instance.current_node)
|
191
|
+
expect(instance.instance_variable_get(:@current_mutation)).to receive(:noop).with(instance.current_node)
|
192
192
|
instance.noop
|
193
193
|
end
|
194
194
|
|
@@ -197,8 +197,13 @@ module Synvert::Core
|
|
197
197
|
instance.warn 'foobar'
|
198
198
|
end
|
199
199
|
|
200
|
-
it '
|
201
|
-
|
200
|
+
it 'adds action' do
|
201
|
+
mutation = NodeMutation.new("")
|
202
|
+
instance.instance_variable_set(:@current_mutation, mutation)
|
203
|
+
action = double
|
204
|
+
expect(action).to receive(:process).and_return(action)
|
205
|
+
instance.add_action(action)
|
206
|
+
expect(mutation.actions).to eq [action]
|
202
207
|
end
|
203
208
|
|
204
209
|
describe '#process' do
|
@@ -256,15 +256,6 @@ module Synvert::Core
|
|
256
256
|
expect(instance.dynamic_helper('arg1', 'arg2')).to eq 'dynamic result'
|
257
257
|
end
|
258
258
|
|
259
|
-
it 'parses todo' do
|
260
|
-
rewriter =
|
261
|
-
Rewriter.new 'group', 'name' do
|
262
|
-
todo "this rewriter doesn't do blah blah blah"
|
263
|
-
end
|
264
|
-
rewriter.process
|
265
|
-
expect(rewriter.todo).to eq "this rewriter doesn't do blah blah blah"
|
266
|
-
end
|
267
|
-
|
268
259
|
it 'parses redo_until_no_change' do
|
269
260
|
rewriter =
|
270
261
|
Rewriter.new 'group', 'name' do
|
data/synvert-core-ruby.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_runtime_dependency "activesupport", "< 7.0.0"
|
23
23
|
spec.add_runtime_dependency "erubis"
|
24
|
-
spec.add_runtime_dependency "node_query", ">= 1.
|
25
|
-
spec.add_runtime_dependency "node_mutation", ">= 1.8.
|
24
|
+
spec.add_runtime_dependency "node_query", ">= 1.12.0"
|
25
|
+
spec.add_runtime_dependency "node_mutation", ">= 1.8.2"
|
26
26
|
spec.add_runtime_dependency "parser"
|
27
|
-
spec.add_runtime_dependency "parser_node_ext", ">= 0.
|
27
|
+
spec.add_runtime_dependency "parser_node_ext", ">= 0.9.0"
|
28
28
|
spec.add_runtime_dependency "parallel"
|
29
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.
|
4
|
+
version: 1.18.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:
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.12.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.12.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: node_mutation
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.8.
|
61
|
+
version: 1.8.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.8.
|
68
|
+
version: 1.8.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: parser
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.9.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.9.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: parallel
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|