IronShay

Ironing code, geek t-shirts and even presentations!

NAVIGATION - SEARCH

IronRuby, IronPython and DLR Daily Builds RSS Feed Is Available!

With the help of Harry Pierson (AKA DevHawk), there is an RSS feed that will notify you when a new nightly build is available!image 
The builds are daily and you get the latest versions of IronRuby, IronPython and the DLR in Silverlight or desktop versions.

So all of you early adapters, go ahead and subscribe to the feed!

Comment: the files in the feed are the built files, not the source code.

Enjoy,
Shay.

IronLanguages and Cross-Platformability

Most dynamic languages can run on multiple platforms. IronPython and IronRuby are no exception. The dev teams are investing lots of resources in order to make this happen because of the importance of this feature to the community.

IronPython and IronRuby can be run on top of Mono, which enables you to run .Net applications on top of different platforms, including Linux, BSD, Mac and more.

mono-gorilla

There are some great posts that show you how to do that:

Enjoy the cross-platformability! :)
Shay.

IronRuby Code Repository Changes

Starting from today, you will not get new updates from the IronRuby SVN code repository. The repository has been moved to github, and SubVersion has been replaced with Git.

If you want the source code, you’d need to adjust your code with the new changes.

If you don’t need the code, only the builds, you can now download the latest 0.2 version as a zip file (that contains the needed DLLs and batch files). Soon enough you’ll be able to download daily builds as well – so the need for the source code reduces or even disappears for those who only wish to work with IronRuby.

The 0.2 version, the daily builds (coming soon) and the links to the Git repository can be found on the download page at: http://www.ironruby.net/Download.

All the best,
Shay.

IronRuby.net Was Recently Updated With a Brand New IronRuby Logo!

The IronRuby.net site (the official IronRuby site) has recently changed it layout from a kind of childish layout to a slicker one.  The new layout comes with a new IronRuby logo! here it is:

ironrubylogoIt’s a nice and simple logo – stays true to its roots :)

Some other updates to the site – the Roadmap page has been updated and it now contains the “must-have” and “nice-to-have” items for the first release of IronRuby. Quite an interesting list, worth a look.

 

All the best,
Shay.

IronRuby Tip: Ruby String and ClrString

When you use IronRuby to execute some C# code, for example, and the C# code returns a string, pay  IronRuby Tip: Ruby String and ClrStringattention that the string is not a Ruby string!
The type of the object you receive is ClrString. ClrString is the equivalent of System.String in IronRuby, all the System.String methods will work on ClrString objects, but Ruby’s string methods will not (and vice versa).

For example:

clr_string = MyCSharpNameSpace::MyClass.ReturnString()

clr_string.IndexOf("something") # This will work
clr_string.EndsWith("something") # This will work

clr_string[0..2] # This will NOT work
clr_string.index("something") # This will NOT work

As you can see, the System.String methods work but the Ruby string methods don’t.

What to do?

If you want to use a System.String as a Ruby string, all you have to do is call to_s! just like that:

clr_string = MyCSharpNameSpace::MyClass.ReturnString()

clr_string = clr_string.to_s # Converting the ClrString to a Ruby string

clr_string[0..2] # This will WORK!
clr_string.index("something") # This will WORK!

Just to make clear – you will not be able to use System.String methods after the conversion to a Ruby string… One language at a time, folks, one language at a time :)

All the best,
Shay.

Getting Started With Dynamic Languages

I've grouped together some resources and blogs for all of you out there who are willing to start working with dynamic languages that are built on top of the DLR. Enjoy!

IronRuby IronRuby

Installation

Currently you'll have to get the code from the IronRuby SVN repository (svn://rubyforge.org/var/svn/ironruby  OR HTTP://ironruby.rubyforge.org/svn/trunk/) and build the project yourself.
Justin Etheredge has posted a step-by-step walk-through on his blog.

Resources

Recommended Blogs

IronPython IronPython

Installation

You can get the installer from the IronPython codeplex homepage: http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=8365

Resources

Recommended Blogs

IronScheme  IronScheme

 Installation

You can get the installer from: http://www.codeplex.com/IronScheme/Release/ProjectReleases.aspx?ReleaseId=14059

Resources

The Dynamic Language Runtime DLR - The Dynamic Language Runtime

There is no need to download the DLR code separately because it already comes with the installation of the other languages. If you want to write your own language on top of the DLR, this is the place to start for you.

Installation

You can get the binaries and the code from the codeplex homepage: http://www.codeplex.com/dlr/Release/ProjectReleases.aspx?ReleaseId=20378

Resources

Hope it helps,
Shay.

kick it on DotNetKicks.com

How to Debug and Run IronRuby Code From Visual Studio

This isn't a trivial thing to do until the IronRuby Visual Studio Integration component is out. So here are the steps in order to achieve that:

1. In Visual Studio, click on File-> Open -> Project/Solution

How to Debug and Run IronRuby Code From Visual Studio

2. Select ir.exe from the [IronRuby code directory]\trunk\build\debug (or release, depends on how you've compiled the code)

How to Debug and Run IronRuby Code From Visual Studio

3. Right click ir.exe in Solution Explorer and select Properties

How to Debug and Run IronRuby Code From Visual Studio

4. In Command Arguments, with "-D [path to code file]" where [path to code file] will be the full path to your ruby file.
For example, -D "c:\dev\IronRubyTest\test.rb".

How to Debug and Run IronRuby Code From Visual Studio

That's it! you can debug your IronRuby code file now!

image

This post was greatly inspired by the IronPython solution that was posted by Harry Pierson on his blog.

Enjoy,
Shay.

IronRuby Tip: Access .Net Indexers

The Problem

IronRuby Tip: Access .Net Indexers  Currently, if you have a .Net class you want to access via IronRuby, and you have an indexer there (like myObject[2]), you won't be able to use the indexer with brackets [] from IronRuby. You'll get an exception.

The Solution

Use get_Item(index) instead (pay attention to casing).

Example

my_dataset.Tables[0] # <-- This won't work
my_dataset.Tables.get_Item(0) # <-- This will work great!
All the best,
Shay.

Why IronRuby is AWSOME!

Yesterday I had to detach a folder from the SVN supervision. In order to do that, one needs to delete the .svn folders within the folder and its subfolders.
I decided to take advantage of IronRuby for that matter.

The problem I ran into with this one was that the files on the .svn folder were read-only. This means that in order to delete the folder, I first have to loop over all the files and remove their read-only attribute. I searched the net for a way to do that without such a loop and found a solution that used a WMI request.

IronRuby lets me take the benefit of the great System.Management class and use it in a Ruby script that I can write in no time.

Here is the code that I've ended up with:

____________________________________________________________________________________
require 'mscorlib'
require 'System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

def RemoveSvnFromDir(path)
    # loop over the files in the given path
    Dir.foreach(path) do |filename|
        current_dir = path + "\\" + filename

        # Ignore dot and double-dot.
        next if filename == "." || filename == ".."

        # If the file is the svn folder, remove it using WMI (no need to reset the read-only attributes)
        if filename == ".svn"
            begin
                puts "Removing #{current_dir}"
                dir = System::Management::ManagementObject.new("win32_Directory.Name='#{current_dir}'")
                dir.Get();
                dir.InvokeMethod("Delete", nil,nil);                
            rescue Exception => e
                puts e.to_s
            end
            next
        end
       
        # If this is a folder, recourse into it and detach it from SVN as well
        if File.directory?(current_dir)
            RemoveSvnFromDir(current_dir)
        end
    end
end

# Get the path from the command line and execute
dir_name = ARGV[0]
puts "Detaching SVN from #{dir_name}"
RemoveSvnFromDir(dir_name)
____________________________________________________________________________________

In order to run it, all that is needed is to open cmd and write "ir SVNCleaner.rb c:\MyCodeDirectory" (assuming that the script file is named SVNCleaner.rb).

This is just a small example of the great power that uniting .Net and dynamic languages can unleash, get ready for more!

Happy Succoth!
Shay.