5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/deep_cover/tools/format_generated_code.rb', line 5
def format_generated_code(covered_code)
inserts = []
generated_code = covered_code.instrument_source do |inserted, _node, expr_limit|
inserts << [expr_limit, inserted.size]
Term::ANSIColor.yellow(inserted)
end
inserts = inserts.sort_by { |exp, _| [exp.line, exp.column] }.reverse
generated_lines = generated_code.split("\n")
inserts.each do |exp_limit, size|
= generated_lines[exp_limit.line]
next if Tools.blank?()
next unless .start_with?('#>')
next if .start_with?('#>X')
next unless .size >= exp_limit.column
.insert(exp_limit.column, ' ' * size)
end
generated_lines.join("\n")
end
|