Hi
Can someone tell me what is going wrong here:
% rake -V
rake, version 0.4.4
% ls
Rakefile
% cat Rakefile
X = FileList["*"]
p X
desc "test"
task :default
% rake
(in /Users/jdf/tmp)
[]
Why is FileList empty?
Hi Jim!
FileList use a "lazy load" technique where we don't calculate the exact
list of files needed for a file list until the first time we need to
know that information.
This allows us to do things like ...
JUNK = FileList['**/*.bak']
CFILES = FileList['**/*.c']
OFILE = FileList['**/*.o']
task :clobber do
# Delete all the JUNK
end
task :compile do
# compile all the CFILES
end
If I invoke :clobber, I never need to know that CFILES resolves to. And
if I invoke :compile, then I never need to resolve JUNK. Since
searching the file system can be somewhat expensive, lazy load file
lists cut down a little on the startup time of Rake.
So in your case, it seems that the inspect command (issued internally by
"p") isn't causing the FileList to be resolved. You can force the
resolution of any file list by trying to access the contents of X.
Try this ...
X = FileList['*']
p X
X[0]
p X
You can also request explicit resolution with "resolve", e.g.
X = FileList['*']
p X.resolve
I'm not sure why inspect (used by "p") is not triggering resolution.
Perhaps it should (to_s does, for example).