From: David Brady Date: 2005-08-30T02:44:03+09:00 Subject: Re: Best way to release mini-libraries? Kirk Haines wrote: >Or should it be released as nothing more than a class file without any >installer, leaving it up to the user to make sure it doesn't butt heads with >something else? Anyone out there who might use this who has an opinion? > > If I can include it with require 'webcache' I would expect Webcache.new to work. If I have to include it with require 'iowa/webcache' I would expect to have to prefix Iowa:: to the namespace. This would also imply to me that it isn't really standalone.... I'm not a Ruby authority by any means; is it possible to grab a naked module (e.g. something that imports directly into your namespace) and wrap it in a module? If so, then your fear of polluting the namespace is overcautious. This doesn't work, but you can see my intent: ------------------------------ class Webcache #...our Webcache class end # Iowa's Webcache imports directly, conflicting with our Webcache # class. Wrap it in IowaWebcache module IowaWebcache # this doesn't work--require seems to import directly into top-level space require 'webcache' end w1 = Webcache.new w2 = IowaWebcache::Webcache.new ------------------------------ Related: - How can you achieve the desired result above, i.e. pushing an existing module down into another module? - How can you reverse it, importing the contents of a module into the current namespace? (e.g. Python's "import from" syntax) If the end-user can manipulate the modules and namespaces freely, then my suggestion is to put the code in the most *convenient* place possible. Later users can pack it away in another namespace if they feel the need. -dB -- David Brady ruby-talk@shinybit.com Grizzled C++/Python/Perl hacker. New to Ruby. Take my Ruby statements with the appropriate amount of salt. I'm having a really surreal day... OR AM I?