Managing Environments for ruby apps

Hi all,

Over the last couple of years I have accumulated a fair amount of Ruby code across a couple of projects at work, and I have factored out several components into reusable libraries, although I haven't needed to turn them into gems yet. Each component looks like a standard library with subdirectories for lib and test. Lib has the code and test has the tests. I have rake files for running tests and various other subdirectories for support resources in the root of each component.

To manage the project dependencies, I setup a common config.rb then I call that from my application to fill the loadpath with the required libraries. This allows me to keep my various libraries and rb files portable by just adding in a require "config" and then simple "require"'s for any given dependencies in the class, without specifying path info in the require arg. It grew out of a desire for modularity as my scripts became applications and spanned multiple projects.

This simple step has made it easy to manage my various applications and my libraries on which they depend. I have also paid particular interest to how Rails manages its load path and environment. I am curious how others approach the issue of managing ruby projects that have dependencies on each other. I am sure there might be other clever ways to manage it without going all the way to using gems as that seems kind of heavy for internal projects that all share the same version control tree.

Thanks,
Bob Evans
http://www.junitfactory.com/
Send Java Get Junit

Robert Evans wrote:

Hi all,

Over the last couple of years I have accumulated a fair amount of Ruby code across a couple of projects at work, and I have factored out several components into reusable libraries, although I haven't needed to turn them into gems yet. Each component looks like a standard library with subdirectories for lib and test. Lib has the code and test has the tests. I have rake files for running tests and various other subdirectories for support resources in the root of each component.

To manage the project dependencies, I setup a common config.rb then I call that from my application to fill the loadpath with the required libraries. This allows me to keep my various libraries and rb files portable by just adding in a require "config" and then simple "require"'s for any given dependencies in the class, without specifying path info in the require arg. It grew out of a desire for modularity as my scripts became applications and spanned multiple projects.

This simple step has made it easy to manage my various applications and my libraries on which they depend. I have also paid particular interest to how Rails manages its load path and environment. I am curious how others approach the issue of managing ruby projects that have dependencies on each other. I am sure there might be other clever ways to manage it without going all the way to using gems as that seems kind of heavy for internal projects that all share the same version control tree.

Thanks,
Bob Evans
http://www.junitfactory.com/
Send Java Get Junit

If your file system supports symlinks, you can have something like this

$ export RUBYLIB=$HOME/ruby/lib:$RUBYLIB

and ruby/lib has links like this:

somelib -> ../somelib/lib/somelib
somelib-main-file.rb -> ../somelib/lib/somelib-main-file.rb

(Typically, I have two links for each project.)

This is assuming you keep your library project dirs in $HOME/ruby/ -- adjust as desired. (These are your checked-out working directories for the library prpjects.)

You can then require libraries in the usual way:

require 'somelib-main-file'
require 'somelib/extras'

Installed programs use exactly the same require calls to reference this library, assuming you either use the standard install.rb or follow the same convention.

The advantage is that you don't have to install locally when you are working on a particular project in order for other projects to use the latest version.

ยทยทยท

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407