Code coverage report for istanbul/lib/report/index.js

Statements: 91.67% (11 / 12)      Branches: 100% (0 / 0)      Functions: 80% (4 / 5)      Lines: 91.67% (11 / 12)      Ignored: none     

All files » istanbul/lib/report/ » index.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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105          89                                                             89 1024     89     89                                               89                                 285                 1       89 267     89      
/*
 Copyright (c) 2012, Yahoo! Inc.  All rights reserved.
 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
 */
 
var util = require('util'),
    EventEmitter = require('events').EventEmitter,
    Factory = require('../util/factory'),
    factory = new Factory('report', __dirname, false);
/**
 * An abstraction for producing coverage reports.
 * This class is both the base class as well as a factory for `Report` implementations.
 * All reports are event emitters and are expected to emit a `done` event when
 * the report writing is complete.
 *
 * See also the `Reporter` class for easily producing multiple coverage reports
 * with a single call.
 *
 * Usage
 * -----
 *
 *      var Report = require('istanbul').Report,
 *          report = Report.create('html'),
 *          collector = new require('istanbul').Collector;
 *
 *      collector.add(coverageObject);
 *      report.on('done', function () { console.log('done'); });
 *      report.writeReport(collector);
 *
 * @class Report
 * @module report
 * @main report
 * @constructor
 * @protected
 * @param {Object} options Optional. The options supported by a specific store implementation.
 */
function Report(/* options */) {
    EventEmitter.call(this);
}
 
util.inherits(Report, EventEmitter);
 
//add register, create, mix, loadAll, getReportList as class methods
factory.bindClassMethods(Report);
 
/**
 * registers a new report implementation.
 * @method register
 * @static
 * @param {Function} constructor the constructor function for the report. This function must have a
 *  `TYPE` property of type String, that will be used in `Report.create()`
 */
/**
 * returns a report implementation of the specified type.
 * @method create
 * @static
 * @param {String} type the type of report to create
 * @param {Object} opts Optional. Options specific to the report implementation
 * @return {Report} a new store of the specified type
 */
/**
 * returns the list of available reports as an array of strings
 * @method getReportList
 * @static
 * @return an array of supported report formats
 */
 
var proto = {
    /**
     * returns a one-line summary of the report
     * @method synopsis
     * @return {String} a description of what the report is about
     */
    synopsis: function () {
        throw new Error('synopsis must be overridden');
    },
    /**
     * returns a config object that has override-able keys settable via config
     * @method getDefaultConfig
     * @return {Object|null} an object representing keys that can be overridden via
     *  the istanbul configuration where the values are the defaults used when
     *  not specified. A null return implies no config attributes
     */
    getDefaultConfig: function () {
        return null;
    },
    /**
     * writes the report for a set of coverage objects added to a collector.
     * @method writeReport
     * @param {Collector} collector the collector for getting the set of files and coverage
     * @param {Boolean} sync true if reports must be written synchronously, false if they can be written using asynchronous means (e.g. stream.write)
     */
    writeReport: function (/* collector, sync */) {
        throw new Error('writeReport: must be overridden');
    }
};
 
Object.keys(proto).forEach(function (k) {
    Report.prototype[k] = proto[k];
});
 
module.exports = Report;