synvert-core 1.30.3 → 1.31.0
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/synvert/core/rewriter.rb +29 -17
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/instance_spec.rb +1 -1
- data/spec/synvert/core/rewriter_spec.rb +25 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3346883848c81ac9a130e077d0aae4eec34df1fcc365c95b9971b558b346f1a9
|
4
|
+
data.tar.gz: 15f5f83ef0d59c08edcf2cd076a36d0e057e94fee8d0435ca679c1a3e094dd01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a24728c75868284ed17baa5cdc9b9ab1d0961ba560ea00f7a71eaf0fe4bf3a01f322435002a9911e934d87a51a744f77b1c21b54bb8126739d31e0a50a9a991c
|
7
|
+
data.tar.gz: 65505c1d4f55b82d789f119463d535a67c11c85f18cbcbb0d7311d572f23e42085b44477d7d70c14e4019511cf5db7c502ac2e7278f0481720aaf64da7031e1f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -149,22 +149,26 @@ module Synvert::Core
|
|
149
149
|
if !@affected_files.empty? && @redo_until_no_change # redo
|
150
150
|
test
|
151
151
|
end
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
new_actions
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
last_start
|
161
|
-
|
152
|
+
if Configuration.test_result == 'new_source'
|
153
|
+
@test_results.values.flatten
|
154
|
+
else
|
155
|
+
@test_results.map do |filename, test_results|
|
156
|
+
new_actions = test_results.map(&:actions).flatten.sort_by(&:end)
|
157
|
+
last_start = -1
|
158
|
+
conflicted =
|
159
|
+
new_actions.any? do |action|
|
160
|
+
if last_start > action.end
|
161
|
+
true
|
162
|
+
else
|
163
|
+
last_start = action.start
|
164
|
+
false
|
165
|
+
end
|
162
166
|
end
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
167
|
+
result = NodeMutation::Result.new(affected: true, conflicted: conflicted)
|
168
|
+
result.actions = new_actions
|
169
|
+
result.file_path = filename
|
170
|
+
result
|
171
|
+
end
|
168
172
|
end
|
169
173
|
end
|
170
174
|
|
@@ -289,7 +293,11 @@ module Synvert::Core
|
|
289
293
|
|
290
294
|
unless @options[:write_to_file]
|
291
295
|
result = NodeMutation::Result.new(affected: true, conflicted: false)
|
292
|
-
|
296
|
+
if Configuration.test_result == 'new_source'
|
297
|
+
result.new_source = content
|
298
|
+
else
|
299
|
+
result.actions = [NodeMutation::Struct::Action.new(:add_file, 0, 0, content)]
|
300
|
+
end
|
293
301
|
result.file_path = filename
|
294
302
|
merge_test_result(result)
|
295
303
|
return
|
@@ -316,7 +324,11 @@ module Synvert::Core
|
|
316
324
|
|
317
325
|
unless @options[:write_to_file]
|
318
326
|
result = NodeMutation::Result.new(affected: true, conflicted: false)
|
319
|
-
|
327
|
+
if Configuration.test_result == 'new_source'
|
328
|
+
result.new_source = nil
|
329
|
+
else
|
330
|
+
result.actions = [NodeMutation::Struct::Action.new(:remove_file, 0, -1)]
|
331
|
+
end
|
320
332
|
result.file_path = filename
|
321
333
|
merge_test_result(result)
|
322
334
|
return
|
data/lib/synvert/core/version.rb
CHANGED
@@ -456,7 +456,7 @@ module Synvert::Core
|
|
456
456
|
before { Configuration.test_result = 'new_source' }
|
457
457
|
after { Configuration.test_result = nil }
|
458
458
|
|
459
|
-
it 'gets new_source
|
459
|
+
it 'gets new_source' do
|
460
460
|
instance =
|
461
461
|
Rewriter::Instance.new rewriter, 'spec/models/post_spec.rb' do
|
462
462
|
with_node type: 'send', receiver: 'FactoryGirl', message: 'create' do
|
@@ -100,6 +100,31 @@ module Synvert::Core
|
|
100
100
|
expect(results[0].actions).to eq [NodeMutation::Struct::Action.new(:replace, 6, 12, 'Synvert')]
|
101
101
|
end
|
102
102
|
end
|
103
|
+
|
104
|
+
context 'Configuration.test_result is new_source' do
|
105
|
+
before { Configuration.test_result = 'new_source' }
|
106
|
+
after { Configuration.test_result = nil }
|
107
|
+
|
108
|
+
it 'gets test results with new_source' do
|
109
|
+
rewriter =
|
110
|
+
Rewriter.new('group', 'name') do
|
111
|
+
within_files '**/*.rb' do
|
112
|
+
with_node node_type: 'class', name: 'Foobar' do
|
113
|
+
replace :name, with: 'Synvert'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
input = "class Foobar\nend"
|
118
|
+
FakeFS do
|
119
|
+
File.write("code.rb", input)
|
120
|
+
results = rewriter.test
|
121
|
+
expect(results[0].file_path).to eq '/code.rb'
|
122
|
+
expect(results[0].affected?).to be_truthy
|
123
|
+
expect(results[0].conflicted?).to be_falsey
|
124
|
+
expect(results[0].new_source).to eq "class Synvert\nend"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
103
128
|
end
|
104
129
|
|
105
130
|
describe 'parses within_file' do
|