The author of the text book has created a library of modules called RubyLabs to support the tutorials and projects in the text book. These instructions describe how to enable the use of the RubyLabs modules for you andrew id user account. This will enable you to use the RubyLabs modules on the Gates Hall Cluster machines and when ssh'ing into unix.andrew.cmu.edu
Get a terminal logged in to a GHC machine or unix.andrew.cmu.edu.
At the command prompt, in the terminal, enter the command:
~vonronne/public/15110/bin/setup-rubylabs.sh
This will produce output similar to the following:
Setting up your Andrew account for RubyLabs... Modifying /afs/andrew.cmu.edu/usrXX/andrewid/.cshrc Creating a /afs/andrew.cmu.edu/usrXX/andrewid/.irbrc file loads rubylabs
Log out of the GHC/unix.andrew.cmu.edu system and, then, log back in.
Open a terminal with a command-line.
Run irb.
Ask Ruby to evaluate the expression Source (with a capital "S").
>> Source => RubyLabs::Source
If RubyLabs is not working, the result will look something like:
irb(main):001:0> Source NameError: uninitialized constant Source from (irb):1 from :0
This will likely not work if you did not first log out and log back in after running ~vonronne/public/15110/bin/setup-rubylabs.sh.
RubyLabs provides a Canvas object for graphical output. In addition, to irb needing to be able to find RubyLabs. RubyLabs will need to be able to find the X11 graphics subsystem. If you are at one of the machines in the Gates Hall Cluster, it should work. If you are accessing remotely, you will need to have X11 and ssh configured correctly (just like you do for running gedit remotely).
You can test the RubyLabs canvas by typing the following command in irb:
Canvas.init(300,300,"HelloWorld")
If everything is working correctly, a window with the title "RubyLabs::HelloWorld" will pop up.
Linux/UNIX allows file names to start with a dot, but these are considered special and are usually not displayed to the user. Many programs read from particular "dot files" in the user's home directory to configure themselves at startup. The ".cshrc" file is used by csh (which is the program that gives you the command line to type in your commands within the terminal); it contains a list of commands to be executed when the terminal is opened. The setup-rubylabs.sh program adds a line to .cshrc that creates an "enviornment variable" called RUBYLIB which gets passed into the irb program and tells irb an extra place to look for Ruby programs. It also creates a file .irbrc and makes a back up copy of any pre-existing file of that name. The file .irbrc contains commands that irb executes when it is started. The version it creates contains a command to automatically load the rubylabs module (from the place specified by the RUBYLIB enviornment variable).