<commit_before>var _ = require('lodash'),
  util = require('util'),
  find = require('find');

var Component = module.exports = function(args) {
  args = args || {};
  this.isInstance = true;
  this.initAttributes(args);
  this.callInitializers();
};

Component.extend = require('./extend');

_.extend(Component.prototype, {
  initAttributes: function(args) {
    _.forEach(this.constructor.attributes, function(value, attr) {
      this.initAttribute(value, attr, args);
    }, this);
  },
  initAttribute: function(config, attr, args) {
    var value = _.without([args[attr], this[attr], config.default], undefined)[0];
    if (value === config.default && _.isFunction(value)) value = value.apply(this);
    if (_.isUndefined(value) && config.builder) value = this[config.builder].apply(this);
    if (config.required && (_.isUndefined(value) || _.isNull(value))) {
      this.throw('AttributeRequired', 'attribute "%s" is required', attr);
    }
    this[attr] = value;
  },
  initComponentsFromPath: function(path, config, defaults) {
    var components = {};
    find.fileSync(/\.js$/, path).forEach(function(file) {
      var name = file.substr(path.length).replace(/\.js$/, '');
      components[name] = {
        name: file,
        arguments: _.defaults({
          file: file,
          configKey: name,
        }, config[name], defaults),
      };
    }, this);
    return this.initComponentsWith(components);
  },
  initComponentsWith: function(components, config) {
    config = config || {};
    if (!_.isArray(components) && !_.isPlainObject(components)) components = [components];
    var collection = {};
    _.forEach(components, function(component, name) {
      var Constructor, config;
      if (_.isString(component))
        Constructor = require(component);
      else if (_.isPlainObject(component)) {
        Constructor = require(component.name);
        config = _.defaults({
          logger: this.logger
        }, component.arguments, config);
        name = _.isNumber(name) ? component.name : name;
      } else Constructor = component;
      if (_.isFunction(Constructor)) {<commit_msg>support wildcard config<commit_after>var _ = require('lodash'),
  util = require('util'),
  find = require('find');

var Component = module.exports = function(args) {
  args = args || {};
  this.isInstance = true;
  this.initAttributes(args);
  this.callInitializers();
};

Component.extend = require('./extend');

_.extend(Component.prototype, {
  initAttributes: function(args) {
    _.forEach(this.constructor.attributes, function(value, attr) {
      this.initAttribute(value, attr, args);
    }, this);
  },
  initAttribute: function(config, attr, args) {
    var value = _.without([args[attr], this[attr], config.default], undefined)[0];
    if (value === config.default && _.isFunction(value)) value = value.apply(this);
    if (_.isUndefined(value) && config.builder) value = this[config.builder].apply(this);
    if (config.required && (_.isUndefined(value) || _.isNull(value))) {
      this.throw('AttributeRequired', 'attribute "%s" is required', attr);
    }
    this[attr] = value;
  },
  initComponentsFromPath: function(path, config, defaults) {
    var components = {};
    find.fileSync(/\.js$/, path).forEach(function(file) {
      var name = file.substr(path.length).replace(/\.js$/, '');
      var wildcard = name.replace(/[^\/]+$/, '*');
      components[name] = {
        name: file,
        arguments: _.defaults({
          file: file,
          configKey: name,
        }, config[name], config[wildcard], defaults),
      };
    }, this);
    return this.initComponentsWith(components);
  },
  initComponentsWith: function(components, config) {
    config = config || {};
    if (!_.isArray(components) && !_.isPlainObject(components)) components = [components];
    var collection = {};
    _.forEach(components, function(component, name) {
      var Constructor, config;
      if (_.isString(component))
        Constructor = require(component);
      else if (_.isPlainObject(component)) {
        Constructor = require(component.name);
        config = _.defaults({
          logger: this.logger
        }, component.arguments, config);
        name = _.isNumber(name) ? component.name : name;
      } else Constructor = component;
      if (_.isFunction(Constructor)) {
{'fraction_non_alphanumeric': 0.16184301921741143, 'fraction_numerical': 0.00046307015512850195, 'mean_word_length': 3.32, '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': '1487705', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1232, 'n_words': 262}