diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-01-08 08:58:07 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-01-08 08:58:07 +0900 |
| commit | 70851aaf57bfdd3ae6e66c87c9fe2ed655980c66 (patch) | |
| tree | eb8fb9cecc4eda68ef0da8371154cb564d89413f | |
| parent | dc39d2290a4c7b5d75abbb85426cb486bc4c9bfd (diff) | |
| parent | edf7729d891b37423ca6b02768570e0b441f2884 (diff) | |
| download | mruby-70851aaf57bfdd3ae6e66c87c9fe2ed655980c66.tar.gz mruby-70851aaf57bfdd3ae6e66c87c9fe2ed655980c66.zip | |
Merge pull request #2696 from furunkel/master
Properly implement directory tasks
| -rwxr-xr-x | minirake | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -237,7 +237,8 @@ module MiniRake # Time stamp for file task. def timestamp - File::stat(name.to_s).mtime + stat = File::stat(name.to_s) + stat.directory? ? Time.at(0) : stat.mtime end end @@ -254,12 +255,14 @@ module MiniRake # Declare a set of files tasks to create the given directories on # demand. - def directory(dir) - path = [] - Sys.split_all(dir).each do |p| - path << p - FileTask.define_task(File.join(path)) do |t| - Sys.makedirs(t.name) + def directory(args, &block) + MiniRake::FileTask.define_task(args) do |t| + block.call(t) unless block.nil? + dir = args.is_a?(Hash) ? args.keys.first : args + (dir.split(File::SEPARATOR) + ['']).inject do |acc, part| + (acc + File::SEPARATOR).tap do |d| + Dir.mkdir(d) unless File.exists? d + end + part end end end |
