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
當然,我正在做一些愚蠢的事情。
獎勵積分:如果你幫助我學習耙/紅寶石,並告訴我一個更好的方法來實現同樣的目標,同時擊敗皺紋。