synvert-core 1.8.0 → 1.9.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 +8 -0
- data/Gemfile.lock +2 -2
- data/README.md +1 -0
- data/lib/synvert/core/rewriter/instance.rb +6 -1
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/instance_spec.rb +12 -5
- 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: aa46b311ec4eb71e3a23d060e1a23dcceffe1b0ddea066a64043aea29635d143
|
4
|
+
data.tar.gz: 7dd8b27cfc88e3d98a876da7592e1df466e00a6c1b79309d34abc475e287b5a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b2babf63c196c428173cac102fc55d7968e8bfee9ba484a8c25ffa3c2da711502c172a5c60ae84155e0fef7ab1e2bcad1b70367f36612550bceee010f2ac43
|
7
|
+
data.tar.gz: ca19136ae935ab915d498ab71fb286b9cf30469dbc4503e5f5fb754863cefaa290e1a833b35cedfa0b2533bf64d55987d031514be60b32884145b8df8cc42de7
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
synvert-core (1.
|
4
|
+
synvert-core (1.9.0)
|
5
5
|
activesupport (< 7.0.0)
|
6
6
|
erubis
|
7
7
|
node_mutation
|
@@ -49,7 +49,7 @@ GEM
|
|
49
49
|
method_source (1.0.0)
|
50
50
|
minitest (5.16.3)
|
51
51
|
nenv (0.3.0)
|
52
|
-
node_mutation (1.
|
52
|
+
node_mutation (1.4.0)
|
53
53
|
activesupport (< 7.0.0)
|
54
54
|
erubis
|
55
55
|
node_query (1.6.0)
|
data/README.md
CHANGED
@@ -96,3 +96,4 @@ Actions:
|
|
96
96
|
* [replace_with](./Synvert/Core/Rewriter/Instance.html#replace_with-instance_method) - replace the whole code of current node
|
97
97
|
* [warn](./Synvert/Core/Rewriter/Instance.html#warn-instance_method) - warn message
|
98
98
|
* [replace_erb_stmt_with_expr](./Synvert/Core/Rewriter/Instance.html#replace_erb_stmt_with_expr-instance_method) - replace erb stmt code to expr code
|
99
|
+
* [noop](./Synvert/Core/Rewriter/Instance.html#noop-instance_method) - no operation
|
@@ -41,7 +41,7 @@ module Synvert::Core
|
|
41
41
|
# It finds specified files, for each file, it executes the block code, tests the original code,
|
42
42
|
# then returns the actions.
|
43
43
|
def test
|
44
|
-
get_file_paths.
|
44
|
+
get_file_paths.map do |file_path|
|
45
45
|
test_file(file_path)
|
46
46
|
end
|
47
47
|
end
|
@@ -325,6 +325,11 @@ module Synvert::Core
|
|
325
325
|
@current_mutation.wrap(@current_node, with: with)
|
326
326
|
end
|
327
327
|
|
328
|
+
# Parse +noop dsl.
|
329
|
+
def noop
|
330
|
+
@current_mutation.noop(@current_node)
|
331
|
+
end
|
332
|
+
|
328
333
|
# Parse +warn+ dsl, it creates a {Synvert::Core::Rewriter::Warning} to save warning message.
|
329
334
|
# @example
|
330
335
|
# within_files 'vendor/plugins' do
|
data/lib/synvert/core/version.rb
CHANGED
@@ -176,6 +176,13 @@ module Synvert::Core
|
|
176
176
|
instance.wrap with: 'module Foobar'
|
177
177
|
end
|
178
178
|
|
179
|
+
it 'parses noop' do
|
180
|
+
instance.current_mutation = double
|
181
|
+
instance.current_node = double
|
182
|
+
expect(instance.current_mutation).to receive(:noop).with(instance.current_node)
|
183
|
+
instance.noop
|
184
|
+
end
|
185
|
+
|
179
186
|
it 'parses warn' do
|
180
187
|
expect(Rewriter::Warning).to receive(:new).with(instance, 'foobar')
|
181
188
|
instance.warn 'foobar'
|
@@ -205,7 +212,7 @@ module Synvert::Core
|
|
205
212
|
assert post.valid?
|
206
213
|
end
|
207
214
|
EOS
|
208
|
-
expect(Dir).to receive(:glob).with('
|
215
|
+
expect(Dir).to receive(:glob).with('spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb'])
|
209
216
|
expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
|
210
217
|
expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
|
211
218
|
instance.process
|
@@ -230,7 +237,7 @@ module Synvert::Core
|
|
230
237
|
config.include FactoryGirl::Syntax::Methods
|
231
238
|
end
|
232
239
|
EOS
|
233
|
-
expect(Dir).to receive(:glob).with('
|
240
|
+
expect(Dir).to receive(:glob).with('spec/spec_helper.rb').and_return(['spec/spec_helper.rb'])
|
234
241
|
expect(File).to receive(:read).with('spec/spec_helper.rb', encoding: 'UTF-8').and_return(input)
|
235
242
|
expect(File).not_to receive(:write).with('spec/spec_helper.rb', output)
|
236
243
|
instance.process
|
@@ -257,7 +264,7 @@ module Synvert::Core
|
|
257
264
|
assert post.valid?
|
258
265
|
end
|
259
266
|
EOS
|
260
|
-
expect(Dir).to receive(:glob).with('
|
267
|
+
expect(Dir).to receive(:glob).with('spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb']).twice
|
261
268
|
expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
|
262
269
|
expect(File).to receive(:write).with('spec/models/post_spec.rb', output)
|
263
270
|
expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(output)
|
@@ -284,7 +291,7 @@ module Synvert::Core
|
|
284
291
|
assert post.valid?
|
285
292
|
end
|
286
293
|
EOS
|
287
|
-
expect(Dir).to receive(:glob).with('
|
294
|
+
expect(Dir).to receive(:glob).with('spec/**/*_spec.rb').and_return(['spec/models/post_spec.rb'])
|
288
295
|
expect(File).to receive(:read).with('spec/models/post_spec.rb', encoding: 'UTF-8').and_return(input)
|
289
296
|
results = instance.test
|
290
297
|
expect(results[0].file_path).to eq 'spec/models/post_spec.rb'
|
@@ -308,7 +315,7 @@ module Synvert::Core
|
|
308
315
|
config.include FactoryGirl::Syntax::Methods
|
309
316
|
end
|
310
317
|
EOS
|
311
|
-
expect(Dir).to receive(:glob).with('
|
318
|
+
expect(Dir).to receive(:glob).with('spec/spec_helper.rb').and_return(['spec/spec_helper.rb'])
|
312
319
|
expect(File).to receive(:read).with('spec/spec_helper.rb', encoding: 'UTF-8').and_return(input)
|
313
320
|
result = instance.test
|
314
321
|
expect(result[0].file_path).to eq 'spec/spec_helper.rb'
|
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.9.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-09-
|
11
|
+
date: 2022-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|