<commit_before>-- vanilla
local Error = require 'vanilla.v.error'
local sys_conf = require 'vanilla.sys.config'
local Registry = require('vanilla.v.registry'):new('sys')

-- perf
local pairs = pairs
local pcall = pcall
local require = require
local setmetatable = setmetatable
local function buildconf(config)
    if config ~= nil then
        for k,v in pairs(config) do sys_conf[k] = v end
    end
    Registry:set('app_name', sys_conf.name)
    Registry:set('app_root', sys_conf.app.root)
    Registry:set('app_version', sys_conf.version)
    return sys_conf
end

local Application = {}

function Application:lpcall( ... )
    local ok, rs_or_error = pcall( ... )
    if ok then
        return rs_or_error
    else
        self:raise_syserror(rs_or_error)
    end
end

function Application:new(config)
    self.config = buildconf(config)
    local instance = {
        run = self.run,
        bootstrap = self.bootstrap,
        dispatcher = self:lpcall(function() return require('vanilla.v.dispatcher'):new(self) end)
    }
    setmetatable(instance, {__index = self})
    return instance
end
<commit_msg>must set APProot app name in the config/application.lua file<commit_after>-- vanilla
local Error = require 'vanilla.v.error'
local sys_conf = require 'vanilla.sys.config'
local Registry = require('vanilla.v.registry'):new('sys')
local utils = require 'vanilla.v.libs.utils'

-- perf
local pairs = pairs
local pcall = pcall
local require = require
local setmetatable = setmetatable
local function buildconf(config)
    if config ~= nil then
        for k,v in pairs(config) do sys_conf[k] = v end
    end
    if sys_conf.name == nil or sys_conf.app.root == nil then
        utils.raise_syserror([[
            Sys Err: Please set app name and app root in config/application.lua like:
            
                Appconf.name = 'idevz.org'
                Appconf.app.root='./'
            ]])
    end
    Registry:set('app_name', sys_conf.name)
    Registry:set('app_root', sys_conf.app.root)
    Registry:set('app_version', sys_conf.version)
    return sys_conf
end

local Application = {}

function Application:lpcall( ... )
    local ok, rs_or_error = pcall( ... )
    if ok then
        return rs_or_error
    else
        self:raise_syserror(rs_or_error)
    end
end

function Application:new(config)
    self.config = buildconf(config)
    local instance = {
        run = self.run,
        bootstrap = self.bootstrap,
        dispatcher = self:lpcall(function() return require('vanilla.v.dispatcher'):new(self) end)
    }
    setmetatable(instance, {__index = self})
    return instance
end

{'fraction_non_alphanumeric': 0.10740314537782893, 'fraction_numerical': 0.0, 'mean_word_length': 3.0371517027863777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2612761', 'n_tokens_mistral': 824, 'n_tokens_neox': 807, 'n_words': 214}