[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

requiring external libraries directly

Mario Ruiz

12/20/2007 2:48:00 PM

I want to put all the external libraries I'm using in my project in a
folder and require directly from there instead of installing the gem in
ruby.

MyProject folder
ExternalLibraries folder
Watir
rexml
oci8
...
mycode requiring the libraries in ExternalLibraries if it's needed


Is that possible?
--
Posted via http://www.ruby-....

5 Answers

Mario Ruiz

12/21/2007 11:24:00 AM

0

Any idea???
--
Posted via http://www.ruby-....

Al Og

12/21/2007 11:54:00 AM

0

Mario Ruiz wrote:

> MyProject folder
> ExternalLibraries folder
> Watir
> rexml
> oci8
> ...
> mycode requiring the libraries in ExternalLibraries if it's needed
>

Just add following string into your code (before require statements)

$:.unshift File.join(File.dirname(__FILE__), "..", "ExternalLibraries
folder")
require ...

this will add ExternalLibraries folder to the ruby load path.

Regards,
arkadi4
--
Posted via http://www.ruby-....

Mario Ruiz

12/21/2007 3:00:00 PM

0

But I'll need the gem file in the external library folder or what??
--
Posted via http://www.ruby-....

Joel VanderWerf

12/21/2007 9:08:00 PM

0

Al Og wrote:
> $:.unshift File.join(File.dirname(__FILE__), "..", "ExternalLibraries
> folder")
> require ...

Suggestion:

Instead of:

File.dirname(__FILE__)

use this:

File.dirname(File.expand_path(__FILE__))

The protects you in case of Dir.chdir.

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

Eric Hodel

12/21/2007 9:23:00 PM

0

Don't trim context, we don't know what you're talking about when you
do that.

On Dec 21, 2007, at 06:59 AM, Mario Ruiz wrote:
>> I want to put all the external libraries I'm using in my project in a
>> folder and require directly from there instead of installing the
>> gem in
>> ruby.
>
> But I'll need the gem file in the external library folder or what??

If you're sourcing the files you want from gems, what's wrong with
using gems? It does everything you want without any extra hassle of
figuring out how to get your load path correct.