From: Gordon Miller Date: 2001-01-16T12:10:01+09:00 Subject: [ruby-talk:9356] Packages within Ruby I am working on a wrapper around Gnuplot that involves a large number of classes and a good amount of code. Keeping all of the code in one file is just confusing and really violates my anal retentive sense of order that I like to keep my code in. In Python, which is where I have spent the bulk of my past few scripting years, there is the concept of a package. With this, if you import a directory name, python will look for a __init__.py file in the directory of that name. This file typically contains other import statements to include the files of the package. I was thinking that it would be nice to duplicate this kind of functionality within ruby. What I've decided to do in the short term is to create the directory and then in that directory put the files that constitute the package. From this file, I then require the other files. For example: gplot (directory) Gnuplot.rb Stream.rb PlotItem.rb Where Gnuplot.rb contains the following lines require 'gplot/Stream' require 'gplot/PlotItem' This seems to be working fine, but my primary beefs with this that I have to include the gplot as part of the require path and in my client code I have to write require 'gplot/Gnuplot' instead of require 'gplot' which is what I really want. Any suggestions, comments, or flames? -- Gordon James Miller gmiller@bittwiddlers.com