<commit_before>/*globals define, requirejs*/
/*jshint node:true, browser:true*/

define([
    './templates/index',
    'q',
    'underscore',
    'deepforge/Constants',
    'deepforge/plugin/Operation',
    'deepforge/OperationCode',
    'deepforge/plugin/PtrCodeGen',
    'text!./metadata.json',
    'plugin/PluginBase',
    'module'
], function (
    Templates,
    Q,
    _,
    CONSTANTS,
    OperationHelpers,
    OperationCode,
    PtrCodeGen,
    pluginMetadata,
    PluginBase,
    module
) {
    'use strict';

    pluginMetadata = JSON.parse(pluginMetadata);
    const DATA_DIR = 'artifacts/';
    const DEFAULT_SETTINGS = {enableJobCaching: false};
    var OUTPUT_INTERVAL = 1500,
        STDOUT_FILE = 'job_stdout.txt';

    /**
     * Initializes a new instance of GenerateJob.
     * @class
     * @augments {PluginBase}
     * @classdesc This class represents the plugin GenerateJob.
     * @constructor
     */
    var GenerateJob = function () {
        // Call base class' constructor.
        PluginBase.call(this);
        this.pluginMetadata = pluginMetadata;

        this.settings = _.extend({}, DEFAULT_SETTINGS);
        if (typeof WebGMEGlobal === 'undefined') {  // Running in NodeJS
            const path = require('path');
            const dirname = path.dirname(module.uri);
            const deploymentSettings = JSON.parse(requirejs('text!' + dirname + '/../../../config/components.json'));
            _.extend(this.settings, deploymentSettings);
        } else {  // Running in the browser
            const ComponentSettings = requirejs('js/Utils/ComponentSettings');
            ComponentSettings.resolveWithWebGMEGlobal(
                this.settings,
                this.getComponentId()
            );
        }
    };

    /**
     * Metadata associated with the plugin. Contains id, name, version, description, icon, configStructue etc.
     * This is also available at the instance at this.pluginMetadata.
     * @type {object}
     */
    GenerateJob.metadata = pluginMetadata;

    // Prototypical inheritance from PluginBase.
    GenerateJob.prototype = Object.create(PluginBase.prototype);
    GenerateJob.prototype.constructor = GenerateJob;

    GenerateJob.prototype.getComponentId = function () {
        return 'GenerateJob';
    };

    /**
     * Main function for the plugin to execute. This will perform the execution.<commit_msg>Updated NodeJS/browser exec env detection. Fixes #1212 (#1213)<commit_after>/*globals define, requirejs*/
/*jshint node:true, browser:true*/

define([
    './templates/index',
    'q',
    'underscore',
    'deepforge/Constants',
    'deepforge/plugin/Operation',
    'deepforge/OperationCode',
    'deepforge/plugin/PtrCodeGen',
    'text!./metadata.json',
    'plugin/PluginBase',
    'module'
], function (
    Templates,
    Q,
    _,
    CONSTANTS,
    OperationHelpers,
    OperationCode,
    PtrCodeGen,
    pluginMetadata,
    PluginBase,
    module
) {
    'use strict';

    pluginMetadata = JSON.parse(pluginMetadata);
    const DATA_DIR = 'artifacts/';
    const DEFAULT_SETTINGS = {enableJobCaching: false};
    var OUTPUT_INTERVAL = 1500,
        STDOUT_FILE = 'job_stdout.txt';

    /**
     * Initializes a new instance of GenerateJob.
     * @class
     * @augments {PluginBase}
     * @classdesc This class represents the plugin GenerateJob.
     * @constructor
     */
    var GenerateJob = function () {
        // Call base class' constructor.
        PluginBase.call(this);
        this.pluginMetadata = pluginMetadata;

        this.settings = _.extend({}, DEFAULT_SETTINGS);
        if (require.isBrowser) {
            const ComponentSettings = requirejs('js/Utils/ComponentSettings');
            ComponentSettings.resolveWithWebGMEGlobal(
                this.settings,
                this.getComponentId()
            );
        } else {  // Running in NodeJS
            const path = require('path');
            const dirname = path.dirname(module.uri);
            const deploymentSettings = JSON.parse(requirejs('text!' + dirname + '/../../../config/components.json'));
            _.extend(this.settings, deploymentSettings);
        }
    };

    /**
     * Metadata associated with the plugin. Contains id, name, version, description, icon, configStructue etc.
     * This is also available at the instance at this.pluginMetadata.
     * @type {object}
     */
    GenerateJob.metadata = pluginMetadata;

    // Prototypical inheritance from PluginBase.
    GenerateJob.prototype = Object.create(PluginBase.prototype);
    GenerateJob.prototype.constructor = GenerateJob;

    GenerateJob.prototype.getComponentId = function () {
        return 'GenerateJob';
    };

    /**
     * Main function for the plugin to execute. This will perform the execution.
{'fraction_non_alphanumeric': 0.11422594142259414, 'fraction_numerical': 0.0033472803347280333, 'mean_word_length': 2.5154411764705884, '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': '7574522', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1295, 'n_words': 308}