"The naming integration with .NET is persnickety at best. The C# Wesabe client had a lowercase class called "wesaberest" that IronRuby just couldn't see, so I changed it to uppercase and aliased it with a constant."
The post is from summer 2007, but could it be that the bug still exists?
I intended to do some ruby-labs, here's a couple of things I thought of experimenting with. Maybe you have already?
How does importing ruby libraries work? Is that well handled by the macro engine? (For Python it isnt because the path to /python arent setup as it should).
How do you sort and filter an array like that in Ruby? find_all sort_by ?
# The template. Notice the single quotes around this string to delay
# evaluation.
template = 'Dear #{customer},\nPlease pay us #{amount} now.\n'
# The "replacement" values.
customer = "Joe Schmoe"
amount = sprintf( "$%0.2f", 250 )
# Evaluate the string using eval, which will use the "replacement" values
# from the local context.
print eval( '"' + template + '"' )
Cool, importing a class-file worked almost oob. Just needed to add a path to the python-folder in \config\scripting.config (should come with the installation imho, will add that to codeplex):
The Umbraco macro-engine gracefully gives us the currentPage object. ERB included in Ruby standard libraries and is necessary to download and include in the Ruby configuration file. But thats done i 5 minutes.
Get version 1.8.7 (IronRuby targets 1.8x). Extract it to somewhere, like c:\Ruby187 and change /config/scripting.config so that the librarypaths setting has the right paths:
I jump into this again as my "ERB"-import advide could be misleading for some - there's no real need for it as I see %Q is a built in nice way to mix html with code:
IronRuby and Umbraco
Has anyone successfully managed to create a Node object in a IronRuby script?
I know it works in Python by doing "x = Node(-1)", but I cannot get it to work in Ruby. It just gives the following error:
Hi there,
the first thing that jumps out at me is
Error loading python script
Is it definitely being executed by IronRuby ?
J
Yes. Here is the full stacktrace:
@Jay - I think that's just cuz the macro engines error messages aren't very smart :P
@Ove - Have you got an include for the NodeFactory API in your file? Can you post your whole file?
Here you go:
You might need to do a specific namespace import, cuz Node is at umbraco.presentation.nodeFactory.
I know you have to do that with IronPython (which I use so I'm not the best person for IronRuby help :P)
Tried adding the following line below "require ..." , but it didn't work.
Here is the new error message:
Ok. Found the following quote from Scott Hanselman:
"The naming integration with .NET is persnickety at best. The C# Wesabe client had a lowercase class called "wesaberest" that IronRuby just couldn't see, so I changed it to uppercase and aliased it with a constant."
The post is from summer 2007, but could it be that the bug still exists?
With the above knowledge in mind, I found the following article: http://ironshay.com/post/Working-with-NET-Lowercase-Namespaces-and-Classes-in-IronRuby.axsp
And I got it working!
EDIT: It seems the "require ... " line was not needed, so I removed it.
Fun!
I intended to do some ruby-labs, here's a couple of things I thought of experimenting with. Maybe you have already?
How does importing ruby libraries work? Is that well handled by the macro engine? (For Python it isnt because the path to /python arent setup as it should).
How do you sort and filter an array like that in Ruby? find_all sort_by ?
I read some about built in template system, which seems very useful: http://freshmeat.net/articles/templates-in-ruby
Cool, importing a class-file worked almost oob. Just needed to add a path to the python-folder in \config\scripting.config (should come with the installation imho, will add that to codeplex):
test.rb:
test2.rb:
I never played with Ruby before. Interesting that it requires some conventions, like capitalizing class-names, otherwise it wont save.
Playtime continues. Filter with filter_by and sorting with sort_by works fine:
Sweet! Here is one that filters out hidden nodes:
Starting to like Ruby :) But needs .Value + nil-check, right? does it work like python?:
Using Ruby standard templating engine ERB it's possible to create stuff like:
The Umbraco macro-engine gracefully gives us the currentPage object. ERB included in Ruby standard libraries and is necessary to download and include in the Ruby configuration file. But thats done i 5 minutes.
And here's a recursive (multi-level) example:
changing <%= PrintChildrenRecursively(currentPage) %> to call with a root node we have a full sitemap.
Small note about getting ERB to run:
The Ruby-libraries are here : http://www.ruby-lang.org/en/downloads/
Get version 1.8.7 (IronRuby targets 1.8x). Extract it to somewhere, like c:\Ruby187 and change /config/scripting.config so that the librarypaths setting has the right paths:
I jump into this again as my "ERB"-import advide could be misleading for some - there's no real need for it as I see %Q is a built in nice way to mix html with code:
www.aaron-powell.com/umbraco-menu-with-ironruby
see also this thread for more %Q samples
http://our.umbraco.org/forum/developers/extending-umbraco/16412-IronRuby,-Umbraco-461,-and-Library-methods
Kudos to Slace, Chriztian and Ted
is working on a reply...