[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Best practice? own libs

Patrick Gundlach

8/27/2006 7:50:00 AM

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

--
Posted via http://www.ruby-....

4 Answers

Trans

8/27/2006 8:12:00 AM

0


Patrick Gundlach wrote:
> 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/proje...), or
use the ruby-specific package manager, RubyGems.

HTH.

trans

Jon Egil Strand

8/27/2006 9:16:00 PM

0

Eric Hodel

8/28/2006 11:31:00 PM

0

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

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

--
Eric Hodel - drbrain@segment7.net - http://blog.se...
This implementation is HODEL-HASH-9600 compliant

http://trackmap.rob...



Patrick Gundlach

8/30/2006 11:46:00 AM

0

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

--
Posted via http://www.ruby-....