Up-to-date hosting sample?

Hi!

I’m preparing an IronRuby article for a french newspaper, and would
like to demonstrate the hosting features (possibly to show how to
build a small dsl to script a C# application for instance).

I’m sitting on SVN at revision 68 but can’t get the wiki sample [1] to
compile - I believe the hosting stuff is currently under heavy
modification, right ?

Does anyone have an up-to-date hosting sample, or should I go back a
few revisions ?

cheers!

[1]
http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp

Thibaut Barrère

LoGeek
http://evolvingworker.com - tools for a better day
http://blog.logeek.fr - about writing software

You’re right. The Hosting API is currently under (re)construction.
Therefore the example is currently not so nice:

        IScriptEnvironment runtime = 

ScriptEnvironment.GetEnvironment();
IScriptEngine engine = IronRuby.GetEngine(runtime);
IScriptScope scope = engine.CreateScope();

        List<string> strings = new List<string>();
        strings.Add("one");
        strings.Add("two");
        IronRuby.GetExecutionContext(runtime).GlobalVariables[SymbolTable.StringToId("strings")] 

= strings;

        SourceUnit script = engine.CreateScriptSourceFromString(

@"
puts ““Hello World! There are #{$strings.count.to_s} strings:””
$strings.each_with_index { |s,i| puts “”#{i}: #{s}"" }
");
engine.Execute(scope, script);

It will get better soon.

Tomas

Hi Tomas,

thanks for your answer ! That will be nice enough :slight_smile:

Thibaut Barrère

LoGeek
http://evolvingworker.com - tools for a better day
http://blog.logeek.fr - about writing software

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs