On 8/11/05, Trans <transfire / gmail.com> wrote:
> I may have found a much better way to override Kernel#require. Here's
> my current code:
> 
>   require 'uri'
> 
>   module Kernel::NanoKernel
> 
>     FILE_ESC_RE = %r{[^a-zA-Z_0-9.\-]}
> 
>     def require( fpath )
>       fs = fpath.split('/')
>       fn = fs.pop
>       dn = fs.join('/')
>       dn += '/' unless dn.empty?
>       en = URI.escape( File.basename( fn ), FILE_ESC_RE )
>       super( "#{dn}#{en}" )
>     end
> 
>   end
> 
>   class Object
>     include NanoKernel
>   end
> 
> I appears to work flawlessly. Agree? Or do you see a bug waiting to
> bite?

Tom, what problem are you trying to solve?  I mean, I see that you're
overriding require, but I'm not sure how it's supposed to be better. 
I'm not implying that it _isn't_.  Just trying to understand the
intent.
-- 
Chad Fowler
http://chadfowler.com
http://rubycentral.org 
http://rubygarden.org 
http://rubygems.rubyforge.org (over 700,000 gems served!)