Use as Lib

How can I use a specific directory as the lib along with ruby library
files???
can Any one reply me with class name or module name?

On 15/03/07, Purandhar sairam Mannidi [email protected] wrote:

How can I use a specific directory as the lib along with ruby library
files???
can Any one reply me with class name or module name?


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

If you’d like to include a directory into the path ruby searches for
files you can use the -I command line prompt. So to add a directory
called ‘lib’ you’d write
ruby -Ilib program.rb

Farrel

Farrel L. wrote:

On 15/03/07, Purandhar sairam Mannidi [email protected] wrote:

How can I use a specific directory as the lib along with ruby library
files???
can Any one reply me with class name or module name?


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

If you’d like to include a directory into the path ruby searches for
files you can use the -I command line prompt. So to add a directory
called ‘lib’ you’d write
ruby -Ilib program.rb

Farrel

Is there any way that we include in the script itself? like in “use
FindBin qw{$RealBin}; use lib $RealBin;” which will find the present
working directory and will include that in @ISA list.

Sairam

Alle giovedì 15 marzo 2007, Farrel L. ha scritto:

called ‘lib’ you’d write
ruby -Ilib program.rb

Farrel

Or you can manipulate the $: variable from within ruby. It’s an array
which
contains the paths ruby uses when looking for required files. So, if you
do

$: << ‘my_lib’

you can require a file contained in the directory my_lib with

require ‘my_file’

instead of using

require ‘my_lib/my_file’

I hope this helps

Stefano

Stefano C. wrote:

$: << ‘my_lib’
I prefere
$:.unshift ‘my_lib’
because this way the path ‘my_lib’ is prepended to the array and you can
be sure the file in this directory will be found even if another with
the same name exist somewhere else in the search path.

regards
Jan

On Mar 15, 7:37 am, Purandhar sairam Mannidi [email protected] wrote:

How can I use a specific directory as the lib along with ruby library
files???
can Any one reply me with class name or module name?


Posted viahttp://www.ruby-forum.com/.

To automatically require all files in a directory?
Some variation of the following might do the trick…

Dir.glob(‘./directory/*’).each do |lib|
require lib
end

Hope that helps.

Mully

Stefano C. wrote:

Or you can manipulate the $: variable from within ruby. It’s an array
which
contains the paths ruby uses when looking for required files. So, if you
do

$: << ‘my_lib’

you can require a file contained in the directory my_lib with

require ‘my_file’

instead of using

require ‘my_lib/my_file’

I hope this helps

Stefano

Thanks for the Help