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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fddb0e5f9a0308d8dbf4af383000ff6e7249697cc22986dad4e2ead63d833f5
4
- data.tar.gz: 9e15b511b6bc4dc20f8b8cfe32beb0b57d1bc5ec505800c88d121c3849b866f4
3
+ metadata.gz: 32daaff5e515783785e74b94839328eb08fc1a0c48e6bae047079f0575bba411
4
+ data.tar.gz: fde8c7b9081f4a32e6f63e9ee9e6ced1878debf41541f822da788e26b756233f
5
5
  SHA512:
6
- metadata.gz: 75a0e4992bc623f897294bf603ebaf5b1a713cac9b349e7d4b2a53bb7be3ccc024313957b232049dcb377d412944e8858b66e59ef6a3d00d58a766473f7bc836
7
- data.tar.gz: daa75723d1e22c1a3d0bd91016dae1cd5f1bd863c750a22d7c897b087f726fd9dd1c35b3ae8695b614fe26cfa502f05263773f1cecc1843c76a10e9c580273c8
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.16.0)
4
+ synvert-core (1.18.0)
5
5
  activesupport (< 7.0.0)
6
6
  erubis
7
- node_mutation (>= 1.8.1)
8
- node_query (>= 1.11.0)
7
+ node_mutation (>= 1.8.2)
8
+ node_query (>= 1.12.0)
9
9
  parallel
10
10
  parser
11
- parser_node_ext (>= 0.4.1)
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.1.10)
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.16.3)
51
+ minitest (5.17.0)
52
52
  nenv (0.3.0)
53
- node_mutation (1.8.1)
54
- activesupport (< 7.0.0)
53
+ node_mutation (1.8.2)
55
54
  erubis
56
- node_query (1.11.0)
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.1.3.0)
60
+ parser (3.2.0.0)
63
61
  ast (~> 2.4.1)
64
- parser_node_ext (0.5.1)
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.5)
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](./Synvert/Core/Rewriter.html#configure-instance_method) - configure the rewriter
63
- * [description](./Synvert/Core/Rewriter.html#description-instance_method) - set description of the rewriter
64
- * [if_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](./Synvert/Core/Rewriter.html#if_gem-instance_method) - compare version of specified gem
66
- * [within_files](./Synvert/Core/Rewriter.html#within_files-instance_method) - find specified files
67
- * [within_file](./Synvert/Core/Rewriter.html#within_file-instance_method) - alias to within_files
68
- * [add_file](./Synvert/Core/Rewriter.html#add_file-instance_method) - add a new file
69
- * [remove_file](./Synvert/Core/Rewriter.html#remove_file-instance_method) - remove a file
70
- * [helper_method](./Synvert/Core/Rewriter.html#helper_method-instance_method) - define a helper method
71
- * [add_snippet](./Synvert/Core/Rewriter.html#add_snippet-instance_method) - call another rewriter
72
- * [todo](./Synvert/Core/Rewriter.html#todo-instance_method) - set todo
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](./Synvert/Core/Rewriter/Instance.html#within_node-instance_method) - recursively find matching ast nodes
78
- * [with_node](./Synvert/Core/Rewriter/Instance.html#with_node-instance_method) - alias to within_node
79
- * [find_node](./Synvert/Core/Rewriter/Instance.html#find_node-instance_method) - alias to within_node
80
- * [goto_node](./Synvert/Core/Rewriter/Instance.html#goto_node-instance_method) - go to a child 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](./Synvert/Core/Rewriter/Instance.html#if_exist_node-instance_method) - check if matching node exist in the child nodes
85
- * [unless_exist_node](./Synvert/Core/Rewriter/Instance.html#unless_exist_node-instance_method) - check if matching node doesn't exist in the child nodes
86
- * [if_only_exist_node](./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
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](./Synvert/Core/Rewriter/Instance.html#append-instance_method) - append the code to the bottom of current node body
91
- * [prepend](./Synvert/Core/Rewriter/Instance.html#prepend-instance_method) - prepend the code to the bottom of current node body
92
- * [insert](./Synvert/Core/Rewriter/Instance.html#insert-instance_method) - insert code
93
- * [insert_after](./Synvert/Core/Rewriter/Instance.html#insert_after-instance_method) - insert the code next to the current node
94
- * [insert_before](./Synvert/Core/Rewriter/Instance.html#insert_before-instance_method) - insert the code previous to the current node
95
- * [replace](./Synvert/Core/Rewriter/Instance.html#replace-instance_method) - replace the code of specified child nodes
96
- * [delete](./Synvert/Core/Rewriter/Instance.html#delete-instance_method) - delete the code specified child nodes
97
- * [wrap](./Synvert/Core/Rewriter/Instance.html#wrap-instance_method) - wrap the current node with code
98
- * [replace_with](./Synvert/Core/Rewriter/Instance.html#replace_with-instance_method) - replace the whole code of current node
99
- * [warn](./Synvert/Core/Rewriter/Instance.html#warn-instance_method) - warn message
100
- * [replace_erb_stmt_with_expr](./Synvert/Core/Rewriter/Instance.html#replace_erb_stmt_with_expr-instance_method) - replace erb stmt code to expr code
101
- * [noop](./Synvert/Core/Rewriter/Instance.html#noop-instance_method) - no operation
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, :current_mutation, :query_adapter, :mutation_adapter
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.16.0'
5
+ VERSION = '1.18.0'
6
6
  end
7
7
  end
data/lib/synvert/core.rb CHANGED
@@ -7,6 +7,7 @@ require 'parser/current'
7
7
  require 'parser_node_ext'
8
8
  require_relative './core/node_ext'
9
9
  require 'active_support'
10
+ require 'active_support/core_ext'
10
11
  require 'erubis'
11
12
  require 'set'
12
13
  require 'node_query'
@@ -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 'parses any_value' do
201
- expect(instance.any_value).to be_instance_of NodeQuery::AnyValue
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
@@ -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.11.0"
25
- spec.add_runtime_dependency "node_mutation", ">= 1.8.1"
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.4.1"
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.16.0
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: 2022-12-29 00:00:00.000000000 Z
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.11.0
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.11.0
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.1
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.1
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.4.1
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.4.1
96
+ version: 0.9.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: parallel
99
99
  requirement: !ruby/object:Gem::Requirement