Code coverage report for lib/reporters/abstract-reporter.js

Statements: 100% (12 / 12)      Branches: 100% (0 / 0)      Functions: 100% (4 / 4)      Lines: 100% (12 / 12)      Ignored: none     

All files » lib/reporters/ » abstract-reporter.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64    1             1         5                 1               1   9         9             1   1             1   1           1  
'use strict';
 
var through = require('through2');
 
/**
 * Base reporter than should be extended by concrete reporters.
 *
 * @constructor
 */
var AbstractReporter = function()
{
  /**
   * @type {null}
   */
  this.stream = null;
};
 
/**
 * Error message should an abstract method not be implemented
 * by a sub-class.
 *
 * @type {string}
 */
AbstractReporter.INHERITANCE_ERROR = 'Method not implemented. ' +
  'Must be overloaded sub a sub-class.';
 
/**
 * Start streaming the files.
 *
 * @return {*}
 */
AbstractReporter.prototype.run = function()
{
  this.stream = through.obj(
    this.processFile.bind(this),
    this.flush.bind(this)
  );
 
  return this.stream;
};
 
/**
 * Called once per file.
 * Must be overloaded by sub-class.
 */
AbstractReporter.prototype.processFile = function()
{
  throw new Error(AbstractReporter.INHERITANCE_ERROR);
};
 
/**
 * Called after all files have been processed.
 * Must be overloaded by a sub-class.
 */
AbstractReporter.prototype.flush = function()
{
  throw new Error(AbstractReporter.INHERITANCE_ERROR);
};
 
/**
 * @type {AbstractReporter}
 */
module.exports = AbstractReporter;