Sha256: 070fee4f797b9ca4d4d6b48814301966e85aa29e09c62900081a9a4dcc180b53

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 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
    }));
  });
}

/**
 * Return coverage class for `n`.
 *
 * @return {String}
 * @api private
 */

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stylus-source-0.49.3 vendor/node_modules/mocha/lib/reporters/html-cov.js