1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/serb.rb
nobu b2d9f1e9d0 * common.mk (encs): new target to compile external encodings.
* enc/Makefile.in: became a serb template.

* enc/make_encmake.rb: creates enc.mk from enc/Makefile.in using serb.

* lib/mkmf.rb (relative_from): moved from ext/extmk.rb.

* lib/mkmf.rb ($extmk): true if under to top source directory, not
  only ext.

* lib/mkmf.rb (depend_rules): extracted from create_makefile.

* tool/serb.rb (serb): splitted from tool/compile_prelude.rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 08:47:28 +00:00

17 lines
326 B
Ruby

def serb(str, var)
result = ''
str.each_line {|line|
if /\A!/ =~ line
result << $'
else
line.split(/(<%.*?%>)/).each {|x|
if /\A<%(.*)%>\z/ =~ x
result << "#{var} << (#{$1}).to_s\n"
else
result << "#{var} << #{x.dump}\n"
end
}
end
}
result
end