- Overview
- Installing IronRuby
- Executables and Tools
- Development Environments
- The Power of IronRuby
- Summary
Development Environments
Support for IronRuby in Visual Studio is not available in IronRuby 1.0. Such support is not in Microsoft's current plans, and no one can really promise it will be in the near future.
However, the Ruby language already has several IDEs available. This section discusses some of them so that you can choose the one that best fits your needs.
Ruby in Steel
This commercial add-on to Visual Studio by SapphireSteel makes developing Ruby applications inside Visual Studio much more natural. It adds new Ruby project types, intellisense, code snippets, and syntax highlighting.
Figure 4.7 is a screenshot from Visual Studio that shows the syntax highlighting and intellisense capabilities of Ruby in Steel.
Figure 4.7 Ruby in Steel syntax highlighting and intellisense.
Although you cannot run IronRuby with Ruby in Steel out of the box, it is possible to alter the solution settings to execute ir.exe. Follow these steps to do so:
- Inside Visual Studio, click Project > Project Settings.
In the Settings window, you see a Ruby region with a "Ruby Interpreter" line. Change the value on this line to the path of ir.exe.
For example, if you installed IronRuby in C:\IronRuby, you must set the value to "C:\IronRuby\Bin\ir.exe".
- Save the project and press Ctrl + F5 to execute the Ruby files.
Ruby in Steel is a commercial product that costs money. It supports Visual Studio 2005, 2008, and also machines without Visual Studio at all (uses the Visual Studio Shell).
To read more about it, try it, or buy it, visit http://www.sapphiresteel.com/Ruby-In-Steel-Developer-Overview.
NetBeans
NetBeans is a free, open source IDE that supports several programming languages, along with the Ruby language. It is Java-based and can run on all operating systems that run Java applications.
For Ruby, you get code completion, naming convention warnings, a convenient project tree, and Ruby on Rails support.
Figure 4.8 shows the NetBeans window with Ruby code inside.
Figure 4.8 NetBeans IDE screenshot with Ruby code.
Unfortunately, NetBeans in its current version 6.7 doesn't support IronRuby. Therefore, you cannot run or debug IronRuby code directly from NetBeans. You must run the IronRuby file from the command prompt using ir.exe.
The NetBeans team plans to add IronRuby to its supported Ruby platforms in one of its next versions.
To learn more about NetBeans and download it, visit http://www.netbeans.org.
RubyMine
RubyMine is a commercial Ruby IDE by JetBrains. This is one of the most advanced Ruby IDEs available and features project creation wizards, syntax highlighting, code tools (like a "surround with" function), intellisense, refactoring, and version control system integration.
Figure 4.9 shows the RubyMine interface and its intellisense pop-up.
Figure 4.9 RubyMine IDE screenshot with intellisense.
RubyMine doesn't come with IronRuby as its Ruby interpreter, and you have to add it as one to execute files with the IronRuby interpreter directly from the interface.
Follow these steps to add IronRuby as a Ruby interpreter in RubyMine:
- Go to File > Settings.
- On the left, choose Ruby SDKs and Gems.
- On the settings on the right, click the Add SDK button, which is located in the upper-right corner of the dialog.
- On the file selector dialog that opens, navigate to <IronRuby installation folder>\Bin\ir.exe. Click OK after you select the file.
- When you click OK on the settings form, RubyMine makes IronRuby its default interpreter.
Before you run a file, you need to modify something else. RubyMine uses configuration settings for each execution. In this configuration, the command-line arguments are sent to the interpreter. The default ones do not work with IronRuby, and you need to remove them. Follow these steps to do that:
- Go to Run > Edit Configurations.
- Click the Edit Defaults button, which is located in the lower-left corner of the dialog.
- Choose Ruby on the left panel.
- On the right, clear the text from the Ruby Arguments field.
- Click OK on all open dialogs to save the changes.
Now you can work on and run files by using the IronRuby interpreter.
RubyMine is a commercial product that costs money. It works on Windows, Mac OS X, and Linux. You can read more about it, try it, and buy it at http://www.jetbrains.com/ruby.
Others
Along with these IDEs, a lot of other great IDEs are available. Some are appropriate for bigger applications, and some for smaller applications and scripts. Most of them offer simple code completion and syntax highlighting.
Like the others, they still cannot run IronRuby directly from their interface, so you have to switch to the command prompt and use ir.exe to run the Ruby file you've been working on.
Some of these IDEs are RadRails (http://www.aptana.com/radrails), SciTE (http://www.scintilla.org/SciTE.html), and Notepad++ (http://notepad-plus.sourceforge.net). Search the Internet for "Ruby IDEs" to find more Ruby IDEs.