adz*_*ies 11
Ruby内置了类来简化:
Dir['deployment_dir/**/*'].delete_if { |f| f.end_with?('.txt') }
Run Code Online (Sandbox Code Playgroud)
但是,对于一些内置任务,rake有这方面的帮助.改编自API文档,您可以选择如下文件:
files_to_delete = FileList.new('deployment_dir/**/*') do |fl|
fl.exclude('*.txt')
end
Run Code Online (Sandbox Code Playgroud)
然后,您可以将其提供给您的删除任务.
更好的是,您可以使用内置的CLEAN/CLOBBER任务:
# Your rake file:
require 'rake/clean'
# [] is alias for .new(), and we can chain .exclude
CLEAN = FileList['deployment_dir/**/*'].exclude('*.txt')
Run Code Online (Sandbox Code Playgroud)
然后你可以在cmd线上说:
rake clean
Run Code Online (Sandbox Code Playgroud)
阅读教程.
| 归档时间: |
|
| 查看次数: |
4317 次 |
| 最近记录: |