getGatherer()

in src/core.js [148:182]


  getGatherer(name) {
    let options = {
      verbose: this.verbose,
      debug: this.debug,
    };

    if (!name) return null;
    if (!this.gatherers[name]) {
      let GathererClass = null;
      let gathererConfig = this.coreConfig[name] || {};

      switch (name) {
        case 'docai':
          GathererClass = require('./gatherers/docai');
          break;

        case 'fake':
          // Return dummy gatherer for testing purpose.
          GathererClass = require('./gatherers/fake');
          break;

        default:
          try {
            GathererClass = require('./gatherers/' + name);
          } catch (e) {
            console.error(e);
            throw new Error(`Unable to load gatherer: ./gatherers/${name}`);
          }
          break;
      }
      this.gatherers[name] = new GathererClass(gathererConfig, this.envVars,
        this.apiHandler, options[name]);
    }
    return this.gatherers[name];
  }