/*1Copyright (c) 2012, Yahoo! Inc. All rights reserved.2Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.3*/45var util = require('util'),6EventEmitter = require('events').EventEmitter,7Factory = require('../util/factory'),8factory = new Factory('report', __dirname, false);9/**10* An abstraction for producing coverage reports.11* This class is both the base class as well as a factory for `Report` implementations.12* All reports are event emitters and are expected to emit a `done` event when13* the report writing is complete.14*15* See also the `Reporter` class for easily producing multiple coverage reports16* with a single call.17*18* Usage19* -----20*21* var Report = require('istanbul').Report,22* report = Report.create('html'),23* collector = new require('istanbul').Collector;24*25* collector.add(coverageObject);26* report.on('done', function () { console.log('done'); });27* report.writeReport(collector);28*29* @class Report30* @module report31* @main report32* @constructor33* @protected34* @param {Object} options Optional. The options supported by a specific store implementation.35*/36function Report(/* options */) {37EventEmitter.call(this);38}3940util.inherits(Report, EventEmitter);4142//add register, create, mix, loadAll, getReportList as class methods43factory.bindClassMethods(Report);4445/**46* registers a new report implementation.47* @method register48* @static49* @param {Function} constructor the constructor function for the report. This function must have a50* `TYPE` property of type String, that will be used in `Report.create()`51*/52/**53* returns a report implementation of the specified type.54* @method create55* @static56* @param {String} type the type of report to create57* @param {Object} opts Optional. Options specific to the report implementation58* @return {Report} a new store of the specified type59*/60/**61* returns the list of available reports as an array of strings62* @method getReportList63* @static64* @return an array of supported report formats65*/6667var proto = {68/**69* returns a one-line summary of the report70* @method synopsis71* @return {String} a description of what the report is about72*/73synopsis: function () {74throw new Error('synopsis must be overridden');75},76/**77* returns a config object that has override-able keys settable via config78* @method getDefaultConfig79* @return {Object|null} an object representing keys that can be overridden via80* the istanbul configuration where the values are the defaults used when81* not specified. A null return implies no config attributes82*/83getDefaultConfig: function () {84return null;85},86/**87* writes the report for a set of coverage objects added to a collector.88* @method writeReport89* @param {Collector} collector the collector for getting the set of files and coverage90* @param {Boolean} sync true if reports must be written synchronously, false if they can be written using asynchronous means (e.g. stream.write)91*/92writeReport: function (/* collector, sync */) {93throw new Error('writeReport: must be overridden');94}95};9697Object.keys(proto).forEach(function (k) {98Report.prototype[k] = proto[k];99});100101module.exports = Report;102103104105106