Best practice? own libs

Hi,

I’d like to ask you for your recommendations. I
develop (privately) a set of libraries which are used in several
projects. Some of these I also want to share with others (i.e.
distribute). When developing I use a directory structure such as

lib/ <— libraries here
test/ <— tests

Now, when using the library from another project I either need to

  1. put the above lib directory in $:, the search path
  2. copy the needed libs to the project
    or
  3. install the library in a system wide/private directory structure
    and set the environment variable RUBYLIB.

Of course I would always like to use the newest version of a lib.

What do you guys recommend? Symlinks?

Patrick

most noteably setup.rb (setup.rb), or
use the ruby-specific package manager, RubyGems.

Go for RubyGems. They’re simple to generate and even simpler to use. I
am
in a similar situation that you describe with some private libs and
found
it best to package them into backofficegems hosted on rubyforge.

Patrick G. wrote:

What do you guys recommend? Symlinks?

Depends on your needs. But #1 and #3 aren’t portable. #2 is the right
choice hwne you don;t want to have you lib dependent on the
installation of another lib. In those cases I put the code in:
lib/vendor/, although I’ve seen other use lib/support/.

The 4th option, which is the typical general approach --the one for whn
it’s okay to have an external dependency, is to install the library to
the a standard location. The $LOAD_PATH is already set to search these
locations depending on you Ruby installation. For instance, on Debian
the location is /usr/local/lib/site_ruby/1.8/. But really you don’t
have to worry about that yourself if you just use an install script,
most noteably setup.rb (setup.rb), or
use the ruby-specific package manager, RubyGems.

HTH.

                                             trans

On Aug 27, 2006, at 12:50 AM, Patrick G. wrote:

  1. put the above lib directory in $:, the search path
  2. copy the needed libs to the project
    or
  3. install the library in a system wide/private directory structure
    and set the environment variable RUBYLIB.

Of course I would always like to use the newest version of a lib.

What do you guys recommend? Symlinks?

ruby -I in your rake/make testing rule.

If the directories don’t exist ruby won’t care and it’ll use
installed versions.

If they do, they’ll be picked up before gems/site_lib.


Eric H. - [email protected] - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Hello,

thanks all for your suggestions. I think that I go for changing $: for
tests and running ‘setup’ before using the library from other
applications. That way I don’t have to copy anything. But I have to
remember running ‘setup’ or rake… after my tests run ok.

Patrick