Skip to content

Instantly share code, notes, and snippets.

@shinaisan
Created October 30, 2016 08:46
Show Gist options
  • Save shinaisan/8b1ccc65e9d27cee2443a13f38806d1b to your computer and use it in GitHub Desktop.
Save shinaisan/8b1ccc65e9d27cee2443a13f38806d1b to your computer and use it in GitHub Desktop.
Rake pathmap example.
require 'rake'
SOURCE_FILES = Rake::FileList.new('src/**/*.txt')
TARGET_FILES = SOURCE_FILES.pathmap("%{^src/,out/}X.txt")
task :default => :copy_all
task :copy_all => TARGET_FILES
rule %r{^out/.+txt$} => '%{^out/,src/}X.txt' do |t|
d = t.name.pathmap("%d")
mkdir_p d
cp t.source, t.name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment