Rake FileList not working?

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?

···

--
T.

T. Onoma wrote:

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.

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

No, No, Thank You! :slight_smile:

BTW, how do I give the RDocTask a prerequisite?

Thanks again,
T.

···

On Tuesday 24 August 2004 09:05 am, Jim Weirich wrote:

(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.

Jim Weirich wrote:

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)

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]

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

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.

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)