Exemplo n.º 1
0
        static SassFileCompiler()
        {
            _sassModule = new TrashStack<SassModule>(() => {
                var srs = new ScriptRuntimeSetup() {
                    HostType = typeof (ResourceAwareScriptHost),
                    //DebugMode = Debugger.IsAttached
                };
                srs.AddRubySetup();
                var runtime = Ruby.CreateRuntime(srs);
                var engine = runtime.GetRubyEngine();

                // NB: 'R:\' is a garbage path that the PAL override below will
                // detect and attempt to find via an embedded Resource file
                engine.SetSearchPaths(new[] {@"R:/lib/ironruby", @"R:/lib/ruby/1.9.1"});

                var source = engine.CreateScriptSourceFromString(Utility.ResourceAsString("SassAndCoffee.Core.lib.sass_in_one.rb"), "R:/lib/sass_in_one.rb", SourceCodeKind.File);
                var scope = engine.CreateScope();
                source.Execute(scope);
                return new SassModule {
                    PlatformAdaptationLayer = (VirtualFilePAL)runtime.Host.PlatformAdaptationLayer,
                    Engine = scope.Engine.Runtime.Globals.GetVariable("Sass"),
                    SassOption = engine.Execute(@"{:syntax => :sass, :cache_location => ""C:/""}"),
                    ScssOption = engine.Execute(@"{:syntax => :scss, :cache_location => ""C:/""}"),
                    ExecuteRubyCode = code => engine.Execute(code, scope)
                };
            });
        }
Exemplo n.º 2
0
 public MinifyingFileCompiler()
 {
     _coffeeEngine = new TrashStack<CoffeeScriptCompiler>(() => new CoffeeScriptCompiler());
     _engine = new TrashStack<MinifyingCompiler>(() => new MinifyingCompiler());
 }
Exemplo n.º 3
0
        static SassFileCompiler()
        {
            _sassModule = new TrashStack<SassModule>(() => {
                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("SassAndCoffee.lib.sass_in_one.rb"), SourceCodeKind.File);
                var scope = engine.CreateScope();
                source.Execute(scope);

                return new SassModule() {
                    Engine = scope.Engine.Runtime.Globals.GetVariable("Sass"),
                    SassOption = engine.Execute("{:syntax => :sass}"),
                    ScssOption = engine.Execute("{:syntax => :scss}"),
                    ExecuteRubyCode = code => engine.Execute(code, scope),
                };
            });
        }