Wednesday, June 16, 2010 4:34 PM Kazi Manzur Rashid

Start Learning Ruby with IronRuby – Setting up the Environment

Recently I have decided to learn Ruby and for last few days I am playing with IronRuby. Learning a new thing is always been a fun and when it comes to adorable language like Ruby it becomes more entertaining.

Like any other language, first we have to create the development environment. In order to run IronRuby we have to download the binaries form the IronRuby CodePlex project. IronRuby supports both .NET 2.0 and .NET 4, but .NET 4 is the recommended version, you can download either the installation or the zip file. If you download the zip file make sure you added the bin directory in the environment path variable. Once you are done, open up the command prompt and type :

ir –v

It should print message like:

IronRuby 1.0.0.0 on .NET 4.0.30319.1

The ir is 32bit version of IronRuby, if you want to use 64bit you can try ir64.

Next, we have to find a editor where we can write our Ruby code as there is currently no integration story of IronRuby with Visual Studio like its twin Iron Python. Among the free IDEs only SharpDevelop has the IronRuby support but it does not have auto complete or debugging built into it, only thing that it supports is the syntax highlighting, so using a text editor which has the same features is nothing different comparing to it. To play with the IronRuby we will be using Notepad++, which can be downloaded from its sourceforge download page. The Notepad++ does have a nice syntax highlighting support :

npplusplus-ruby

I am using the Vibrant Ink with some little modification.

The next thing we have to do is configure the Notepad++ that we can run the Ruby script in IronRuby inside the Notepad++. Lets create a batch(.bat) file in the IronRuby bin directory, which will have the following content:

@echo off 
cls
call ir %1
pause

This will make sure that the console will be paused once we run the script.

Now click Run->Run in the Notepad++, it will bring up the run dialog and put the following command in the textbox (The riir.bat is the batch file which we have saved in the above):

riir.bat "$(FULL_CURRENT_PATH)"

npplusplus-ruby-run

Click the save which will bring another dialog.

Type Iron Ruby and assign the shortcut to ctrl + f5 (Same as Visual Studio Start without Debugging) and click ok.

npplusplus-ruby-shortcut

Once you are done you will find the IronRuby in the Run menu. Now press ctrl + f5, we will find the ruby script running in the IronRuby.

npplusplus-ruby-output

Now there are one last thing that we would like to add which is poor man’s context sensitive help. First, download the ruby language help file from the Ruby Installer site and extract into a directory. Next we will have to install the Language Help Plug-in of Notepad++, click Plugins->Plugin Manger –>Show Plugin Manager and scroll down until you find the plug-in the list, now check the plug-in and click install. Once it is installed it will prompt you to restart the Notepad++, click yes.

npplusplus-ruby-plugin

When the Notepad++ restarts, click the Plugins –> Language Help –> Options –> add and enter the following details and click ok:

npplusplus-ruby-help

The chm file location can be different depending upon where you extracted it.

Now when you put your in any of ruby keyword and press ctrl + f1 it will take you to the help topic of that keyword.

For example, when my caret is in the each of the following code and I press ctrl + f1, it will take me to the each api doc of Array.

def loop_demo
	(1..10).each{ |n| puts n}
end

loop_demo

That’s it for today.

Happy Ruby coding.

Shout it
Filed under: , ,

Comments

# Start Learning Ruby with IronRuby – Setting up the Environment - Kazi Manzur Rashid

Wednesday, June 16, 2010 5:39 AM by DotNetShoutout

Thank you for submitting this cool story - Trackback from DotNetShoutout

# re: Start Learning Ruby with IronRuby – Setting up the Environment

Wednesday, June 16, 2010 6:28 AM by varun

Great Article Kazi bhai...and I really appreciate the inside of configuring Notepad++, I might wanna try doing same for Iron Python as well as for normal (c) python... I mean IDLE is good but not good enough :).

Will be watching out some great new MVC and Ruby on Rails article from you....

Cheers!

# Twitter Trackbacks for Start Learning Ruby with IronRuby ??? Setting up the Environment - Kazi Manzur Rashid's Blog [asp.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 Start Learning Ruby with IronRuby ??? Setting up the Environment - Kazi Manzur Rashid's Blog         [asp.net]        on Topsy.com

# re: Start Learning Ruby with IronRuby – Setting up the Environment

Wednesday, June 16, 2010 7:30 AM by Kazi Manzur Rashid

@varun : Can't promise on RoR, but you will definitely find something on Rake, RSpec and maybe Cucumber and also ASP.NET MVC + IronRuby.

# Начинаем изучение Ruby с IronRuby – установка окружения

Wednesday, June 16, 2010 7:42 AM by progg.ru

Thank you for submitting this cool story - Trackback from progg.ru

# re: Start Learning Ruby with IronRuby – Setting up the Environment

Wednesday, June 16, 2010 5:46 PM by Denny Ferrassoli

And just to throw it out there, "Mr. Neighborly's Humble Little Ruby Book" is a great way to start learning, especially if you're new to Ruby like me.

The PDF is available here:

www.humblelittlerubybook.com/.../hlrb.pdf

# Links from Twitter

Wednesday, June 16, 2010 11:36 PM by Vagif Abilov's blog on .NET

Software architecture - 5 years later by Arnon Rotem-Gal-Oz Waterfall, Lean/Kanban, and Scrum by Ken

# re: Start Learning Ruby with IronRuby – Setting up the Environment

Thursday, June 17, 2010 2:59 AM by Kazi Manzur Rashid

Thanks Denny for the Ruby Book link.

# Start Learning Ruby with IronRuby ? Setting up the Environment - Kazi Manzur Rashid

Thursday, June 17, 2010 11:18 PM by iAwaaz-News-by-People

Thank you for submitting this cool story - Trackback from iAwaaz-News-by-People

# Write your Tests in RSpec with IronRuby

Friday, June 18, 2010 11:18 AM by Kazi Manzur Rashid's Blog

[Note: This is not a continuation of my previous post , treat it as an experiment out in the wild. ]

# Start Learning Ruby with IronRuby ??? Setting up the Environment … | Neorack Tutorials

Pingback from  Start Learning Ruby with IronRuby ??? Setting up the Environment … | Neorack Tutorials

# re: Start Learning Ruby with IronRuby – Setting up the Environment

Sunday, June 27, 2010 6:15 PM by Corey

Another good option is to use RubyMine. It works fine with IronRuby.

# re: Start Learning Ruby with IronRuby – Setting up the Environment

Sunday, June 27, 2010 7:00 PM by Kazi Manzur Rashid

@Corey: True, In fact I do have a license of RubyMine, but as it is a commercial product ($99 and it is very reasonable considering the features) I kept it out of the scene.

# How to compile RoR code in Notepad++? | Hardware Infomation and Computer Tutorials

Pingback from  How to compile RoR code in Notepad++? | Hardware Infomation and Computer Tutorials

# ruby and me | Yes I am copying you

Saturday, July 23, 2011 11:26 AM by ruby and me | Yes I am copying you

Pingback from  ruby and me | Yes I am copying you

# How to compile RoR code in Notepad++? - Programmers Goodies

Wednesday, September 28, 2011 10:00 PM by How to compile RoR code in Notepad++? - Programmers Goodies

Pingback from  How to compile RoR code in Notepad++? - Programmers Goodies