31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/seeing_is_believing/binary/engine.rb', line 31
def self.call(options)
options = options.dup
body = options.delete :body
line = options.delete :line
markers = options.delete :markers
alignment_strategy = options.delete :alignment_strategy
marker_regexes = markers.values.map(&:regex)
RewriteComments.call body, include_lines: [line] do ||
if line == .line_number && marker_regexes.any? { |r| r =~ .text }
= ''
elsif line == .line_number && .text.empty?
= FormatComment.call(
.whitespace_col,
markers.value.prefix,
'',
options.merge(
pad_to: alignment_strategy.line_length_for(.line_number)
),
)
elsif line == .line_number
= .whitespace + .text
elsif match = markers.value.regex.match(.text)
= FormatComment.call(
.whitespace_col,
markers.value.prefix,
match.post_match,
options.merge(
pad_to: alignment_strategy.line_length_for(.line_number)
)
)
else
= .whitespace + .text
end
[[/^\s*/], .lstrip]
end
end
|