Sunday, October 30, 2011

Exercise 0: The Setup: Learn Ruby the Hard Way: Practicum


So I have two systems that I can play with on this, Mac and PC. Since the Mac version has some limitations that I can't really get around (I have to keep certain versions of the app at the versions installed since I'm runnning an active testing environment in Ruby 1.8), for this challenge I'll be using Windows and using the Ruby Version Manager to install the app.

The first step is to go and get the "gedit" text editor. Why gedit? Because it has little in the way of extra help beyond spelling and language support.

There are some basic tweaks we can make to gedit once we have downloaded the editor, such as setting the tab to 2 spaces, inserting spaces instead of tabs when hitting the tab key, and making it so that the line number is visible. Other than that, there is little in the way of the cool tools that many of the IDE applications have. To tell the truth, I really am starting to like some of the features in RubyMine that I've played with. For these practicum posts, we shall be doing this with the preferred editor (all things being equal).

Here's the steps straight from the Learn Ruby the Hard Way site:

- In your Terminal program, run irb (Interactive Ruby). You run things in Terminal by just typing their name and hitting RETURN.

- Hit CTRL-Z (Z), Enter and get out of irb (actually, it doesn't work this way on my command prompt. typing "exit" or "quit" does exit irb).

- Learn how to make a directory in the Terminal. Search online for help (mkdir LRtHW)

- Learn how to change into a directory in the Terminal. Again search online (cd LRtHW).

- Use your editor to create a file in this directory. Make the file, "Save" or "Save As...", and pick this directory (heh, I edited this blog post in the editor, see below :) ).

- Go back to Terminal using just the keyboard to switch windows. Look it up if you can't figure it out (alt-tab and the arrow keys :) ).

- Back in Terminal, see if you can list the directory to see your newly created file. Search online for how to list a directory. (dir, and there it is :) ).

Warning: Windows is a big problem for Ruby. Sometimes you install Ruby and one computer will have no problems, and another computer will be missing important features. If you have problems, please visit: http://rubyinstaller.org/ (So far so good!)

Ta-daa!!!

OK, admittedly, that was not a big deal, but for many just getting the stuff installed can be a big deal and a challenge if they are not used to packages and gems and running the Ruby Installer, but once it's downloaded, then you have a lot of flexibility in how you can use the tools. As stated, though, I'm going to be as literal as I can be, and you will see the literal details as I see them and as I work with them. If I get stumped, I'll say so. If something doesn't work the same way, I'll say so. Tomorrow, some very rudimentary code, done in the spirit and in the system Zed recommends. My pledge is to do this by the book, and therefore, that's what I'm going to do :).

2 comments:

Cheryl said...

Hi,

I'm working on a Mac and when I enter run irb from the terminal command line I get an error message:

-bash: run: command not found

What does this mean? I thought Ruby was preinstalled. How can I check?

Thank You
Cheryl

Michael Larsen said...

Hi Cheryl,

the first thing to do is to see if your system sees that Ruby is installed. open your terminal window and type "which ruby". If you get a full path back to the executable, then you know it's installed. Also, you can type "ruby -v" at the command prompt to see your Ruby version. If neither of those work, then you may need to add the path where the Ruby executable resides in your PATH environment variable (type "echo $PATH to see what is there. If the path to your Ruby executable isn't listed, edit your shell profile file and add it :) ).