From: Robert Dawson Date: 2003-10-18T23:06:50+09:00 Subject: POLS ANT file pattern in Ruby This is a multi-part message in MIME format. ------=_NextPart_000_094E_01C39585.7A570C60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I am returning to a bit of Ruby hacking after spending a couple of years = away from it. I met someone who is newer to Ruby and caught some of = their excitement for it (Hi Dan).=20 My day job has me writing Java code. As many of you will know the = default build tool for Java projects is ANT. ANT is a step forward from = the pre-ANT world, but has problems -- one of the big ones is that it is = XML based, and thus verbose. XML as good as YAML for data, and not as = good as Ruby for programming :). =20 Dan and I were talking about building a Ruby replacement for ANT. One = week-end we both decided to start writing it, and came up with = test-cases.. Dan came up with a name (BOB), and there is now a piece of = vapourware. My test cases are to do with ANT FileSetish behavour. Ant has some interesting globbing functionality that works very similar = to File::fnmatch, but slightly different. I like the ant way, but don't want to suprise Ruby people. Here is the test cases that talk about the behaviour I want. File.fnmatch would provide similar functionality (with = File::FNM_PATHNAME it comes really close), except I don't see that the = last test could past easily. Before I make the last test pass, I want to know if Ruby people would = find the behaviour described to be suprising? matcher =3D FilePatternMatcher.new assert(matcher.match("test.txt", "test.txt")) assert(matcher.match("test.txt", "*")) assert(matcher.match("second.txt", "*")) assert(matcher.match("test.txt", "*.txt"), "*.txt should match = test.txt") matcher =3D FilePatternMatcher.new assert(matcher.match("test.txt", "test.*"), "test.* should match = test.txt") assert(!matcher.match("somedirectory/test.txt", "*.txt"), "*.txt = should not match somedirectory/test.txt") assert(!matcher.match("test.txt", "*.doc")) assert(matcher.match("first/second/test.txt", "**/test.txt")) = assert(!matcher.match("first/second/third/fourth/fifth/test.txt", = "**/third/*/test.txt")) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.522 / Virus Database: 320 - Release Date: 30/09/2003 ------=_NextPart_000_094E_01C39585.7A570C60 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I am returning to a bit of Ruby hacking = after=20 spending a couple of years away from it.  I met someone who is = newer to=20 Ruby and caught some of their excitement for it (Hi Dan).
 
My day job has me writing Java = code.  As many=20 of you will know the default build tool for Java projects is ANT.  = ANT is a=20 step forward from the pre-ANT world, but has problems -- one of the big = ones is=20 that it is XML based, and thus verbose.  XML as good as YAML for = data, and=20 not as good as Ruby for programming :). 
 
Dan and I were talking about building a = Ruby=20 replacement for ANT.  One week-end we both decided to start writing = it, and=20 came up with test-cases.. Dan came up with a name (BOB), and there is = now a=20 piece of vapourware.
 
My test cases are to do with ANT = FileSetish=20 behavour.
 
Ant has some interesting globbing = functionality=20 that works very similar to File::fnmatch, but slightly = different.
 
I like the ant way, but don't want to = suprise Ruby=20 people.
 
Here is the test cases that talk about = the=20 behaviour I want.
 
File.fnmatch would provide similar = functionality=20 (with File::FNM_PATHNAME it comes really close), except I don't see that = the=20 last test could past easily.
 
Before I make the last test pass, I = want to know if=20 Ruby people would find the behaviour described to be = suprising?
 
        matcher=20 =3D FilePatternMatcher.new
        = assert(matcher.match("test.txt",=20 "test.txt"))
       =20 assert(matcher.match("test.txt",=20 "*"))
       =20 assert(matcher.match("second.txt", "*"))
       =20 assert(matcher.match("test.txt", "*.txt"),  "*.txt should match=20 test.txt")
        matcher =3D=20 FilePatternMatcher.new
       =20 assert(matcher.match("test.txt", "test.*"), "test.* should match=20 test.txt")
       =20 assert(!matcher.match("somedirectory/test.txt", "*.txt"), "*.txt = should not=20 match somedirectory/test.txt")
       =20 assert(!matcher.match("test.txt", "*.doc"))
       =20 assert(matcher.match("first/second/test.txt", = "**/test.txt"))
       =20 assert(!matcher.match("first/second/third/fourth/fifth/test.txt",=20 "**/third/*/test.txt"))
 

---
Outgoing mail is certified = Virus=20 Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: = 6.0.522 /=20 Virus Database: 320 - Release Date: = 30/09/2003
------=_NextPart_000_094E_01C39585.7A570C60--