Closed zostay closed 8 years ago
@zostay Thanks for working on this! I've left some comments on the code; please have a look when you have time.
I hope to have a chance to look at this after work later. The comments are very helpful.
@zostay Excellent, keep me posted. Thanks again for helping to develop IO::String!
I think I addressed each of the suggestions you made. I also added more documentation and tests. I still need to look into what other methods should be implemented to complete the implementation.
This looks pretty good; I'll merge later today!
I added one last push and I am done now. This adds readchars(), seek(), and tell() so you can do character counting. I'm not going to implement slurp-rest() and read(), etc. because that involves encoding support.
Writes lack support for seek() and tell(), so print() does not overwrite as it should and put() and friends. That needs to be added to complete read/write support.
So, I broke my promise. I went ahead and fixed print. This adds a :a
option to open, makes seek work with print, also adds getc, which I overlooked, adds put, and adds gist and perl methods. It adds more tests for many of these things.
Most of what remains is related to encoding, which I haven't dived into. It wouldn't be hard to add, though. Mostly, it's just a matter of making sure .encode and .decode are called in time to count bytes rather than chars or to write bytes to the string. An IO::Buf might be a nice companion to this object.
One quick thought: getc
returns Nil
at end of stream; should readchars
return Nil
as well?
I'm going to merge to get the ball rolling, but IO::Handle
appears to return Str
on end of stream.
Thanks for making this happen and sorry I didn't get back to you. It has been a crazy couple of days for me. Anyway, you rock! :+1:
Cheers.
This is work in progress, but I wanted to submit a pull request to get your feedback.
So far I revamped internals and added support for doing basic reads. Writes work as before (with new internals).