From: Robert Klemme Date: 2009-09-29T20:42:24+09:00 Subject: Re: Mimicking classpath and hierarchical packages ? 2009/9/29 Jean-Christophe Le Lann : > I'd like to have your advices concerning these points : how to to mimick > the java notions of classpath and of hierarchical packages, in ruby, as > close as possible ? > > Is there a standard and clean way of doing this ? "Classpath" is stored in $: and $LOAD_PATH (they point to the same object). Shell variable is $RUBYLIB. Typically files are named similar to their content, e.g. file mypro.rb module MyPro end # optional: require 'mypro/c1' file mypro/c1.rb require 'mypro' module MyPro class C1 end end etc. Use via require 'mypro/c1' or require 'mypro'. Alternative: file mypro.rb module MyPro autoload 'C1', 'c1' end file mypro/c1.rb require 'mypro' module MyPro class C1 end end Use via require 'mypro/c1' or require 'mypro'. You can see this in various standard libraries as well. You can look at REXML for example. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/