Beispiel #1
0
        public override FilterInfo GetFilters()
        {
            var filters = (Hash)RubyEngine.CallMethod(RubyControllerDescriptor.RubyControllerClass, "action_filters");

            var info = filters.ToFilterInfo(ActionName);

            return(info);
        }
Beispiel #2
0
        protected override void ProcessRecord()
        {
            AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => Assembly.Load(AssemblyResolver.ResolveAssembly(args));

            if (RubyFile != null && File.Exists(RubyFile))
            {
                _postScript = File.ReadAllText(RubyFile);
            }
            else if (Script != null)
            {
                _postScript = Script;
            }

            if (AbstractScript != null)
            {
                // Combine abstractScript
                _scopeScript = AbstractScript + Environment.NewLine + _postScript;
            }
            else
            {
                // No abstract script found, just pass the postScript to the scope
                _scopeScript = _postScript;
            }

            SortedDictionary <string, object> inputVariables = new SortedDictionary <string, object>();

            if (Verbs != null)
            {
                string[] verbsArray = Verbs.Replace(" ", String.Empty).Split(',');

                if (verbsArray.Length > 0)
                {
                    foreach (string verb in verbsArray)
                    {
                        inputVariables.Add(verb, new object());
                    }
                }
            }

            RubyEngine rubyEngine = new RubyEngine {
                Script = _scopeScript, ScriptVariables = inputVariables
            };
            SortedDictionary <string, object> outputVariables = rubyEngine.Execute();

            WriteObject(outputVariables);
        }
Beispiel #3
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name='args'>
        /// The command-line arguments.
        /// </param>
        public static void Main(string[] args)
        {
            // Get config
            int port = Config.ListenPort;

            // Initialize folder
            CommonHelper.InitializeFolder();

            // Start peer service
            StartPeer(port);

            // Start CLI
            RubyEngine engine = new RubyEngine();

            engine.SetVariable("api", new API());
            engine.Repl();
        }
        public RubyEnvironment(Action<RubyEnvironment> configure)
        {
            Engine = new RubyEngine();
            ApplicationRootPath = AppDomain.CurrentDomain.BaseDirectory;
            string configured = ConfigurationManager.AppSettings[ApplicationRootConfigurationKey];
            if (!String.IsNullOrEmpty(configured))
            {
                if (Path.IsPathRooted(configured) == false)
                    configured = Path.Combine(ApplicationRootPath, configured);

                if (Directory.Exists(configured))
                    ApplicationRootPath = configured;
            }

            GemPath = DefaultGemPath;
            configured = ConfigurationManager.AppSettings[GemPathConfigurationKey];
            if (!String.IsNullOrEmpty(configured) && Directory.Exists(configured))
                GemPath = configured;

            if (configure != null)
                configure(this);

            Initialize();
        }
Beispiel #5
0
 public override object Execute(ControllerContext controllerContext, IDictionary <string, object> parameters)
 {
     return(RubyEngine.CallMethod(controllerContext.Controller, ActionName));
 }
Beispiel #6
0
 protected override void Because()
 {
     _engine = RubyEngine.InitializeIronRubyMvc(_pathProvider, "~/routes.rb");
 }
 public ExecutandoScriptsTexto()
 {
     ruby = new RubyEngine(this);
 }