Sha256: 38f6ca7cb0a8844b2ad0a17edad0325628abe6dfa689eff88f5daf697287cd79

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

/**
 * Module dependencies.
 */

var JSONCov = require('./json-cov')
  , fs = require('fs');

/**
 * Expose `HTMLCov`.
 */

exports = module.exports = HTMLCov;

/**
 * Initialize a new `JsCoverage` reporter.
 *
 * @param {Runner} runner
 * @api public
 */

function HTMLCov(runner) {
  var jade = require('jade')
    , file = __dirname + '/templates/coverage.jade'
    , str = fs.readFileSync(file, 'utf8')
    , fn = jade.compile(str, { filename: file })
    , self = this;

  JSONCov.call(this, runner, false);

  runner.on('end', function(){
    process.stdout.write(fn({
        cov: self.cov
      , coverageClass: coverageClass
    }));
  });
}

function coverageClass(n) {
  if (n >= 75) return 'high';
  if (n >= 50) return 'medium';
  if (n >= 25) return 'low';
  return 'terrible';
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stylus-source-0.27.1 vendor/node_modules/mocha/lib/reporters/html-cov.js
stylus-source-0.27.0 vendor/node_modules/mocha/lib/reporters/html-cov.js
stylus-source-0.26.1 vendor/node_modules/mocha/lib/reporters/html-cov.js
stylus-source-0.26.0 vendor/node_modules/mocha/lib/reporters/html-cov.js
stylus-source-0.25.0 vendor/node_modules/mocha/lib/reporters/html-cov.js