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; }
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; }