Class: Rake::Delphi::EchoToFile
- Defined in:
- lib/rake/common/echotask.rb
Instance Method Summary collapse
-
#initialize(task, ifile, ofile, vars) ⇒ EchoToFile
constructor
A new instance of EchoToFile.
Methods inherited from BasicTask
Constructor Details
#initialize(task, ifile, ofile, vars) ⇒ EchoToFile
Returns a new instance of EchoToFile.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rake/common/echotask.rb', line 10 def initialize(task, ifile, ofile, vars) super(task) @task.out "#{ifile} -> #{ofile}" FileUtils.mkdir_p(File.dirname(ofile)) File.open(ifile, 'r') do |f| File.open(ofile, 'w') do |w| while (line = f.gets) # replace ${var1.var2.var3} with its value from xml line.gsub!(/\$\{(.+?)\}/) do |match| val = nil $1.split(".").each do |part| val = val.nil? ? vars[part] : val[part] end match = val.nil? ? match : val end if vars w.puts line end w.close end f.close end end |