I'm definitely in favour, but would prefer the method name #readn. It's shorter and actually more intuitive (to me) than #readbytes. -- Gavin Sinclair
I restate the thread from : Imho having Readable and Writable mixins (aka Stream interfaces/facets) would be better, cause inheriting from IO is nearly impossible (as StringIO shows) and adding readbytes to IO and StringIO would just postpone the problem: just looking at the bundled libraries, what about OpenSSL::SSL::SSLSocket and Zlib::GzipReader ? -- gabriele renzi
How about adding the two modules Readable and Writeable (Writable?) in io.c, and include both of them into class IO and StringIO. "readbytes.rb" could issues an obsolete warning... and we introduce two new files "readable.rb" and "writable.rb", which fill the two modules with content? Of course we should include the modules into OpenSSL::SSL:SSLSocket and Zlib::GzipReader, too. Agreed? -- mneumann
Looking at the ruby-openssl sources, class SSLSocket seem to not to have a read or write method. Or do you refer to module Buffering in file lib/openssl/buffering.rb ?
-- mneumann
I'd like to have the two modules in the core, and let readbytes.rb add behaviour to the module IO::Writable, that would leave the behaviour in an external library like now, but still allow consistent behaviour for every Writable object.
I think SSLSocket just responds to #sysread and #syswrite, but I don't know much of the internals of OpenSSL.
Anyway, I think that you may like to provide a spec/sample implementation (fill "Analisys" ;) of the modules for better acceptance by matz.
-- gabriele renzi
for an implementation see the patch:
except, that the two modules are not in the IO namespace (but that's easy to fix).
I'm definitely in favour, but would prefer the method name #readn. It's shorter and actually more intuitive (to me) than #readbytes. -- Gavin Sinclair
I restate the thread from : Imho having Readable and Writable mixins (aka Stream interfaces/facets) would be better, cause inheriting from IO is nearly impossible (as StringIO shows) and adding readbytes to IO and StringIO would just postpone the problem: just looking at the bundled libraries, what about OpenSSL::SSL::SSLSocket and Zlib::GzipReader ? -- gabriele renzi
How about adding the two modules Readable and Writeable (Writable?) in io.c, and include both of them into class IO and StringIO. "readbytes.rb" could issues an obsolete warning... and we introduce two new files "readable.rb" and "writable.rb", which fill the two modules with content? Of course we should include the modules into OpenSSL::SSL:SSLSocket and Zlib::GzipReader, too. Agreed? -- mneumann
Looking at the ruby-openssl sources, class SSLSocket seem to not to have a read or write method. Or do you refer to module Buffering in file lib/openssl/buffering.rb ?
-- mneumann
I'd like to have the two modules in the core, and let readbytes.rb add behaviour to the module IO::Writable, that would leave the behaviour in an external library like now, but still allow consistent behaviour for every Writable object.
I think SSLSocket just responds to #sysread and #syswrite, but I don't know much of the internals of OpenSSL.
Anyway, I think that you may like to provide a spec/sample implementation (fill "Analisys" ;) of the modules for better acceptance by matz.
-- gabriele renzi
for an implementation see the patch:
except, that the two modules are not in the IO namespace (but that's easy to fix).