<commit_before>/**
 * DepsResolver
 * ============
 */

var inherit = require('inherit'),
    vm = require('vm'),
    vow = require('vow'),
    vfs = require('enb/lib/fs/async-fs'),
    yaml = require('js-yaml');

function DepsError(message) {
    this.message = message;
    Error.captureStackTrace(this, DepsError);
}
DepsError.prototype = Object.create(Error.prototype);
DepsError.prototype.name = 'Deps error';

/**
 * DepsResolver — класс, раскрывающий deps'ы.
 * @name DepsResolver
 */
module.exports = inherit({

    /**
     * Конструктор.
     * @param {Level[]} levels
     */
    __constructor: function (levels) {
        this.levels = levels;
        this.declarations = [];
        this.resolved = {};
        this.declarationIndex = {};
    },

    /**
     * Раскрывает шорткаты deps'а.
     * @param {String|Object} dep
     * @param {String} blockName
     * @param {String} elemName
     * @returns {Array}
     */
    normalizeDep: function (dep, blockName, elemName) {
        var levels = this.levels;
        if (typeof dep === 'string') {
            return [{ name: dep }];
        } else {
            var res = [];
            if (!dep || !(dep instanceof Object)) {
                throw new DepsError('Deps shoud be instance of Object or String');
            }
            if (dep.elem) {
                (Array.isArray(dep.elem) ? dep.elem : [dep.elem]).forEach(function (elem) {
                    if (dep.mods) {
                        Object.keys(dep.mods).forEach(function (modName) {
                            var modVals = dep.mods[modName];
                            if (!Array.isArray(modVals)) {
                                modVals = [modVals];
                            }
                            res = res.concat(modVals.map(function (modVal) {
                                return { name: dep.block || blockName, elem: elem, modName: modName, modVal: modVal };
                            }));
                        });
                    } else if (dep.mod) {
                        res.push({ name: dep.block || blockName, elem: elem, modName: dep.mod, modVal: dep.val });
                    } else {
                        res.push({ name: dep.block || blockName, elem: elem });
                    }
                });
            } else if (dep.mod || dep.mods || dep.elems) {
                if (dep.mod) {
                    res.push({ name: dep.block || blockName, modName: dep.mod, modVal: dep.val });
                }
                Object.keys(dep.mods || {}).forEach(function (modName) {
                    var modVals = dep.mods[modName];
                    if (modVals === '*') {
                        modVals = levels.getModValues(dep.block || blockName, modName);
                    }
                    if (!Array.isArray(modVals)) {<commit_msg>Fixed bug with respect context in deps for elem mod<commit_after>/**
 * DepsResolver
 * ============
 */

var inherit = require('inherit'),
    vm = require('vm'),
    vow = require('vow'),
    vfs = require('enb/lib/fs/async-fs'),
    yaml = require('js-yaml');

function DepsError(message) {
    this.message = message;
    Error.captureStackTrace(this, DepsError);
}
DepsError.prototype = Object.create(Error.prototype);
DepsError.prototype.name = 'Deps error';

/**
 * DepsResolver — класс, раскрывающий deps'ы.
 * @name DepsResolver
 */
module.exports = inherit({

    /**
     * Конструктор.
     * @param {Level[]} levels
     */
    __constructor: function (levels) {
        this.levels = levels;
        this.declarations = [];
        this.resolved = {};
        this.declarationIndex = {};
    },

    /**
     * Раскрывает шорткаты deps'а.
     * @param {String|Object} dep
     * @param {String} blockName
     * @param {String} elemName
     * @returns {Array}
     */
    normalizeDep: function (dep, blockName, elemName) {
        var levels = this.levels;
        if (typeof dep === 'string') {
            return [{ name: dep }];
        } else {
            var res = [];
            if (!dep || !(dep instanceof Object)) {
                throw new DepsError('Deps shoud be instance of Object or String');
            }
            if (dep.elem) {
                (Array.isArray(dep.elem) ? dep.elem : [dep.elem]).forEach(function (elem) {
                    if (dep.mods) {
                        Object.keys(dep.mods).forEach(function (modName) {
                            var modVals = dep.mods[modName];
                            if (!Array.isArray(modVals)) {
                                modVals = [modVals];
                            }
                            res = res.concat(modVals.map(function (modVal) {
                                return { name: dep.block || blockName, elem: elem, modName: modName, modVal: modVal };
                            }));
                        });
                    } else if (dep.mod) {
                        res.push({ name: dep.block || blockName, elem: elem, modName: dep.mod, modVal: dep.val });
                    } else {
                        res.push({ name: dep.block || blockName, elem: elem });
                    }
                });
            } else if (dep.mod || dep.mods || dep.elems) {
                if (dep.mod) {
                    if (elemName) {
                        res.push(
                            { name: dep.block || blockName, elem: elemName, modName: dep.mod },
                            { name: dep.block || blockName, elem: elemName, modName: dep.mod, modVal: dep.val }
                        );
                    } else {
                        res.push(
                            { name: dep.block || blockName, modName: dep.mod },
                            { name: dep.block || blockName, modName: dep.mod, modVal: dep.val }
                        );
                    }
                }
                Object.keys(dep.mods || {}).forEach(function (modName) {
                    var modVals = dep.mods[modName];
                    if (modVals === '*') {
                        modVals = levels.getModValues(dep.block || blockName, modName);
                    }
                    if (!Array.isArray(modVals)) {
{'fraction_non_alphanumeric': 0.13627577319587628, 'fraction_numerical': 0.0, 'mean_word_length': 1.3617344998098135, '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': '740773', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1725, 'n_words': 376}