Here is my implementation:
static void Main(string[] args)
{
var url = "http://www.google.com";
var engine = IronRuby.Ruby.CreateEngine();
var paths = new List<String>();
paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib");
paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby\1.8");
paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby");
paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\1.8");
engine.SetSearchPaths(paths);
engine.ExecuteFile("../../screenscraper.rb");
var obj =
engine.Runtime.Globals.GetVariable("ScreenScraper");
var screenScraper = engine.Operations.CreateInstance(obj);
var html = engine.Operations.InvokeMember(screenScraper,
"scrape", url);
Console.WriteLine(html);
}
And now it throws the following error:
Unhandled Exception: IronRuby.Builtins.LoadError: no such file to load
-- string
io
at
Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame
fram
e)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame
frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0
arg0, T1 a
rg1)
at IronRuby.Runtime.RubyScriptCode.Run(Scope scope, Boolean
bindGlobals)
at IronRuby.Runtime.RubyScriptCode.Run(Scope scope)
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink
errorSink)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope
scope)
at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path)
at IronRubyConsoleApp.Program.Main(String[] args) in
C:\Projects\ILoveIronRub
y\ILoveIronRuby\IronRubyConsoleApp\Program.cs:line 25
Press any key to continue . . .
Ivan Porto Carrero wrote:
> you might want to move the executefile method
>
> var url = "http://www.google.com.com";
>
> var engine = IronRuby.Ruby.CreateEngine();
>
>
> var paths = new List<String>();
> paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib");
>
> paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby\1.8");
> paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\site_ruby");
> paths.Add(@"C:\DevTools\ironruby-1.0-rc1\lib\ruby\1.8");
>
>
> engine.SetSearchPaths(paths);
>
>
> var obj =
> engine.Runtime.Globals.GetVariable("ScreenScraper");
> engine.ExecuteFile("../../screenscraper.rb");
> var screenScraper = engine.Operations.CreateInstance(obj);
>
> var html = engine.Operations.InvokeMember(screenScraper,
> "scrape", url);
>
> Console.WriteLine(html);
> ---
> Met vriendelijke groeten - Best regards - Salutations
> Ivan Porto Carrero - Mob: +32.486.787.582
> Web: http://whiterabbitconsulting.eu - http://flanders.co.nz
> Twitter: http://twitter.com/casualjim
> Author of IronRuby in Action (http://manning.com/carrero)
> Microsoft IronRuby/C# MVP
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core