0
目标:收集所有文件,包含与目录结构匹配的目录结构。Rake FileList排除方法适用于irb,但不适用于我的rake文件
皱纹:需要过滤一个讨厌的不受欢迎的目录,但匹配的却是唯一命名的“不想要的”。实际的字符串改变,以保护无辜。
- 源/ DIR1 /内容/脚本 - OK
- 源/ DIR2/subdir1 /内容/脚本 - OK
- 源/ DIR3 /拒收想/内容/脚本 - 好...不想
以下作品中的剧本,但我要做的不应该是必要的不需要的路径单独检查。当我在irb中测试这个相同的FileList并将其排除时,它按需要工作。从我的rakefile中,我看到不想要目录由FileList返回。
FileList['source/**/content/scripts'].exclude('do-not-want').each do |f|
unless /do-not-want/ =~ f #hmm why does the exclude above not actually exclude do-not-want directories?
Dir.chdir(f) do |d|
puts "directory changed to #{d} and copying scripts from #{d} to common directory #{target}"
FileUtils.cp_r('.', target)
end
end
end
当然,我正在做一些愚蠢的事情。
奖励积分:如果你帮助我学习耙/红宝石,并告诉我一个更好的方法来实现同样的目标,同时击败皱纹。