POLS ANT file pattern in Ruby

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

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 :).

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 = 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 = 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

* Robert Dawson <robert@rojotek.com> [1008 15:08]:

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

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 :).

Good luck with this - I was talking only yesterday about
how easy life could be with a tool with the power of ant
tasks and the simplicity of Ruby and YAML - I'm never using
XML again if I can help it, since I got RSI.

Let us know if something turns up on RubyForge!

···

--
I'm going to Boston to see my doctor. He's a very sick man.
    -- Fred Allen
Rasputin :: Jack of All Trades - Master of Nuns

Hi –

···

On Sat, 18 Oct 2003, Robert Dawson wrote:

Before I make the last test pass, I want to know if Ruby people
would find the behaviour described to be suprising?

assert(!matcher.match(“first/second/third/fourth/fifth/test.txt”,
“**/third/*/test.txt”))

Just eyeballing it, I would expect this assertion to be true. I guess
that means I would find File.fnmatch (which I’ve never used, except in
the last few minutes) surprising.

David


David Alan Black
home: dblack@superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

You might want to take a look at Rake
(http://onestepback.org/software/rake for now, I’m in the process of
moving to RubyForge).

Rake was based on Make rather than Ant, but once you throw away Make’s
weird tab syntax and Ant’s XML syntax, the underlying functionality
would probably be pretty close.

Let me know if you are interested in colaborating.

···

On Sat, 2003-10-18 at 10:06, Robert Dawson wrote:

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.


– Jim Weirich jweirich@one.net 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)

I noticed that Ruby supports lookaheads (??=), but does ruby support look
behinds?

I can’t get the syntax (?<=) to work. Is the syntax possibly different?

Thanks

Zach

Please Note that (??=) was to be (?=).

···

-----Original Message-----
From: Zach Dennis [mailto:zdennis@mktec.com]
Sent: Saturday, October 18, 2003 12:53 PM
To: ruby-talk ML
Subject: regex look behind

I noticed that Ruby supports lookaheads (??=), but does ruby support look
behinds?

I can’t get the syntax (?<=) to work. Is the syntax possibly different?

Thanks

Zach

No, it doesn’t. Anyway, you can compile your Ruby 1.6.8 or 1.8 with the
new regex engine oniguruma that already supports it:

http://raa.ruby-lang.org/list.rhtml?name=oniguruma

···

On Sat, 2003-10-18 at 18:52, Zach Dennis wrote:

I noticed that Ruby supports lookaheads (??=), but does ruby support look
behinds?