{"size": 911, "ext": "js", "max_stars_repo_path": "tasks/modules/file-analyzer.js", "max_stars_repo_name": "tdeekens/grunt-weightwatchsy", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tasks/modules/file-analyzer.js", "max_issues_repo_name": "tdeekens/grunt-weightwatchsy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tasks/modules/file-analyzer.js", "max_forks_repo_name": "tdeekens/grunt-weightwatchsy", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.8043478261, "max_line_length": 58, "alphanum_fraction": 0.6849615807}
'use strict';

var fs = require('fs');
var path = require('path');
var _ = require('lodash');

function FileAnalyzer(exclusions) {
  this._exclusions = exclusions;
}

FileAnalyzer.prototype.getFiles = function(globbedFiles) {
  var files = [];

  globbedFiles.forEach(function(file) {
    files = file.src.filter(function(filepath) {
      return fs.lstatSync(filepath).isFile();
    }).map(function(filepath) {
      return filepath;
    });
  });

  return files;
};

FileAnalyzer.prototype.shuntAll = function(files) {
  var _this = this;

  return _.filter(files, function(file) {
    return !_this.isExcluded(file);
  });
};

FileAnalyzer.prototype.getExtension = function(file) {
  return path.extname(file);
};

FileAnalyzer.prototype.isExcluded = function(file) {
  var extension = this.getExtension(file);

  return (
    _.includes(this._exclusions, extension)
  );
};

module.exports = FileAnalyzer;
