Comrade
May 21st, 2005, 12:00 PM
This guide assumes you are on Windows, although you *nix users are probably smart enough to figure it out from the information I give here :p.
So you've downloaded the latest version of the Ruby Windows Installer (http://rubyforge.org/frs/?group_id=167) , and you're looking for a nice IDE to go with it - Notepad can only take you so far.
Fear not, for Eclipse (http://eclipse.org/) is here. Eclipse is originally a Java IDE, but it's a platform that we can get to work with almost any language, provided that you can write the plug-ins for it. But the nice thing about Eclipse is the simplicity of getting plug-ins. Chances are, someone already wrote the plug-in you want.
Enough talking; go and get Eclipse (http://eclipse.org/downloads/index.php)!
Make sure that you keep eclipse in C:\Eclipse - it won't work if the path to the application has spaces in it. This is weird problem, but a problem nonetheless.
So you should have Ruby installed to C:\Ruby (or wherever), and Eclipse installed to C:\Eclipse. Now we're ready to rock.
Run Eclipse. Go to Help - Software Updates - Find and Install.
Check off "Search for new features to install", it should be the bottom one.
Click on "New Remote Site". Under name, put any name, just so that you can remember it. Under URL, enter the following:
http://rubyeclipse.sf.net/updatesite
Now that it's in the list, check it off. Make sure "Eclipse Update Site" is not checked. Hit Next, then, in the list that follows, find the latest version of the Ruby Development Tools (at the bottom) and check it off. Then hit next again. Once it's installed, you need to restart Eclipse, so let it do that.
Go to Window - Preferences - Workbench - Perspectives. Make "Ruby" the default perspective. Get out of Preferences. You can always change the perspective easily at the top right hand corner of Eclipse. See? There are tabs that say "Ruby" and "Java".
Now, let's create an application. Go to new, then Ruby Project. Choose a project name, then you should see it loaded on the left hand side. Under Ruby Resources, right click on the folder with your project's name. Then New - File, and create a file with the extension .rb.
We still didn't tell Eclipse where the Ruby interpreter is, so let's do that now. Go to Window, Preferences, Ruby, then Installed Interpreters. Hit "Add", browse to your Ruby 'bin' directory (C:\Ruby\bin), then for the name say "Ruby.exe".
Go back to your screen, and make sure that your .rb file is in the editing window. Put in the following code:
def sayGoodnight(name)
result = "Goodnight, " + name
return result
end
# Time for bed...
puts sayGoodnight("John-Boy")
puts sayGoodnight("Mary-Ellen")
(Thanks to Programming Ruby (http://www.rubycentral.com/book/intro.html) for the code)
Now go to Run - Run As - Ruby Application, and there you go! It should run at the bottom.
Note that the bottom of the screen is like command prompt. Give console input there, and view console output there as well.
Congratulations - you're on your way to Ruby and Eclipse prowess!
So you've downloaded the latest version of the Ruby Windows Installer (http://rubyforge.org/frs/?group_id=167) , and you're looking for a nice IDE to go with it - Notepad can only take you so far.
Fear not, for Eclipse (http://eclipse.org/) is here. Eclipse is originally a Java IDE, but it's a platform that we can get to work with almost any language, provided that you can write the plug-ins for it. But the nice thing about Eclipse is the simplicity of getting plug-ins. Chances are, someone already wrote the plug-in you want.
Enough talking; go and get Eclipse (http://eclipse.org/downloads/index.php)!
Make sure that you keep eclipse in C:\Eclipse - it won't work if the path to the application has spaces in it. This is weird problem, but a problem nonetheless.
So you should have Ruby installed to C:\Ruby (or wherever), and Eclipse installed to C:\Eclipse. Now we're ready to rock.
Run Eclipse. Go to Help - Software Updates - Find and Install.
Check off "Search for new features to install", it should be the bottom one.
Click on "New Remote Site". Under name, put any name, just so that you can remember it. Under URL, enter the following:
http://rubyeclipse.sf.net/updatesite
Now that it's in the list, check it off. Make sure "Eclipse Update Site" is not checked. Hit Next, then, in the list that follows, find the latest version of the Ruby Development Tools (at the bottom) and check it off. Then hit next again. Once it's installed, you need to restart Eclipse, so let it do that.
Go to Window - Preferences - Workbench - Perspectives. Make "Ruby" the default perspective. Get out of Preferences. You can always change the perspective easily at the top right hand corner of Eclipse. See? There are tabs that say "Ruby" and "Java".
Now, let's create an application. Go to new, then Ruby Project. Choose a project name, then you should see it loaded on the left hand side. Under Ruby Resources, right click on the folder with your project's name. Then New - File, and create a file with the extension .rb.
We still didn't tell Eclipse where the Ruby interpreter is, so let's do that now. Go to Window, Preferences, Ruby, then Installed Interpreters. Hit "Add", browse to your Ruby 'bin' directory (C:\Ruby\bin), then for the name say "Ruby.exe".
Go back to your screen, and make sure that your .rb file is in the editing window. Put in the following code:
def sayGoodnight(name)
result = "Goodnight, " + name
return result
end
# Time for bed...
puts sayGoodnight("John-Boy")
puts sayGoodnight("Mary-Ellen")
(Thanks to Programming Ruby (http://www.rubycentral.com/book/intro.html) for the code)
Now go to Run - Run As - Ruby Application, and there you go! It should run at the bottom.
Note that the bottom of the screen is like command prompt. Give console input there, and view console output there as well.
Congratulations - you're on your way to Ruby and Eclipse prowess!