aboutsummaryrefslogtreecommitdiffstats
path: root/test/rake/data/file_creation_task/Rakefile
blob: 94641b69723842ff1939b96f463b911e45d67a7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby

N = 2

task :default => :run

BUILD_DIR = 'build'
task :clean do 
  rm_rf 'build'
  rm_rf 'src'
end

task :run

TARGET_DIR = 'build/copies'

FileList['src/*'].each do |src|
  directory TARGET_DIR
  target = File.join TARGET_DIR, File.basename(src)
  file target => [src, TARGET_DIR] do
    cp src, target
    # sleep 3 if src !~ /foo#{N-1}$/   # I'm commenting out this sleep, it doesn't seem to do anything.
  end
  task :run => target
end

task :prep => :clean do
  mkdir_p 'src'
  N.times do |n|
    puts "DBG: Touching src/foo#{n}"
    touch "src/foo#{n}"
  end
end