icn
icn

Reputation: 17876

confused by ruby/rake filelist

Here is my code to generate a list of files

  files = FileList.new('c:/temp/**/*') do |fl|
    fl.exclude("*.dll")    
  end
  puts files

How come output still contains *.dll file? Something am I missing?

Upvotes: 0

Views: 601

Answers (2)

Marek Příhoda
Marek Příhoda

Reputation: 11198

[Following DigitalRoss's answer] Or you can you a regular expresion as the pattern, see the docs. So this should work

files = FileList.new('c:/temp/**/*') do |fl|
  fl.exclude(/\.dll$/)
end

puts files

Upvotes: 1

DigitalRoss
DigitalRoss

Reputation: 146053

Because the glob pattern passed to fl.exclude is expanded against the actual file system just like the /temp glob pattern, but it can't do the same match because it isn't a full path.

fl.exclude 'c:/temp/**/*.dll'

Upvotes: 2

Related Questions