[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

POLS ANT file pattern in Ruby

Robert Dawson

10/18/2003 2:07:00 PM

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.g...).
Version: 6.0.522 / Virus Database: 320 - Release Date: 30/09/2003
4 Answers

Rasputin

10/18/2003 3:55:00 PM

0

* 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

Jim Weirich

10/18/2003 9:55:00 PM

0

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.

You might want to take a look at Rake
(http://onest.../sof... 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.

--
-- Jim Weirich jweirich@one.net http://onest...
-----------------------------------------------------------------
"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)

Jason Creighton

10/18/2003 10:28:00 PM

0

On Sun, 19 Oct 2003 06:54:31 +0900
Jim Weirich <jweirich@one.net> wrote:

> 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.
>
> You might want to take a look at Rake

I second this. Rake is very cool. (I thought you might want an opinion
from someone other than the author. :-) )

Jason Creighton

Martin DeMello

10/20/2003 2:23:00 PM

0

Jason Creighton <androflux@softhome.net.remove.to.reply> wrote:
> On Sun, 19 Oct 2003 06:54:31 +0900
> Jim Weirich <jweirich@one.net> wrote:
>
>> 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.
>>
>> You might want to take a look at Rake
>
> I second this. Rake is very cool. (I thought you might want an opinion
> from someone other than the author. :-) )

Has anyone ported a complicated makefile over to rake? That would make
the basis of a good article, I think.

martin