示例#1
0
        private object Rackup()
        {
            Utils.Log("=> Loading Rack application");
            var fullPath = Path.Combine(_appRoot, "config.ru");

            if (File.Exists(fullPath))
            {
                return(IronRubyEngine.ExecuteMethod <RubyArray>(
                           IronRubyEngine.Execute("Rack::Builder"),
                           "parse_file", MutableString.CreateAscii(fullPath))[0]);
            }
            return(null);
        }
示例#2
0
        internal static void ReportErrorAsHTML(HttpContext /*!*/ context, Exception /*!*/ e, Action <string> write)
        {
            var trace = IronRubyEngine.Engine == null ?
                        e.Message + "\n" + e.StackTrace + "\n" :
                        IronRubyEngine.Engine.GetService <ExceptionOperations>().FormatException(e);

            write("<html>\r\n");
            write(String.Format(@"
<h4>Error: {0}</h4>
<pre>
{1}
</pre>
", HttpUtility.HtmlEncode(e.Message), HttpUtility.HtmlEncode(trace)));

            if (IronRubyEngine.Engine != null)
            {
                write("<h4>Search paths</h4>\r\n");
                write("<pre>\r\n");
                foreach (var path in IronRubyEngine.Engine.GetSearchPaths())
                {
                    write(HttpUtility.HtmlEncode(path));
                    write("\r\n");
                }
                write("</pre>\r\n");

                try {
                    var gempaths = IronRubyEngine.Execute <RubyArray>("require 'rubygems'; Gem.path");
                    write("<h4>Gem paths</h4>\r\n");
                    write("<pre>\r\n");
                    foreach (var gempath in gempaths)
                    {
                        write(HttpUtility.HtmlEncode(((MutableString)gempath).ToString()));
                        write("\r\n");
                    }
                    write("</pre>\r\n");
                } catch {
                    // who cares if it fails
                }
            }
            write("</html>\r\n");
        }