25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/bob/compiler/substitution.rb', line 25
def quote_and_substitute(arg, node)
parts = arg.split(SUBSTITUTION_SCANNER).reject(&:empty?)
if parts.empty?
%{""}
else
parts.map { |str|
if SUBSTITUTION_SCANNER =~ str
if str[0] == "\\"
quote(str[1..-1] || "")
else
if (parsed = SUBSTITUTION_PARSER.match(str))
if parsed[:fallback]
"env.get(#{quote parsed[:path]}, #{quote unescape parsed[:fallback]})"
else
"env.get(#{quote parsed[:path]})"
end
else
warn "Treating invalid substitution as string: #{str.inspect}", node.parent.line
quote str
end
end
else
quote str
end
}.join(" + ")
end
end
|