<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Jessica.Filters;
using Jessica.Responses;
using Jessica.Routing;
using Jessica.ViewEngines;

namespace Jessica
{
    public class JessModule
    {
        public IList<JessicaRoute> Routes { get; private set; }

        public BeforeFilters Before { get; private set; }
        public AfterFilters After { get; private set; }

        ViewFactory _viewFactory;
        string _basePath;
		
		public JessModule()
			: this("")
		{
		}

        public JessModule(string basePath)
        {
            Routes = new List<JessicaRoute>();
            Before = new BeforeFilters();
            After = new AfterFilters();

            _viewFactory = new ViewFactory(Jess.ViewEngines, AppDomain.CurrentDomain.BaseDirectory);
            _basePath = basePath;
        }

        private void AddRoute(string method, string route, Func<dynamic, Response> action)
        {
            route = string.Concat(_basePath, Regex.Replace(route, "/:([^/]*)", "/{$1}")).TrimStart('/');

            var existing = Routes.SingleOrDefault(r => r.Url == route);

            if (existing != null)
            {
                if (existing.Actions.ContainsKey(method))
                {
                    existing.Actions[method] = action;
                }
                else
                {
                    existing.Actions.Add(method, action);
                }
            }
            else
            {
                Routes.Add(new JessicaRoute(route, new Dictionary<string, Func<dynamic, Response>> { { method, action } }));<commit_msg>Added optional parameter back to the JessModule constructor<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Jessica.Filters;
using Jessica.Responses;
using Jessica.Routing;
using Jessica.ViewEngines;

namespace Jessica
{
    public class JessModule
    {
        public IList<JessicaRoute> Routes { get; private set; }

        public BeforeFilters Before { get; private set; }
        public AfterFilters After { get; private set; }

        ViewFactory _viewFactory;
        string _basePath;

        public JessModule(string basePath = "")
        {
            Routes = new List<JessicaRoute>();
            Before = new BeforeFilters();
            After = new AfterFilters();

            _viewFactory = new ViewFactory(Jess.ViewEngines, AppDomain.CurrentDomain.BaseDirectory);
            _basePath = basePath;
        }

        private void AddRoute(string method, string route, Func<dynamic, Response> action)
        {
            route = string.Concat(_basePath, Regex.Replace(route, "/:([^/]*)", "/{$1}")).TrimStart('/');

            var existing = Routes.SingleOrDefault(r => r.Url == route);

            if (existing != null)
            {
                if (existing.Actions.ContainsKey(method))
                {
                    existing.Actions[method] = action;
                }
                else
                {
                    existing.Actions.Add(method, action);
                }
            }
            else
            {
                Routes.Add(new JessicaRoute(route, new Dictionary<string, Func<dynamic, Response>> { { method, action } }));
{'fraction_non_alphanumeric': 0.10279263220439691, 'fraction_numerical': 0.0005941770647653001, 'mean_word_length': 1.9691358024691359, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2728420', 'n_tokens_mistral': 892, 'n_tokens_neox': 857, 'n_words': 210}