<commit_before>var vow = require('vow');
var fs = require('enb/lib/fs/async-fs');
var bemxjst = require('bem-xjst');
var bemcompat = require('bemhtml-compat');
var XJST_SUFFIX = 'xjst';

module.exports = require('enb/lib/build-flow').create()
    .name('bem-xjst')
    .target('target', '?.bem-xjst.js')
    .methods({
        _sourceFilesProcess: function (sourceFiles, oldSyntax) {
            return vow.all(sourceFiles.map(function (file) {
                    return fs.read(file.fullname, 'utf8')
                        .then(function (source) {
                            if (oldSyntax && XJST_SUFFIX !== file.suffix.split('.').pop()) {
                                source = bemcompat.transpile(source);
                            }

                            return '/* begin: ' + file.fullname + ' *' + '/\n' +
                                source +
                                '\n/* end: ' + file.fullname + ' *' + '/';
                        });
                }))
                .then(function (sources) {
                    return this._bemxjstProcess(sources.join('\n'));
                }, this);
        },
        _bemxjstProcess: function (source) {
            var bemxjstProcessor = BemxjstProcessor.fork();

            return bemxjstProcessor.process(source, this._getOptions()).then(function (res) {
                bemxjstProcessor.dispose();
                return res;
            });
        },
        _getOptions: function () {
            var fieldNames = this._optionFieldNames;
            var options = {};

            for (var optName in fieldNames) {
                if (fieldNames.hasOwnProperty(optName)) {
                    options[optName] = this[fieldNames[optName]];
                }
            }
            return options;
        }
    })
    .createTech();

var BemxjstProcessor = require('sibling').declare({
    process: function (source, options) {
        return bemxjst.generate(source, {
            wrap: true,
            exportName: options.exportName,
            optimize: !options.devMode,
            cache: !options.devMode && options.cache
        });
    }
});<commit_msg>Refactoring of `bem-xjst` tech: removed `_getOptions`<commit_after>var vow = require('vow');
var fs = require('enb/lib/fs/async-fs');
var bemxjst = require('bem-xjst');
var bemcompat = require('bemhtml-compat');
var XJST_SUFFIX = 'xjst';

module.exports = require('enb/lib/build-flow').create()
    .name('bem-xjst')
    .target('target', '?.bem-xjst.js')
    .methods({
        _sourceFilesProcess: function (sourceFiles, oldSyntax) {
            return vow.all(sourceFiles.map(function (file) {
                    return fs.read(file.fullname, 'utf8')
                        .then(function (source) {
                            if (oldSyntax && XJST_SUFFIX !== file.suffix.split('.').pop()) {
                                source = bemcompat.transpile(source);
                            }

                            return '/* begin: ' + file.fullname + ' *' + '/\n' +
                                source +
                                '\n/* end: ' + file.fullname + ' *' + '/';
                        });
                }))
                .then(function (sources) {
                    return this._bemxjstProcess(sources.join('\n'));
                }, this);
        },
        _bemxjstProcess: function (source) {
            var bemxjstProcessor = BemxjstProcessor.fork();

            return bemxjstProcessor.process(source, {
                wrap: true,
                exportName: this._exportName,
                optimize: !this._devMode,
                cache: !this._devMode && this._cache
            }).then(function (res) {
                bemxjstProcessor.dispose();
                return res;
            });
        }
    })
    .createTech();

var BemxjstProcessor = require('sibling').declare({
    process: function (source, options) {
        return bemxjst.generate(source, options);
    }
});
{'fraction_non_alphanumeric': 0.13673929376408714, 'fraction_numerical': 0.0005008765339343851, 'mean_word_length': 1.49625, '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': '2530666', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1114, 'n_words': 192}