lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Apr 13, 2012, at 9:40 AM, steve donovan wrote:

> On Fri, Apr 13, 2012 at 9:20 AM, Alexander Gladysh <agladysh@gmail.com> wrote:
>> Is it possible to get either of modules as a standalone
>> LuaRocks-installable module?
> 
> Should be straightforward, I don't think I'd bother Hisham with too
> many of these little babies, but I will write a rockspec.

Really? A full-fledge rockspec for a one file, self-contained module? Oh, my… :D

> And thanks to PA for pointing out the problem…

You are welcome.

While we are at it, I suspect that the semantic of read( number ) is slightly off…

For example:

print( stringio.open( 'foobar' ):read( -3 ) )

> foob

Perhaps a negative size should raise an exception or something, no?

> David M and I agreed that such a module is very useful when writing
> tests that involves file operations.

Yes, it's rather convenient in various scenario.


P.S.

FWIW, I wrote my own in the meantime -with no doubts its very own set of bugs- until we can settle on one foolproof implementation:

http://dev.alt.textdrive.com/browser/Mail/StringIO.lua#L83

Usage example:

for aLine in StringIO( aString ):lines() do
  aCount = aCount + 1
  print( aCount, aLine )
end