Example #1
0
var generateTable = function(data) {
	var cliTable = require('cli-table'),
		res = [];
	for (var i = 0; i < data.length; i++) {
		res.push('\n\nBrowser: ', data[i]._browserName + '\n');
		var table = new cliTable({
			head: ['Metrics', 'Value', 'Unit', 'Source'],
			colAligns: ['right', 'left'],
			colWidths: [35, 15, 15, 35]
		});
		for (var key in data[i]) {
			if (key.indexOf('_') === 0)
				continue;
			var val = data[i][key];
			table.push([key, val.value + '', val.unit + '', val.source + '']);
		}
		table = table.sort(function(a, b) {
			if (a[3] === b[3]) {
				return a[0] > b[0] ? 1 : -1;
			} else {
				return a[3] > b[3] ? 1 : -1;
			}
		});
		res.push(table.toString());
	}
	return res.join('');
};
Example #2
0
    items.forEach(function(row) {
        var err,
            percentLine = Math.floor((row.calledLines / row.coveredLines) * 100),
            percentFunction = Math.floor((row.calledFunctions / row.coveredFunctions) * 100),
            cell = [
                row.path,
                row.calledLines + '/' + row.coveredLines,
                percentLine + '%',
                row.calledFunctions + '/' + row.coveredFunctions,
                percentFunction + '%'
            ];

            ['calledLines', 'calledFunctions', 'coveredLines', 'coveredFunctions'].forEach(function(prop) {
                totals[prop] += row[prop];
            });

        if (percentLine <= options.coverageWarn) {
            err = true;
            cell[1] = util.color(String(cell[1]), 'red');
            cell[2] = util.color(String(cell[2]), 'red');
        }
        if (percentFunction <= options.coverageWarn) {
            err = true;
            cell[3] = util.color(String(cell[3]), 'red');
            cell[4] = util.color(String(cell[4]), 'red');
        }
        if (err) {
            cell[0] = util.color(util.bad, 'red') + ' ' + cell[0];
        } else {
            cell[0] = util.color(util.good, 'green') + ' ' + cell[0];
        }
        table.push(cell);
    });
Example #3
0
            david.getUpdatedDependencies(manifest, options, function(err, deps) {
                if (err) {
                    grunt.log.error('an error occurred.');

                    next(new Error(err));
                } else {
                    if (Object.keys(deps).length) {
                        grunt.log.errorlns('outdated dependencies detected:');

                        var table = new Table({
                            head : [ 'Dependency', 'installed', 'stable', 'latest' ],
                            colWidths : [ 50, 11, 10, 10 ]
                        });

                        for ( var dep in deps) {
                            table.push([dep, deps[dep].required, deps[dep].stable, deps[dep].latest ]);
                        }

                        grunt.log.writeln(table.toString());
                    } else {
                        grunt.log.writeln('No outdated dependencies detected');
                    }

                    next();
                }
            });
Example #4
0
  'test complete table': function (){
    var table = new Table({ 
        head: ['Rel', 'Change', 'By', 'When']
      , style: {
            'padding-left': 1
          , 'padding-right': 1
        }
      , colWidths: [6, 21, 25, 17]
    });

    table.push(
        ['v0.1', 'Testing something cool', '*****@*****.**', '7 minutes ago']
      , ['v0.1', 'Testing something cool', '*****@*****.**', '8 minutes ago']
    );

    var expected = [
        '┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓'
      , '┃ Rel  ┃ Change              ┃ By                      ┃ When            ┃'
      , '┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━┫'
      , '┃ v0.1 ┃ Testing something … ┃ rauchg@gmail.com        ┃ 7 minutes ago   ┃'
      , '┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━┫'
      , '┃ v0.1 ┃ Testing something … ┃ rauchg@gmail.com        ┃ 8 minutes ago   ┃'
      , '┗━━━━━━┻━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━┛'
    ];

    table.toString().should.eql(expected.join("\n"));
  },
Example #5
0
        _.each(response.protocols, function(proto) {

            var protoheader = new Table()

            console.log(colors.bold('\n#### ' + proto.protocolName + ' ##\n'));
            protoheader.push(
                { 'Protocol Name': proto.protocolName },
                { 'Scheme': proto.protocolScheme },
                { 'Description': proto.description }
            );

            console.log(protoheader.toString())

            var table = new Table({
                head: ['Endpoint', 'Description']
                , colWidths: [30, 30]
            });

            if (proto.operations.length > 0 && proto.operations != "N/A") {
                _.each(proto.operations, function (op) {

                    var doc = op.doc
                    if (doc == null) doc = ''

                    table.push(
                        [op.resource, doc]
                    );
                });
                console.log(colors.green('\n' + proto.operations.length + ' operations available\n'));
                console.log(table.toString())
            } else {
                console.log(colors.bold(colors.red('\nNo operations are available for this protocol, or they cannot be read\n')));
            }
        })
Example #6
0
					reports.forEach(function(report, index){
						// Compare with previous report
						if ( index === reports.length - 1 ) {
							report.iterationsPercentIncrease = ''
						} else {
							report.iterationsPercentIncrease = report.iterationsPercent - reports[index+1].iterationsPercent + '%'
						}
						if ( typeof report.iterationsPercent === 'number' ) {
							report.iterationsPercent += '%'
						}
						if ( typeof report.fasterNextPercent === 'number' ) {
							report.fasterNextPercent += '%'
						}
						if ( typeof report.fasterLastPercent === 'number' ) {
							report.fasterLastPercent += '%'
						}

						table.push([
							report.test,
							report.iterations,
							report.iterationsPercent,
							report.iterationsPercentIncrease,
							report.timePerIteration,
							report.fasterNextPercent,
							report.fasterLastPercent,
							report.duration
						])
					})
 paths.forEach(function(path) {
   var speed = data[path];
   var row = [path, speed.times, ProfileReport.formatNumber(speed.millis / speed.times) + " ms"];
   if (hasSecurity) {
     row.push(ProfileReport.formatNumber(speed.rejected));
   }
   table.push(row);
 });
Example #8
0
  _.each(dataSources, function (dataSource) {

    var currentStatus = dataSource.currentStatus;
    var errorMsg = currentStatus.error && currentStatus.error.userDetail ? currentStatus.error.userDetail : "NONE";
    var dataLength = dataSource.data ? dataSource.data.length : 0;

    table.push([dataSource._id, dataSource.name, dataSource.service.guid, dataSource.service.title, dataSource.endpoint, currentStatus.status, errorMsg, dataLength, moment(dataSource.lastRefreshed).fromNow()]);
  }, this);
Example #9
0
  _.each(list, function (data) {
    var jobId = data._id;
    var appId = data.appid;
    var env = data.environment;
    var status = data.status;

    table.push([jobId, appId, env, status]);
  });
Example #10
0
 docs.forEach(function(doc){
   table.push([
       doc.test_site,
       doc.nt_res_st - doc.nt_req_st,
       doc.nt_domloading - doc.nt_req_st,
       doc.nt_res_end - doc.nt_req_st
   ])
 });
Example #11
0
		sleep_data.forEach(function(record){
		    table.push([
			record.date,
			record.properties.score_amount_of_sleep,
			record.properties.score_sleep_latency,
			record.tags.join(', ').replace(/_/g, ' ')
		    ]);
		});
Example #12
0
        underscore.each(data, function (value) {
            var row = underscore.pick(value, fields);

            if (row.extra !== undefined) {
                row.extra = row.extra.join(" ");
                table.push(underscore.values(row));
            }
        });
Example #13
0
File: app.js Project: mattgrill/cqc
 this.status                 = function(){
   var table = new Table({
     'head' : ['Name', 'Health', 'Broken Bones', 'Cuts', 'Knives', 'Bandages', 'Splints'],
     'colWidths': [8, 8, 15, 6, 8, 10, 9]
   });
   table.push([this.name,this.health,this.broken_bones,this.cuts,this.knives,this.bandages,this.splints]);
   return table;
 }
 writeSummary(pkgVersions, (title, headers, rows) => {
   const table = new CliTable({
     head: headers,
   });
   table.push(...rows);
   console.log(`*** ${title} ***`);
   console.log(table.toString());
 });
Example #15
0
 students.forEach(function(student) {
   table.push([
     student.id,
     student.name,
     student.address,
     student.birth_date.toString('yyyy-MMM-MMM')
   ]);
 });
Example #16
0
  function pushItem(item) {
    item = fields.map(function(field) {
      if (field === 'submitted') return item[field].toLocaleString();
      return item[field] || '';
    });

    asciiTable.push(item);
  }
Example #17
0
 psi(url, { key: 'AIzaSyAbijQJj5ck79PhPpxBdypNr2oy4BupJw0', strategy: 'desktop' }).then(data => {
     count++;
     console.log(count);
     table.push({ "+": [url, data.ruleGroups.SPEED.score, bytesToSize(data.pageStats.htmlResponseBytes), , bytesToSize(data.pageStats.imageResponseBytes)] });
     if (count == listURL.length) {
         console.log(table.toString());
     }
 });
Example #18
0
 _.each(properties, function (prop) {
   prop.guid = prop.guid || "none";
   var max = opts.max || 180;
   if (prop.value.length > max) {
     prop.value = "TRUNCATED TOO LONG TO DISPLAY. Try --json";
   }
   table.push([prop.guid, prop.name, prop.value]);
 }, this);
Example #19
0
		this.ApiDoc.data[this.ApiName].forEach(function(cmd) {
			table.push([
				cmd.cmd,
				(cmd.method != null ? cmd.method : 'any').toUpperCase(),
				cmd.description != null ? cmd.description : '-',
				cmd['return'] != null && cmd['return']['type'] != null ? cmd['return']['type'] : '-'
			]);
		});
Example #20
0
File: list.js Project: moimikey/vcn
        data.map(function(file){
            out = [];
            Object.keys(fields).map(function(field){
                out.push(file[fields[field]]);
            });

            table.push(out);
        });
Example #21
0
  _.each(environments, function(env) {
    var targets = [];
    _.each(env.targets, function(target) {
      targets.push(target._id);
    });

    table.push([env._id, env.label, env.autoDeployOnCreate, env.autoDeployOnUpdate, targets.join(", "), moment(env.modified).fromNow()]);
  }, this);
function generateTable(data) {
	var cliTable = require('cli-table');
	var Docs = require('browser-perf/docs');

	var MAX_IMPORTANCE = 30; 

	var apiDocs = new Docs();
	var decimalPoints = {
		ms: 3,
		count: 0,
		fps: 3,
		percentage: 2,
	}

	var res = [];
	for (var i = 0; i < data.length; i++) {
		res.push('\n\nBrowser: ', data[i]._browserName + '\n');
		var table = new cliTable({
			head: ['Metrics', 'Value', 'Unit', 'Source'],
			colAligns: ['right', 'right', 'left', 'right'],
			colWidths: [35, 20, 10, 15]
		});
		for (var key in data[i]) {
			if (key.indexOf('_') === 0)
				continue;
			if ((apiDocs.getProp(key, 'importance') || 0) < MAX_IMPORTANCE)
				continue;

			var val = data[i][key];
			var unit = '' + (apiDocs.getProp(key, 'unit') || '');
			if (typeof val === 'number') {
				if (typeof decimalPoints[unit] !== 'undefined') {
					val = val.toFixed(decimalPoints[unit]);
				} else {
					val = val + '';
				}
			}

			table.push([key, val + '', unit, '' + (apiDocs.getProp(key, 'source') || '')]);
		}
		table = table.sort(function(a, b) {
			var rankA = apiDocs.getProp(a[0], 'importance') || -1;
			var rankB = apiDocs.getProp(b[0], 'importance') || -1;

			if (rankA === rankB) {
				if (a[3] === b[3]) {
					return a[0] > b[0] ? 1 : -1;
				} else {
					return a[3] > b[3] ? 1 : -1;
				}
			} else {
				return rankA > rankB ? 1 : (rankA < rankB ? -1 : 0);
			}
		})
		res.push(table.toString());
	}
	return res.join('');
}
Example #23
0
 instances.items.forEach(function (instance) {
   var definition = definitions[instance.definitionId];
   table.push([
     instance.id,
     definition.name || '',
     definition.version || '',
     definition.description || ''
   ]);
 });
Example #24
0
lr.on('end', function () {
    var table = new Table({
        head: ["District", "Count", "%"],
        colWidths: [30, 10, 10]
    });

    for (var d in districts) {
        var pct = Math.round(districts[d] / total * 100);
        if (pct > 20) {
            pct = chalk.underline(chalk.red(pct));
        }
        table.push([d, districts[d], pct]);
    }

    table.push(["Total", total, "100"]);

    console.log(table.toString());
});
Example #25
0
exports.createTableForAppEnvVars = function (appEnvVars, envValue) {
  var maxId = 24, maxTS = 20, maxName = 25, maxDevValue = 25, maxLiveValue = 25;
  for (var i = 0; i < appEnvVars.length; i++) {
    var appEnvVar = appEnvVars[i].fields;
    if (strlen(appEnvVar.name) > maxName) {
      maxName = strlen(appEnvVar.name);
    }
    if (strlen(appEnvVar.devValue) > maxDevValue) {
      maxDevValue = strlen(appEnvVar.devValue);
    }
    if (strlen(appEnvVar.liveValue) > maxLiveValue) {
      maxLiveValue = strlen(appEnvVar.liveValue);
    }
  }
  if (maxName > exports.maxTableCell) {
    maxName = exports.maxTableCell;
  }
  if (maxDevValue > exports.maxTableCell) {
    maxDevValue = exports.maxTableCell;
  }
  if (maxLiveValue > exports.maxTableCell) {
    maxLiveValue = exports.maxTableCell;
  }

  var tableHeaders = ['Guid', 'Modified', 'Name'];
  var tableColWidths = [maxId + 2, maxTS + 2, maxName + 2];
  if (!envValue) {
    tableHeaders.push("Dev Value");
    tableHeaders.push("Live Value");
    tableColWidths.push(maxDevValue + 2);
    tableColWidths.push(maxLiveValue + 2);
  } else if ("dev" === envValue) {
    tableHeaders.push("Dev Value");
    tableColWidths.push(maxDevValue + 2);
  } else {
    tableHeaders.push("Live Value");
    tableColWidths.push(maxLiveValue + 2);
  }
  var table = new Table({
    head: tableHeaders,
    colWidths: tableColWidths,
    style: exports.style()
  });

  for (var p = 0; p < appEnvVars.length; p++) {
    var appVar = appEnvVars[p].fields;
    var dataRow = [appVar.guid, moment(appVar.sysCreated, 'YYYY-MM-DD h:mm:ss:SSS').fromNow(), appVar.name];
    if (appVar.devValue) {
      dataRow.push(appVar.devValue);
    }
    if (appVar.liveValue) {
      dataRow.push(appVar.liveValue);
    }
    table.push(dataRow);
  }
  return table;
};
Example #26
0
  _.each((logSearchResults.hits || {}).hits || [], function(logEntry) {
    var messages = _.pick(logEntry._source, 'msg', 'error', 'err', 'message');

    messages = _.map(_.compact(messages), function(message) {
      return message.replace(/\r?\n|\r/g,'');
    });

    table.push([logEntry._source.time, messages.join(' '), logEntry._source.level]);
  }, this);
Example #27
0
 logPromptResults: function() {
     var table = new Table();
     table.push({
         'Course Name': this.settings.courseName
     }, {
         'Course Directory': this.settings.courseDirectory
     });
     this.log(table.toString());
 },
Example #28
0
 _.each(result.diagnostics, function (diagnostic) {
   table.push([
     diagnostic.storeId,
     diagnostic.fetchId,
     diagnostic.status,
     diagnostic.time,
     JSON.stringify(diagnostic.result || diagnostic.error || {}, null, 2)
   ]);
 });
Example #29
0
 _.each(assets, function(x){
   t.push([x.symbol
     , ac.c(x.cost_basis)
     //, x.equity ? ac.c(x.cost_basis/net_equity*100) : '-'
     , ac.c(x.current * x.quantity)
     , ac.c(x.cost_basis/net_worth*100)
     , ac.c(x.current*x.quantity/total_worth*100)
     ])
 })
    connection.query(query, function(err, res) {
        console.log(res.length + " matches found!");
        for (var i = 0; i < res.length; i++) {
        newtable.push(
			    [res[i].DepartmentID, res[i].DepartmentName, res[i].OverHeadCosts, res[i].TotalSales, res[i].TotalSales - res[i].OverHeadCosts]
			);
	    }
	    console.log(newtable.toString());
    });