Skip to content

Instantly share code, notes, and snippets.

@choan
Created April 2, 2009 12:41
Show Gist options
  • Save choan/89170 to your computer and use it in GitHub Desktop.
Save choan/89170 to your computer and use it in GitHub Desktop.
A method to define rake file tasks which depend on multiple files which are concatenated after being processed with ERB
module RakeExtensions
def concat(*args, &block)
t = Rake::FileTask.define_task(*args)
out_file = t.name
list = []
yield list if block_given?
t.enhance(list) do
File.open(out_file, 'w+') do |f|
f << list.map do |item|
ERB.new(IO.read(File.expand_path(item)), nil, '%').result(binding)
end * $/
end
end
end
end
# usage:
# concat some_file do |list|
# list << "header"
# list << "some_source_file"
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment