Hi,
I have the need to filter files, replacing in-place-tokens with
variables during the copy. I would like to be able to do something like
this:
FileUtils.filter_cp_r from_dir, to_dir, { “SERVER1” => “s1.example.com”,
/LDAP_SERVER_([\d])/ => "l\\1.example.com" }
and those files will be copied, but modified so that in the destination
dir, all occurances of SERVER1 have been changed to s1.example.com and
the regexp substituted with the substitution string.
Is there any library for this? I’ve looked but not found. My current
approach is to create a small lib for this myself, using FileUtils, Find
and Tempfile. But it feels like this should be a common operation,
especially when doing installation scripts.
And before someone suggests it: no, I’m not at liberty to change the
tokens, so I can’t embed ERb-tags in the source material.
–
Ola B. (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)
“Yields falsehood when quined” yields falsehood when quined.