On Wed, 24 Jan 2001 14:23:19 -0500 (EST) Mathieu Bouchard <matju / cam.org> wrote: > > Hi James, > > > def require source > > files = File.new("libcontents").read > > source.sub! /.rb/ ,"" # OOPS! should be /\.rb$/ doh! and below again! > > if files =~ Regexp.new(source + ".rb") > > system "tar -Ozxf rubylib.tar.gz #{source}.rb > /tmp/#{source}.rb" > > super "/tmp/#{source}.rb" > > File.delete "/tmp/#{source}.rb" > > This is a really cool thing! > > What I see you could improve: > > 1. Error handling. What if a file is not there? What if the archive is > broken? What if out of disk space? Yes, laziness at fault, since I put it together myself I knew that all the bits were in the right place but should allow for others mucking it up :) > 2. Execution time. This is in "quadratic time". This means that if you > have twice the files, you quadruple your time. This can be improved by > switching to another format: > > (a) usual file hierarchy but with support for .gz Too big > (b) tar archive, not gzipped, but containing only .gz files isn't that what a tar.gz is anyway? > (c) .zip file This is a lot faster, nice one. > 3. Not using a temporary file. This would require a change to the > built-in "require" method itself. beyond me I'm afraid > > By the way, in which context do you define require? in module Kernel ? if > so, how come can you use super? Don't know just did it and ignored the warning for now. > > matju > >