[Rake-devel] [PATCH] Better pattern support for FileList
Tilman Sauerbeck
tilman at code-monkey.de
Sat Aug 12 13:04:37 EDT 2006
Hi,
atm, FileList only recognizes strings with at least one '*' character as
a pattern. ie, patterns that only make use of ? or [] or {} aren't
working in FileList, although they are supported by Dir.glob.
Attached patch fixes that by passing any string through Dir.glob.
I don't think the overhead of calling Dir.glob is big enough to warrant
more extensive checking for any wildcard characters in resolve_add.
Note that I didn't actually test the unit test that I added, cause I'm
too lazy to install rcov right now :P
Regards,
Tilman
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-------------- next part --------------
Index: test/test_filelist.rb
===================================================================
--- test/test_filelist.rb (revision 565)
+++ test/test_filelist.rb (working copy)
@@ -106,6 +106,14 @@
].sort, fl.sort
end
+ def test_non_star_patterns
+ fl = FileList.new
+ fl.include("foo.[ch]")
+ assert fl.size == 2
+ assert fl.include?("foo.c")
+ assert fl.include?("foo.h")
+ end
+
def test_reject
fl = FileList.new
fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
Index: lib/rake.rb
===================================================================
--- lib/rake.rb (revision 565)
+++ lib/rake.rb (working copy)
@@ -1132,12 +1132,7 @@
end
def resolve_add(fn)
- case fn
- when %r{[*?]}
- add_matching(fn)
- else
- self << fn
- end
+ add_matching(fn)
end
private :resolve_add
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rake-devel/attachments/20060812/69f5f6ae/attachment.bin
More information about the Rake-devel
mailing list