4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/less/ext.rb', line 4
def failure_message color
o = color ? Mutter.new.clear : lambda {|i, *args| i }
return nil unless (tf = terminal_failures) && tf.size > 0
msg = "on line #{failure_line}: expected " + (
tf.size == 1 ?
o[tf[0].expected_string, :yellow] :
"one of #{o[tf.map {|f| f.expected_string }.uniq * ' ', :yellow]}"
)
f = input[failure_index]
got = case f
when "\n" then o['\n', :cyan]
when nil then o["EOF", :cyan]
when ' ' then o["white-space", :cyan]
else o[f.chr, :yellow]
end
msg += " got #{got} after:\n\n#{input[index...failure_index]}\n"
end
|