Ruby file list excludes folder

Here is all I tried:

files = FileList.new("c:/temp/**/*") do |file| file.exclude("c:/temp/logs/") end files = FileList.new("c:/temp/**/*") do |file| file.exclude("c:/temp/logs") end files = FileList.new("c:/temp/**/*") do |file| file.exclude("c:/temp/logs/*.*") end files = FileList.new("c:/temp/**/*") do |file| file.exclude("c:/temp/logs/**/*") end files = FileList.new("c:/temp/**/*") do |file| file.exclude("c:/temp/**/logs/") end 

the rake version is 0.9.2.2, and the Ruby version is 193. everything does not work. How can I exclude a directory in a file list?

+6
source share
1 answer

I assume that you are trying to get a list of all files under c:/tmp except everything that is in (and including) the c:/tmp/logs folder:

 files = FileList.new("c:/temp/**/*").exclude(/c:\/temp\/logs/) 

[Edit] For more information, see the FileList#exclude documentation. For example, to exclude multiple directories, you can either add multiple string / regex arguments, change the regular expression to match all directory patterns that need to be excluded, or do something similar in a block.

 x1 = /c:\/temp\/logs/ # The entire "c:/temp/logs" folder. x2 = /\.zip$/i # Any file whose name ends with ".zip". FileList.new("c:/temp/**/*").exclude(x1, x2) 
+6
source

Source: https://habr.com/ru/post/906226/


All Articles