Rake FileList not working?

T

T. Onoma

In my Rakefile (given in earlier post):

PKG_FILES = FileList[
"lib/**/*",
"test/**/*",
"examples/**/*",
"doc/**/*",
"[A-Z]*",
"install.rb",
"Rakefile"
].exclude(/\bCVS\b|~$/)
p PKG_FILES.class

# => NilClass

Huh?
 
J

Jim Weirich

T. Onoma said:
In my Rakefile (given in earlier post):

PKG_FILES = FileList[
"lib/**/*",
"test/**/*",
"examples/**/*",
"doc/**/*",
"[A-Z]*",
"install.rb",
"Rakefile"
].exclude(/\bCVS\b|~$/)
p PKG_FILES.class

# => NilClass

Huh?

(1) Remove the exclude call. You don't need it. FileLists are smart
enough to automatically exclude CVS directories and backup files.

(2) If you do need exclude, put it in a separate step. E.g.

PKG_FILES = FileList['blah*.rb']
PKG_FILES.exclude(/.*test.rb/)

Exclude must not be returning the filelist. That is a bug. I'll fix it
in the next release.

Thanks for the heads up.
 
T

T. Onoma

(1) Remove the exclude call. You don't need it. FileLists are smart
enough to automatically exclude CVS directories and backup files.

(2) If you do need exclude, put it in a separate step. E.g.

PKG_FILES = FileList['blah*.rb']
PKG_FILES.exclude(/.*test.rb/)

Exclude must not be returning the filelist. That is a bug. I'll fix it
in the next release.

Thanks for the heads up.

No, No, Thank You! :)

BTW, how do I give the RDocTask a prerequisite?

Thanks again,
T.
 
J

Joel VanderWerf

Jim said:
Exclude must not be returning the filelist. That is a bug. I'll fix it
in the next release.

I'm confused... Isn't FileList#exclude supposed to return an array of
strings, not a FileList? (Rake 0.4.3, anyway)
 
J

Jim Weirich

T. Onoma said:
BTW, how do I give the RDocTask a prerequisite?

Prerequisites can be added to a task at any time. Just redeclare the task
and the prerequisites and action will be appended to the existing task.

For example:

task :build => [:preprocess, :compile, :link]

is equivalent to ...

task :build => [:preprocess]
task :build => [:compile]
task :build => [:link]

So, to add a prereq to the :rdoc task ...

task :rdoc => [:whatever]
 
J

Jim Weirich

Joel VanderWerf said:
I'm confused... Isn't FileList#exclude supposed to return an array of
strings, not a FileList? (Rake 0.4.3, anyway)

Well, exclude should return a list of strings (actually a list of file
names). The type of list it returns is a FileList. And since FileList
acts a lot like an array (through the magic of DuckTyping), returning the
file list object *is* returning an array of strings ... it's just not an
Array of strings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top