public string CompileSass(string input, SassMode mode) { var srs = new ScriptRuntimeSetup() { HostType = typeof(ResourceAwareScriptHost) }; srs.AddRubySetup(); var runtime = Ruby.CreateRuntime(srs); var engine = runtime.GetRubyEngine(); engine.SetSearchPaths(new List <string> { @"R:\lib\ironruby", @"R:\lib\ruby\1.9.1" }); var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SquishIt.Sass.lib.sass_in_one.rb"), SourceCodeKind.File); var scope = engine.CreateScope(); source.Execute(scope); dynamic sassMode = mode == SassMode.Sass ? engine.Execute("{:syntax => :sass}") : engine.Execute("{:syntax => :scss}"); var sassEngine = scope.Engine.Runtime.Globals.GetVariable("Sass"); return((string)sassEngine.compile(input, sassMode)); }
public void RubyHosting5() { // app-domain creation: if (_driver.PartialTrust) { return; } AppDomain domain = AppDomain.CreateDomain("foo"); var rs = ScriptRuntimeSetup.ReadConfiguration(); LanguageSetup ls = rs.GetRubySetup(); Debug.Assert(ls.Names.IndexOf("IronRuby") != -1); var newSetup = new ScriptRuntimeSetup(); newSetup.AddRubySetup((s) => { s.Options["LibraryPaths"] = ls.Options["LibraryPaths"]; }); ScriptRuntime runtime = ScriptRuntime.CreateRemote(domain, newSetup); ScriptEngine engine = runtime.GetRubyEngine(); Assert(engine.RequireFile("fcntl") == true); Assert(engine.Execute <bool>("Object.constants.include?(:Fcntl)") == true); }
protected override ScriptRuntime /*!*/ CreateRuntime() { var setup = new ScriptRuntimeSetup(); setup.AddRubySetup(); return(_factory.CreateRuntime(setup)); }
public MainPage() { this.InitializeComponent(); var setup = new ScriptRuntimeSetup(); setup.HostType = typeof(DlrHost); setup.AddRubySetup(); var runtime = Ruby.CreateRuntime(setup); this.engine = Ruby.GetEngine(runtime); this.scope = engine.CreateScope(); this.scope.SetVariable("Main", this); runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly); runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly); runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly); string outputText = @" box = main.find_name('OutputBox') p box.text_alignment box.text_alignment = Windows::UI::Xaml::TextAlignment.Right p box.text_alignment "; InputBox.IsSpellCheckEnabled = false; OutputBox.IsSpellCheckEnabled = false; InputBox.Document.SetText(TextSetOptions.None, outputText); }
protected virtual ScriptRuntime /*!*/ CreateRuntime() { ScriptRuntimeSetup setup = new ScriptRuntimeSetup(); setup.AddRubySetup(); setup.DebugMode = true; return(Ruby.CreateRuntime(setup)); }
public MainPage() { this.InitializeComponent(); var setup = new ScriptRuntimeSetup(); setup.HostType = typeof(DlrHost); setup.AddRubySetup(); var runtime = Ruby.CreateRuntime(setup); this.engine = Ruby.GetEngine(runtime); this.scope = engine.CreateScope(); this.scope.SetVariable("Main", this); runtime.LoadAssembly(typeof(object).GetTypeInfo().Assembly); runtime.LoadAssembly(typeof(TextSetOptions).GetTypeInfo().Assembly); runtime.LoadAssembly(typeof(TextAlignment).GetTypeInfo().Assembly); string outputText = @" box = main.find_name('OutputBox') p box.text_alignment box.text_alignment = Windows::UI::Xaml::TextAlignment.Right p box.text_alignment "; InputBox.IsSpellCheckEnabled = false; OutputBox.IsSpellCheckEnabled = false; InputBox.Document.SetText(TextSetOptions.None, outputText); // http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx IInspectable insp = (IInspectable)InputBox.Document; string winTypeName; insp.GetRuntimeClassName(out winTypeName); Guid[] iids; int iidCount; insp.GetIids(out iidCount, out iids); // winTypeName = "Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IMapView`2<Windows.Foundation.Collections.IVector`1<String>, String>>"; var parts = ParseWindowsTypeName(winTypeName); Type type = MakeWindowsType(parts); var guid = type.GetTypeInfo().GUID; }
void Initialize() { if (initialized) { return; } pal = new CassettePlatformAdaptationLayer(new ResourceRedirectionPlatformAdaptationLayer(), RootDirectory); var srs = new ScriptRuntimeSetup { HostType = typeof(SassCompilerScriptHost), HostArguments = new List <object> { pal }, }; srs.AddRubySetup(); var runtime = Ruby.CreateRuntime(srs); engine = runtime.GetRubyEngine(); // NB: 'R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}' is a garbage path that the PAL override will // detect and attempt to find via an embedded Resource file engine.SetSearchPaths(new List <string> { @"R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}\lib\ironruby", @"R:\{345ED29D-C275-4C64-8372-65B06E54F5A7}\lib\ruby\1.9.1" }); var source = engine.CreateScriptSourceFromString( Utility.ResourceAsString("lib.sass_in_one.rb", typeof(SassAndCoffee.Ruby.Sass.SassCompiler)), SourceCodeKind.File); scope = engine.CreateScope(); source.Execute(scope); sassCompiler = scope.Engine.Runtime.Globals.GetVariable("Sass"); sassOption = engine.Execute("{:cache => false, :syntax => :sass}"); scssOption = engine.Execute("{:cache => false, :syntax => :scss}"); initialized = true; }
/// <summary> /// Initializes the Ruby engine. /// </summary> private void Initialize() { if (initialized) { return; } ResourceAwarePlatformAdaptationLayer resourceAwarePlatform = new ResourceAwarePlatformAdaptationLayer(); ScriptRuntimeSetup srs = new ScriptRuntimeSetup { HostType = typeof(ResourceAwareScriptHost), HostArguments = new List <object> { resourceAwarePlatform } }; srs.AddRubySetup(); ScriptRuntime runtime = Ruby.CreateRuntime(srs); engine = runtime.GetRubyEngine(); engine.SetSearchPaths(new List <string> { @"R:\Resources\ironruby", @"R:\Resources\ruby\1.9.1" }); string resouce = Utils.ResourceAsString("Cruncher.Preprocessors.Sass.Resources.sass_in_one.rb"); ScriptSource source = engine.CreateScriptSourceFromString(resouce, SourceCodeKind.File); scope = engine.CreateScope(); source.Execute(scope); sassEngine = scope.Engine.Runtime.Globals.GetVariable("Sass"); initialized = true; }