In article <jgmj60lih3807ibu6rhjkhn5ab9fiac7k0 / 4ax.com>,
  gabriele renzi <surrender_it / rc1.vip.ukl.yahoo.com> writes:

> yes I'm aware of open-uri and I do agree it is impressive and useful, 
> but, it has the problem of just being.. well.. 'open' :)
> For example, it does not allow handling of Dir objects out of the local fs.

open-uri.rb and pathname.rb provides a VFS for HTTP, FTP and local
files.  Since they define a polymorphic open method for URI::HTTP,
URI::FTP and Pathname, you can open them as http_uri.open,
ftp_uri.open or pathname.open.  You don't need to distinguish them.
Note that Kernel.open(loc) is implemented as URI.parse(loc).open in
open-uri.rb.

If you want to open another kind of resources, define a class to
represent its location and define open method for the class.  Then,
you can open the resource.

This means that Tcl's struct Tcl_Filesystem is represented as a duck
type.  http://www.tcl.tk/cgi-bin/tct/tip/17.html

However open-uri.rb and pathname.rb provides only two porlymorphic
methods: open and read.  So it needs more methods to be useful as VFS.
For example, already Pathname#each_entry exists for iterating over
child entries like Dir.foreach.  URI::FTP#each_entry should be
provided in future. URI::HTTP#each_entry is difficult to implement,
though.  So I think the duck type is enough as a VFS framework.

> I believe something like this in the base distribution would be lovely :)

open-uri.rb and pathname.rb is in the base distribution.
-- 
Tanaka Akira