synvert-core 1.21.7 → 1.22.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 +4 -0
- data/Gemfile.lock +1 -1
- data/lib/synvert/core/rewriter/instance.rb +15 -12
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/instance_spec.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90f6acc3b15b0d25a8df1320393862f574dffbfc1743fd5bbb03f7323d994ae1
|
4
|
+
data.tar.gz: 7fa5d3c80ed1c86fc8c67abc2add07e374681c3bb54bc53e590195ffb51c3fb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 755e6b198dc2ce1c652ea6bced3f9ee002599e6ab51dee5ea1a9dd8d103b0aafa86fa495808db548a675e0a6bf0356533687f7cd652e73dd519bec9e50cb55dd
|
7
|
+
data.tar.gz: f2364e3359310b864a813d6132e9475ea4f19f95219e849bcbd33cdfe362f849c5a11ddc9220ca6b7689058ca795e70be75a63043fc9498224d336f2fd10a567
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
254
|
-
|
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
|
-
|
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)
|
268
271
|
column = ' ' * NodeMutation.adapter.get_start_loc(@current_node).column
|
269
|
-
@current_mutation.insert(@current_node, "\n#{column}#{code}", at: 'end', to: to)
|
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
|
-
|
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)
|
283
288
|
column = ' ' * NodeMutation.adapter.get_start_loc(@current_node).column
|
284
|
-
@current_mutation.insert(@current_node, "#{code}\n#{column}", at: 'beginning', to: to)
|
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(
|
338
|
-
@current_mutation.remove(@current_node,
|
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,
|
353
|
-
@current_mutation.delete(@current_node, *selectors,
|
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.
|
data/lib/synvert/core/version.rb
CHANGED
@@ -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,7 +155,8 @@ module Synvert::Core
|
|
153
155
|
instance.current_node,
|
154
156
|
"\n Foobar",
|
155
157
|
at: 'end',
|
156
|
-
to: nil
|
158
|
+
to: nil,
|
159
|
+
and_comma: false
|
157
160
|
)
|
158
161
|
instance.insert_after 'Foobar'
|
159
162
|
end
|
@@ -166,7 +169,8 @@ module Synvert::Core
|
|
166
169
|
instance.current_node,
|
167
170
|
"Foobar\n ",
|
168
171
|
at: 'beginning',
|
169
|
-
to: nil
|
172
|
+
to: nil,
|
173
|
+
and_comma: false
|
170
174
|
)
|
171
175
|
instance.insert_before 'Foobar'
|
172
176
|
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.22.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: 2023-03-
|
11
|
+
date: 2023-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|