// Generated by CoffeeScript 1.8.0
(function() {
  var Table, i18n, sloc,
    __slice = [].slice,
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  Table = require('cli-table');

  i18n = require('../i18n');

  sloc = require('../sloc');

  module.exports = function(data, options, fmtOpts) {
    var f, head, heads, k, keys, s, statToArray, table, _i, _len, _ref;
    keys = options.keys || sloc.keys;
    heads = options.details ? ['Path'].concat(__slice.call(keys)) : keys;
    head = __indexOf.call(fmtOpts, 'no-head') >= 0 ? [] : (function() {
      var _i, _len, _results;
      _results = [];
      for (_i = 0, _len = heads.length; _i < _len; _i++) {
        k = heads[_i];
        _results.push(i18n.en[k]);
      }
      return _results;
    })();
    table = new Table({
      head: head
    });
    statToArray = function(d) {
      var _i, _len, _results;
      _results = [];
      for (_i = 0, _len = keys.length; _i < _len; _i++) {
        k = keys[_i];
        _results.push(d[k]);
      }
      return _results;
    };
    if (options.details) {
      _ref = data.files;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        f = _ref[_i];
        table.push([f.path].concat(__slice.call(statToArray(f.stats))));
      }
    } else if ((s = data.summary) != null) {
      table.push(statToArray(s));
    }
    return table.toString();
  };

}).call(this);
