ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.che...@ascentialsoftware.com
Subject RE: Perl filter task vs. filter/filterset/copy task
Date Tue, 27 Nov 2001 14:43:05 GMT
I can imagine having some kind of PerlFilterOutputStream.
The only issue I have with that is the fact that the filter make sense if it
works line by line.
What I mean, like with awk for example, each filter is applied for each line
one after another.
The PerlFilterOutputStream will have to put in a buffer any incoming data,
detect each line then filter
it and write it back to the underlying OutputStream.
I can also imagine that the "line separator" can be configurable (so you do
not have to filter
line by line if you do not want to).
But what will it mean if you call flush on this OutputStream in a middle of
a "line"? Just try to apply the
filter on what is in the buffer and forget about the end of the line?

What will it means for the XML syntax of the filter? Some kind of a
generalization where you can specify the
kind of filter you want (like the mapper)? the key/value might be not enough
to totally specify the filtering
parameters of any filter, will it?

Thomas

-----Original Message-----
From: Peter Donald [mailto:peter@apache.org]
Sent: Tuesday, November 27, 2001 4:11 AM
To: Ant Developers List
Subject: Re: Perl filter task vs. filter/filterset/copy task


Sounds interesting. One thing I have wanted to do for a while is reimplement

filters as a normal InputStream. So you could do something like

FilterOutputStream fos = ..;
//set some values to filter here
fos.setFilterVar( key, value );

FileUtils.copy( new FileInputStream("myfile.txt"), fos );

Then in theory your filter could be any implementation of output stream. 
Could your perlfilter work like that ?


On Tue, 27 Nov 2001 05:12, thomas.cherel@ascentialsoftware.com wrote:
> I must admit this work motivated by trying to create some build.xml files
> to run some
> automatic tests (instead of building a product), which might not be the
> primary purpose of Ant.
> I looked at Junit and extensions, the only problem I have with those
> environments is the way the test is marked
> as failed or passed (by asserts or exceptions thrown by the test code).
I'd
> like much better the output of the test compared
> to a reference output with may be some filtering. It makes the test
simpler
> to write (no code to write to check if test is
> ok) and it is more suitable for integration type of tests (tests more
> complex than unit tests).
>
> I created a perfilter task. I am not happy with the current design of
this,
> since I believe that it should be a
> generalization of the filter/filterset used within a copy task (or
> something like that). I am currently looking into that, but
> I'd like the ant developer community input on that.
>
> The idea is to be able to take multiple files, filter them using the perl
> regexp "s/../../gimox" and generate multiple
> (or one) output files (using filset and mapper). I am using the oro-2.0.4
> for the perl expression processing. I defined
> a new task (perlfilter) and a new type (subst) in order to do that. You
can
> find below some example of such task.
>
> The issues that I have when trying to generalize it into filter/filterset
> and copy are the following ones:
> 	- I am not sure that the subst type can be mapped easily into a
> filter type. The token/value attributes are
> too specific, I think.
> 	- the copy task with a merge mapper is not doing a merge (it is not
> a concat). It is just overwriting the tofile
> by each of the copied file (tofile will be equal to the last copied file).
> Not sure if this is a bug or if this is the way
> it is supposed to work (but merge mapper is a very confusing term, then).
>
> Thomas
>
> <perlfilter file="test.run.out" tofile="test.out" overwrite="true"
> verbose="true">
>   <subst pattern=".*t" replacement="rr" />
> </perlfilter>
>
> <perlfilter tofile="test12.out" verbose="true" overwrite="true">
>   <fileset dir=".">
>     <include name="test.run1.out" />
>     <include name="test.run2.out" />
>   </fileset>
>   <subst pattern="/" replacement="\\" delimiter="#" />
> </perlfilter>
>
> <perlfilter todir="." verbose="true" overwrite="true">
>   <fileset dir=".">
>     <include name="test.run1.out" />
>     <include name="test.run2.out" />
>   </fileset>
>   <mapper type="merge" to="test.out" />
>   <subst pattern="/" replacement="\\" delimiter="#" />
>   <subst pattern=".*t" replacement="rr" />
> </perlfilter>

-- 
Cheers,

Pete

---------------------------------------------------
"Therefore it can be said that victorious warriors 
win first, and then go to battle, while defeated 
warriors go to battle first, and then seek to win." 
              - Sun Tzu, the Art Of War
---------------------------------------------------

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message