# File lib/packaging/tar.rb, line 94 def template(workdir=nil) workdir ||= Pkg::Config.project_root @templates.each do |template_file| template_file = File.expand_path(template_file) target_file = template_file.sub(File.extname(template_file),"") root = Pathname.new(Pkg::Config.project_root) # We construct paths to the erb template and its proposed target file # relative to the project root, *not* fully qualified. This allows us # to, given a temporary workdir containing a copy of the project, # construct the full path to the erb and target file inside the # temporary workdir. # rel_path_to_template = Pathname.new(template_file).relative_path_from(root).to_path rel_path_to_target = Pathname.new(target_file).relative_path_from(root).to_path # What we pass to Pkg::util::File.erb_file are the paths to the erb # and target inside of a temporary project directory. We are, in # essence, templating "in place." This is why we remove the original # files - they're not the originals in the authoritative project # directory, but the originals in the temporary working copy. Pkg::Util::File.erb_file(File.join(workdir,rel_path_to_template), File.join(workdir, rel_path_to_target), true, :binding => Pkg::Config.get_binding) end end