<commit_before>'use strict';
// Based on the reporting in grunt-pagespeed by <NAME>
// TODO: Refactor further as this still uses patterns that
// are based on Grunt conventions.

var prettyBytes = require('pretty-bytes');
var utils = require('./lib/utils');

exports.init = function () {
  var generateRuleSetResults, generateScore, generateStatistics, score, threshold;
  score = 0;
  threshold = 70;
  exports = {};

  generateScore = function (strategy, response) {
    return 'URL:      ' + response.id + '\nStrategy: ' + strategy + ' \nScore:    ' + score;
  };

  generateRuleSetResults = function (rulesets) {
    var result, ruleImpact, title, _results;
    _results = [];
    for (title in rulesets) {
      result = rulesets[title];
      title = utils.firstToUpperCaseAndAddSpace(title);
      title += utils.buffer(title);
      ruleImpact = Math.ceil(result.ruleImpact * 100) / 100;
      _results.push('' + title + '| ' + ruleImpact);
    }
    return _results.join('\n');
  };

  generateStatistics = function (statistics) {
    var result, title, _results;
    _results = [];
    for (title in statistics) {
      result = title.indexOf('Bytes') !== -1 ?
        prettyBytes(+statistics[title]) :
        statistics[title];
      title = utils.firstToUpperCaseAndAddSpace(title);
      title += utils.buffer(title);
      _results.push('' + title + '| ' + result);
    }
    return _results.join('\n');
  };

  exports.threshold = function (limit) {
    threshold = limit;
    return threshold;
  };

  exports.process = function (parameters, response, done) {
    var logger  = console.log;
    done        = done || function () {};
    threshold   = parameters.threshold || threshold;

    logger(
      [
        utils.divider,
        generateScore(parameters.strategy, response),
        generateStatistics(response.pageStats),
        utils.divider,
        generateRuleSetResults(response.formattedResults.ruleResults),
        utils.divider<commit_msg>Fixes #23 - More cleanup<commit_after>'use strict';
// Based on the reporting in grunt-pagespeed by <NAME>
// TODO: Refactor further as this still uses patterns that
// are based on Grunt conventions.

var prettyBytes = require('pretty-bytes');
var utils = require('./lib/utils');

exports.init = function () {

  var score = 0,
      threshold = 70,
      exports = {};

  var generateScore = function (strategy, response) {
    return 'URL:      ' + response.id + '\nStrategy: ' + strategy + ' \nScore:    ' + score;
  };

  var generateRuleSetResults = function (rulesets) {
    var result, ruleImpact, title, _results;
    _results = [];
    for (title in rulesets) {
      result = rulesets[title];
      title = utils.firstToUpperCaseAndAddSpace(title);
      title += utils.buffer(title);
      ruleImpact = Math.ceil(result.ruleImpact * 100) / 100;
      _results.push('' + title + '| ' + ruleImpact);
    }
    return _results.join('\n');
  };

  var generateStatistics = function (statistics) {
    var result, title, _results;
    _results = [];
    for (title in statistics) {
      result = title.indexOf('Bytes') !== -1 ?
        prettyBytes(+statistics[title]) :
        statistics[title];
      title = utils.firstToUpperCaseAndAddSpace(title);
      title += utils.buffer(title);
      _results.push('' + title + '| ' + result);
    }
    return _results.join('\n');
  };

  exports.threshold = function (limit) {
    threshold = limit;
    return threshold;
  };

  exports.process = function (parameters, response, done) {
    var logger  = console.log;
    done        = done || function () {};
    threshold   = parameters.threshold || threshold;

    logger(
      [
        utils.divider,
        generateScore(parameters.strategy, response),
        generateStatistics(response.pageStats),
        utils.divider,
        generateRuleSetResults(response.formattedResults.ruleResults),
        utils.divider
{'fraction_non_alphanumeric': 0.13085787451984635, 'fraction_numerical': 0.005633802816901409, 'mean_word_length': 2.8943170488534395, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3450914', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1126, 'n_words': 274}