From: John Carter Date: 2003-12-12T06:48:24+09:00 Subject: Re: expect, rexpect and others Ok, I'm setting up a RubyForge project for it, anyone interested in being co-developers on it? On Fri, 12 Dec 2003, Ben Giddings wrote: > Is there some historical reason why the result of a match is "buffer", $1, > $2, $3...? To me, it would make more sense to do Well I started it as a drop in replacement for the one in the Ruby standard library.(Which is admirably brief and elegant), I already had code that was using that, but it was too slow. I think at one stage they did that. I see now they have if mat=e_pat.match(buf) then result = [buf,*mat.to_a[1..-1]] One major API change relative to the standard expect.rb is the timeout is the number of seconds the select blocks waiting for input. So if the timeout is 2 seconds and single character trickles in every second you never ever timeout. In RExpect I timeout if I haven't seen a match in timeout seconds. > Also, the other efficiency thing that concerns me is that both versions > attempt to match against the entire buffer. The majority of regexps > *could* match something huge, but are generally only used for something > less than say 80 chars long. I want to use an 'expect' type library > against something that is updating a count of each byte of a 200k+ file > written. After that progress meter it prints "Done.", which is all I > really want to match against. It would be more efficient if there were an > option to specify the maximum size of the buffer to use as a match, and to > throw out parts of a buffer bigger than that. Something like: Once I have it checked into Rubyforge you are welcome to hack and patch it and either join me as a developer with CVS access rights or just send me patches. My only request is to try keep the API reasonably backward compatible, either by use of default parameters or providing new interfaces. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand A Million Monkeys can inflict worse things than just Shakespeare on your system.