Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void SetFixture(RubyRuntime data)
        {
            if (_scriptRuntime == null)
            {
                _scriptRuntime = data.CreateRuntime();
            }

            _engine  = _scriptRuntime.GetRubyEngine();
            _context = Ruby.GetExecutionContext(_engine);
        }
Beispiel #3
0
        protected override void EstablishContext()
        {
            if (_scriptRuntime == null)
            {
                var rubySetup = Ruby.CreateRubySetup();
                rubySetup.Options["InterpretedMode"] = true;

                var runtimeSetup = new ScriptRuntimeSetup();
                runtimeSetup.LanguageSetups.Add(rubySetup);
                runtimeSetup.DebugMode = true;

                _scriptRuntime = Ruby.CreateRuntime(runtimeSetup);
            }
            _engine  = _scriptRuntime.GetRubyEngine();
            _context = Ruby.GetExecutionContext(_engine);
        }
Beispiel #4
0
        /// <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;
        }