synvert-core 1.21.7 → 1.22.1

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: 0d33e2874a1d23b725a4d2bb62e8cfd03d71b9c82e22fbe9a349336ac19f6eab
4
- data.tar.gz: 74a56b255b08c5f017fe0717dbd644cfc61983a06c6c7c0b0ec86f77d6566ff1
3
+ metadata.gz: 80a767738290801342257194e72b784fa8d1849f5a7a2098dabf5776cc33735b
4
+ data.tar.gz: 7e6a0b109c9c281a3ead5e623107c30417288dc4ca694d0bdafcd71ccac67fc8
5
5
  SHA512:
6
- metadata.gz: a98c6ded4885bebda395ad253cb826ce1e82ad06d734cc0bfbd00b592676c6dde8aac530d30d2d27beb3b7ca314519a782de91fa0e97905ea4c1fd62122eef98
7
- data.tar.gz: ec1d2ac24a8f9066bb228363b961cc1e93da96f501cbfb166fb398cb21a3bd80d5ee496b261e0901289b6fed3d9749fdf04cd5b2db458853caf742ceca5c5691
6
+ metadata.gz: 7abe8e7fbe261f1739974eb51b70cbf86a4a674bcdd8c2fcadce42962deb0a2be2532d28bdb808a211dd4e86c8bbd7150fb6d8def0ac263e9fcceba491f4b240
7
+ data.tar.gz: 906b75c024ca0464d60bdadaf8dcf761f2e18d3df2704d66423eefcf1bdf98cae57804b368358ac0838053f76fee4a36c4989f774b630489291aaf5e05933f4a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.22.1 (2023-03-31)
4
+
5
+ * Fix indent when `insert_after` or `insert_before` to a child node
6
+ * Update `node_mutation` to 1.13.0
7
+
8
+ ## 1.22.0 (2023-03-24)
9
+
10
+ * Add `and_comma` option to `insert`, `insert_before`, `insert_after` api
11
+
3
12
  ## 1.21.7 (2023-03-23)
4
13
 
5
14
  * Polish `erb` engine
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.21.7)
4
+ synvert-core (1.22.1)
5
5
  activesupport (< 7.0.0)
6
- node_mutation (>= 1.12.1)
6
+ node_mutation (>= 1.13.0)
7
7
  node_query (>= 1.12.0)
8
8
  parallel
9
9
  parser
@@ -49,7 +49,7 @@ GEM
49
49
  method_source (1.0.0)
50
50
  minitest (5.18.0)
51
51
  nenv (0.3.0)
52
- node_mutation (1.12.1)
52
+ node_mutation (1.13.0)
53
53
  erubis
54
54
  node_query (1.12.0)
55
55
  notiffany (0.1.3)
@@ -250,8 +250,9 @@ module Synvert::Core
250
250
  # @param code [String] code need to be inserted.
251
251
  # @param at [String] insert position, beginning or end
252
252
  # @param to [String] where to insert, if it is nil, will insert to current node.
253
- def insert(code, at: 'end', to: nil)
254
- @current_mutation.insert(@current_node, code, at: at, to: to)
253
+ # @param and_comma [Boolean] insert extra comma.
254
+ def insert(code, at: 'end', to: nil, and_comma: false)
255
+ @current_mutation.insert(@current_node, code, at: at, to: to, and_comma: and_comma)
255
256
  end
256
257
 
257
258
  # It inserts the code next to the current node.
@@ -264,9 +265,11 @@ module Synvert::Core
264
265
  # insert_after "{{receiver}}.secret_key_base = \"#{SecureRandom.hex(64)}\""
265
266
  # end
266
267
  # @param code [String] code need to be inserted.
267
- def insert_after(code, to: nil)
268
- column = ' ' * NodeMutation.adapter.get_start_loc(@current_node).column
269
- @current_mutation.insert(@current_node, "\n#{column}#{code}", at: 'end', to: to)
268
+ # @param to [String] where to insert, if it is nil, will insert to current node.
269
+ # @param and_comma [Boolean] insert extra comma.
270
+ def insert_after(code, to: nil, and_comma: false)
271
+ column = ' ' * NodeMutation.adapter.get_start_loc(@current_node, to).column
272
+ @current_mutation.insert(@current_node, "\n#{column}#{code}", at: 'end', to: to, and_comma: and_comma)
270
273
  end
271
274
 
272
275
  # It inserts the code previous to the current node.
@@ -279,9 +282,11 @@ module Synvert::Core
279
282
  # insert_before "{{receiver}}.secret_key_base = \"#{SecureRandom.hex(64)}\""
280
283
  # end
281
284
  # @param code [String] code need to be inserted.
282
- def insert_before(code, to: nil)
283
- column = ' ' * NodeMutation.adapter.get_start_loc(@current_node).column
284
- @current_mutation.insert(@current_node, "#{code}\n#{column}", at: 'beginning', to: to)
285
+ # @param to [String] where to insert, if it is nil, will insert to current node.
286
+ # @param and_comma [Boolean] insert extra comma.
287
+ def insert_before(code, to: nil, and_comma: false)
288
+ column = ' ' * NodeMutation.adapter.get_start_loc(@current_node, to).column
289
+ @current_mutation.insert(@current_node, "#{code}\n#{column}", at: 'beginning', to: to, and_comma: and_comma)
285
290
  end
286
291
 
287
292
  # It replaces erb stmt code to expr code.
@@ -332,10 +337,9 @@ module Synvert::Core
332
337
  # with_node type: 'send', message: { in: %w[puts p] } do
333
338
  # remove
334
339
  # end
335
- # @param options [Hash] options.
336
340
  # @option and_comma [Boolean] delete extra comma.
337
- def remove(**options)
338
- @current_mutation.remove(@current_node, **options)
341
+ def remove(and_comma: false)
342
+ @current_mutation.remove(@current_node, and_comma: and_comma)
339
343
  end
340
344
 
341
345
  # It deletes child nodes.
@@ -347,10 +351,9 @@ module Synvert::Core
347
351
  # delete :receiver, :dot
348
352
  # end
349
353
  # @param selectors [Array<Symbol>] selector names of child node.
350
- # @param options [Hash]
351
354
  # @option and_comma [Boolean] delete extra comma.
352
- def delete(*selectors, **options)
353
- @current_mutation.delete(@current_node, *selectors, **options)
355
+ def delete(*selectors, and_comma: false)
356
+ @current_mutation.delete(@current_node, *selectors, and_comma: and_comma)
354
357
  end
355
358
 
356
359
  # It wraps current node with code.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.21.7'
5
+ VERSION = '1.22.1'
6
6
  end
7
7
  end
@@ -128,7 +128,8 @@ module Synvert::Core
128
128
  instance.current_node,
129
129
  'Foobar',
130
130
  at: 'end',
131
- to: 'receiver'
131
+ to: 'receiver',
132
+ and_comma: false
132
133
  )
133
134
  instance.insert 'Foobar', to: 'receiver'
134
135
  end
@@ -140,7 +141,8 @@ module Synvert::Core
140
141
  instance.current_node,
141
142
  'Foobar',
142
143
  at: 'beginning',
143
- to: nil
144
+ to: nil,
145
+ and_comma: false
144
146
  )
145
147
  instance.insert 'Foobar', at: 'beginning'
146
148
  end
@@ -153,9 +155,10 @@ module Synvert::Core
153
155
  instance.current_node,
154
156
  "\n Foobar",
155
157
  at: 'end',
156
- to: nil
158
+ to: 'caller',
159
+ and_comma: false
157
160
  )
158
- instance.insert_after 'Foobar'
161
+ instance.insert_after 'Foobar', to: 'caller'
159
162
  end
160
163
 
161
164
  it 'parses insert_before' do
@@ -166,9 +169,10 @@ module Synvert::Core
166
169
  instance.current_node,
167
170
  "Foobar\n ",
168
171
  at: 'beginning',
169
- to: nil
172
+ to: 'caller',
173
+ and_comma: false
170
174
  )
171
- instance.insert_before 'Foobar'
175
+ instance.insert_before 'Foobar', to: 'caller'
172
176
  end
173
177
 
174
178
  it 'parses replace_erb_stmt_with_expr' do
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_runtime_dependency "activesupport", "< 7.0.0"
23
23
  spec.add_runtime_dependency "node_query", ">= 1.12.0"
24
- spec.add_runtime_dependency "node_mutation", ">= 1.12.1"
24
+ spec.add_runtime_dependency "node_mutation", ">= 1.13.0"
25
25
  spec.add_runtime_dependency "parser"
26
26
  spec.add_runtime_dependency "parser_node_ext", ">= 1.0.0"
27
27
  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.7
4
+ version: 1.22.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-03-23 00:00:00.000000000 Z
11
+ date: 2023-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.12.1
47
+ version: 1.13.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.12.1
54
+ version: 1.13.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: parser
57
57
  requirement: !ruby/object:Gem::Requirement