Newbie question: Where to put library .rb files?

  • Thread starter Kenneth McDonald
  • Start date
K

Kenneth McDonald

At our site, newly started using Ruby, we're now starting to get code
we'd like to make generally available via 'require'. What is the
standard location/method for doing this? Can it be done in such a
manner that rdoc and ri documentation is made available to the site,
preferably integrated with the rest of the ruby docs on this site?

Thanks,
Ken McDonald
 
R

RichardOnRails

At our site, newly started using Ruby, we're now starting to get code  
we'd like to make generally available via 'require'. What is the  
standard location/method for doing this? Can it be done in such a  
manner that rdoc and ri documentation is made available to the site,  
preferably integrated with the rest of the ruby docs on this site?

Thanks,
Ken McDonald

The place you want is ruby\lib\ruby\site_ruby.

For example, I have my home-grown utility Search.rb stored there,
which defines a Search class. Then a Ruby program stored anywhere can
simply include:

require 'search' # case-insensitive on WinXP, e.g.
s = Seach.new # etc.

HTH,
Richard
 
J

Jeff Moore

Kenneth said:
At our site, newly started using Ruby, we're now starting to get code
we'd like to make generally available via 'require'. What is the
standard location/method for doing this? Can it be done in such a
manner that rdoc and ri documentation is made available to the site,
preferably integrated with the rest of the ruby docs on this site?

Thanks,
Ken McDonald

To see what your current config is set to cut-n-paste this into
irb:


puts "ruby load directories"
puts
$:.each do |e|
puts e
end


Since I work across a variety of platforms, I prefer to set the
RUBYLIB environment variable on each of my systems to a directory
of my choosing. This directory is added to load paths in $:
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top