Best practice? own libs

P

Patrick Gundlach

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
 
T

Trans

Patrick said:
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?

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 (http://i.loveruby.net/en/projects/setup/), or
use the ruby-specific package manager, RubyGems.

HTH.

trans
 
E

Eric Hodel

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?

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.
 
P

Patrick Gundlach

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top