From: James Britt Date: 2005-11-02T14:54:47+09:00 Subject: Re: [ANN] urirequire: I got yer Web 2.0 right here Jeff Wood wrote: > lib ??? > > shouldn't that be like 4 lines??? > > def net_eval( url ) > require 'open-uri' > eval open( url ).readlines.join > end > Here's a quick variation: require 'open-uri' def require( resource ) begin super rescue LoadError $:.each do |lp| if lp =~ /http:\/\//i begin s = open( "#{lp}/#{resource}" ) { |f| f.read} eval s return rescue; end end end raise LoadError.new( "Cannot find '#{resource}'") end end # Now you can add select Web sites to the load path $:.unshift 'http://trust.me/no/really/this/is/safe' Mix in MouseHole for more fun. James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys