<commit_before>'use strict';

var EventEmitter = require('events'),
    include = require('include-all'),
    _ = require('lodash'),
    async = require('async');

var Mycro = function(config) {
    var self = this;

    // inherit from EventEmitter
    EventEmitter.call(self);

    // set defauts
    self._config = config || {};
    self._version = require('./package.json').version;

    // gather default config
    var defaults = include({
        dirname: __dirname + '/config',
        filter:  /(.+)\.js$/,
        optional:  true
    });

    // gather user config
    var userConfig = include({
        dirname: process.cwd() + '/config',
        filter:  /(.+)\.js$/,
        optional: true
    });

    // initialize any config files that export constructors
    // note: if constructors expect a single argument, the microservice will be
    // passed as the sole argument
    defaults = _.mapValues(defaults, function(constructor) {
        if (typeof constructor === 'function') {
            return constructor(self);
        }
        return constructor;
    });
    userConfig = _.mapValues(userConfig, function(constructor) {
        if (typeof constructor === 'function') {
            return constructor();
        }
        return constructor;
    });


    // create microservice config and store it on the service object
    self._config = _.defaults(_.extend(userConfig, self._config), defaults);

    // configure logger settings
    self.logger = new self._config.logger(self._config.log);
    self.log = function() {
        self.logger.log.apply(self.logger, Array.prototype.slice.call(arguments));
    };

    self._hooks = [];
    self._config.hooks.forEach(function(hook) {
        if (_.isFunction(hook)) {
            self._hooks.push(hook);
            self.log('silly', '[init] loading hook: ' + hook.name);<commit_msg>fixes #38<commit_after>'use strict';

var EventEmitter = require('events'),
    include = require('include-all'),
    _ = require('lodash'),
    async = require('async');

var Mycro = function(config) {
    var self = this;

    // inherit from EventEmitter
    EventEmitter.call(self);

    // set defauts
    self._config = config || {};
    self._version = require('./package.json').version;

    // gather default config
    var defaults = include({
        dirname: __dirname + '/config',
        filter:  /(.+)\.js$/,
        optional:  true
    });

    // gather user config
    var userConfig = include({
        dirname: process.cwd() + '/config',
        filter:  /(.+)\.js$/,
        optional: true
    });

    // initialize any config files that export constructors
    // note: if constructors expect a single argument, the microservice will be
    // passed as the sole argument
    defaults = _.mapValues(defaults, function(constructor) {
        if (typeof constructor === 'function') {
            return constructor(self);
        }
        return constructor;
    });
    userConfig = _.mapValues(userConfig, function(constructor) {
        if (typeof constructor === 'function') {
            return constructor(self);
        }
        return constructor;
    });


    // create microservice config and store it on the service object
    self._config = _.defaults(_.extend(userConfig, self._config), defaults);

    // configure logger settings
    self.logger = new self._config.logger(self._config.log);
    self.log = function() {
        self.logger.log.apply(self.logger, Array.prototype.slice.call(arguments));
    };

    self._hooks = [];
    self._config.hooks.forEach(function(hook) {
        if (_.isFunction(hook)) {
            self._hooks.push(hook);
            self.log('silly', '[init] loading hook: ' + hook.name);
{'fraction_non_alphanumeric': 0.13712284482758622, 'fraction_numerical': 0.0005387931034482759, 'mean_word_length': 2.4252767527675276, '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': '2687504', 'n_tokens_mistral': 1015, 'n_tokens_neox': 993, 'n_words': 262}