views:

37

answers:

2

I have a finished Ruby project that has the standard structure for a multiple file Ruby program:

project/
     lib/ # Files the driver program uses go here.
     bin/ # Driver program goes here.
     tests/ # Unit tests go here.

What I want to be able to do is type in project into the command line from any directory and have my program run (which means it needs to be in my $PATH). My question is how do I do add a multiple file Ruby project to my PATH so that I can call by name in the terminal? (Or perhaps my approach is wrong, and I should do something else like make it into a Gem? I just don't know what is normally done).

+1  A: 

You could go the quick and dirty route, and write a bash script that calls your main function to run the project, and then stick the bash script over in /usr/bin.

Andrew
I like the idea of having a bash script - I dislike the idea of dumping things unnecessarily in /usr/bin, a better idea would be to create the bash script in /opt or /usr/local/bin or else in your home dir and edit your path via ~/.bashrc/ /usr/bin is for your distribution to edit.
Ninefingers
+1  A: 

package it as a gem and install that gem. If not and you're on linux then you can set your shebang line to be the right ruby, and chmod to make your script executable, and add your bin dir to your path (or what not).

rogerdpack