<commit_before>'use strict';

const _ = require('lodash');
const pluginMaker = require('./mixinPluginMaker');

module.exports = class {
  constructor(molotovProvider, cocktailPluginDefinitions, modulesPluginDirectory, modulesSupers) {
    // Get their supers, and plugins.
    this.setMolotovSupers(molotovProvider.getSupersDirectory());
    this.setMolotovPlugins(molotovProvider.getPluginDirectory());
    // if our plugins - set our plugins
    this.setCocktailPluginDefinitions({});
    this.setCocktailSupers({});
    this.setCocktailPlugins({});
    if (cocktailPluginDefinitions) {
      this.setCocktailPluginDefinitions(cocktailPluginDefinitions);
    }
    // if our supers - set our supers
    if (modulesSupers) {
      this.setCocktailSupers(modulesSupers);
    }
    // merge supers and plugins
    if (modulesPluginDirectory) {
      this.setCocktailPlugins(modulesPluginDirectory);
    }

    this.mergeSupers();
    this.mergePlugins();
  }

  setCocktailPluginDefinitions(cocktailPluginDefinitions) {
    this.cocktailPluginDefinitions = cocktailPluginDefinitions;
  }

  getCocktailPluginDefinitions() {
    return this.cocktailPluginDefinitions;
  }<commit_msg>Added config plugin def check.<commit_after>'use strict';

const _ = require('lodash');
const pluginMaker = require('./mixinPluginMaker');
const config = require('config');

module.exports = class {
  /**
   * cocktail class
   *
   * @params {obj} molotovProvider
   *   The Molotov class implemented by a molotov provider module.
   * @params {obj} optional cocktailPluginDefinitions
   *   An object of plugin definitions. If not provided will be extracted from config.
   * @params {obj} optional modulesPluginDirectory
   */
  constructor(molotovProvider, cocktailPluginDefinitions, modulesPluginDirectory, modulesSupers) {
    // Get their supers, and plugins.
    this.setMolotovSupers(molotovProvider.getSupersDirectory());
    this.setMolotovPlugins(molotovProvider.getPluginDirectory());
    // if our plugins - set our plugins
    this.setCocktailPluginDefinitions({});
    this.setCocktailSupers({});

    if (cocktailPluginDefinitions) {
      this.setCocktailPluginDefinitions(cocktailPluginDefinitions);
    }
    else {
      if (!config.molotov.cocktailPlugins) {
        throw new Error('Cocktail must declare plugins.');
      }
      this.setCocktailPluginDefinitions(config.molotov.cocktailPlugins);
    }
    // if our supers - set our supers
    if (modulesSupers) {
      this.setCocktailSupers(modulesSupers);
    }
    // merge supers and plugins
    if (modulesPluginDirectory) {
      this.setCocktailPlugins(modulesPluginDirectory);
    }

    this.mergeSupers();
    this.mergePlugins();
  }

  setCocktailPluginDefinitions(cocktailPluginDefinitions) {
    this.cocktailPluginDefinitions = cocktailPluginDefinitions;
  }

  getCocktailPluginDefinitions() {
    return this.cocktailPluginDefinitions;
  }
{'fraction_non_alphanumeric': 0.09746053534660261, 'fraction_numerical': 0.0, 'mean_word_length': 4.078397212543554, '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': '4837928', 'n_tokens_mistral': 870, 'n_tokens_neox': 822, 'n_words': 163}