Exemple #1
0
        public SassTransformerBase(string syntaxOption)
        {
            var pal = new ResourceRedirectionPlatformAdaptationLayer();
            var srs = new ScriptRuntimeSetup
            {
                HostType = typeof(SassCompilerScriptHost),
                HostArguments = new List<object> { pal },
            };
            srs.AddRubySetup();
            var runtime = Ruby.CreateRuntime(srs);
            var 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(SassCompiler)), SourceCodeKind.File);
            var scope = engine.CreateScope();
            source.Execute(scope);

            sassCompiler = scope.Engine.Runtime.Globals.GetVariable("Sass");
            option = engine.Execute(syntaxOption);
        }
        private void Initialize()
        {
            if (!_initialized)
            {
                _pal = new ResourceRedirectionPlatformAdaptationLayer();
                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(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}");
                _sassOptionCompressed = _engine.Execute("{:cache => false, :syntax => :sass, :style => :compressed}");
                _scssOptionCompressed = _engine.Execute("{:cache => false, :syntax => :scss, :style => :compressed}");

                _initialized = true;
            }
        }
        private void Initialize()
        {
            if (!_initialized) {
                _pal = new ResourceRedirectionPlatformAdaptationLayer();
                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(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}");
                _sassOptionCompressed = _engine.Execute("{:cache => false, :syntax => :sass, :style => :compressed}");
                _scssOptionCompressed = _engine.Execute("{:cache => false, :syntax => :scss, :style => :compressed}");

                _initialized = true;
            }
        }