被ruby/rake文件列表搞糊涂了
下面是生成文件列表的代码被ruby/rake文件列表搞糊涂了,ruby,file,rake,Ruby,File,Rake,下面是生成文件列表的代码 files = FileList.new('c:/temp/**/*') do |fl| fl.exclude("*.dll") end puts files 为什么输出仍然包含*.dll文件?我遗漏了什么?因为传递给fl.exclude的glob模式是针对实际文件系统展开的,就像/tempglob模式一样,但它不能进行相同的匹配,因为它不是完整路径 fl.exclude 'c:/temp/**/*.dll' 因为传递给fl.exclud
files = FileList.new('c:/temp/**/*') do |fl|
fl.exclude("*.dll")
end
puts files
为什么输出仍然包含*.dll文件?我遗漏了什么?因为传递给
fl.exclude
的glob模式是针对实际文件系统展开的,就像/temp
glob模式一样,但它不能进行相同的匹配,因为它不是完整路径
fl.exclude 'c:/temp/**/*.dll'
因为传递给
fl.exclude
的glob模式是针对实际文件系统展开的,就像/temp
glob模式一样,但它不能进行相同的匹配,因为它不是完整路径
fl.exclude 'c:/temp/**/*.dll'
[按照DigitalRoss的回答]或者您可以使用常规表达式作为模式,请参见。所以这应该行得通
files = FileList.new('c:/temp/**/*') do |fl|
fl.exclude(/\.dll$/)
end
puts files
[按照DigitalRoss的回答]或者您可以使用常规表达式作为模式,请参见。所以这应该行得通
files = FileList.new('c:/temp/**/*') do |fl|
fl.exclude(/\.dll$/)
end
puts files