<commit_before>var path = require('path')
,	proc = require('child_process')
,	url = require('url')
,	http = require('http')
,   headless = require('headless')
,   ejs = require('ejs')
,   fs = require('fs');

var  filters = rootRequire('lib/ejs-filters')
;

filters.loadFilters(ejs);

var Checker = function () {};

Checker.prototype.check = function (options) {
	//accepted options:
	//	- url : URL for a document to load
	//	- profile : smartphone profile
    //  - lang : language for translation
	//	- checklist : array of checks to do
	//	- events : where to send the various events
	if(!options.events) return this.throw("The events option is required for reporting.");
	if(!options.url) return this.throw("Without url there is nothing to check.");
    // Read from profiles directory instead?
    var validProfiles = ['default', 'smartphone2', 'tablet'];

    if(!options.profile || validProfiles.indexOf(options.profile) === -1) {
        options.profile = 'default';
    }
     var profile = require('./profiles/' + options.profile + '.json')
    ,	sink = options.events
    ,	checklist = options.checklist
    ,   resume = {
            ok : 0
        ,   issues : 0
        }
    ,	self = this
    ;
    self.profile = profile;
    self.sink = sink;
    self.checklist = checklist;
    self.resume = resume;
    self.options = options;
    this.emulateBrowser(profile, options.url, options.id);
};
Checker.prototype.emulateBrowser = function (profile, url, id, callback) {
    var self = this;
    var opt = {display: {width: profile.width, height: profile.height}};
    headless(opt,function(err, childProcess, servernum) {<commit_msg>read from profiles directory instead tab<commit_after>var path = require('path')
,	proc = require('child_process')
,	url = require('url')
,	http = require('http')
,   headless = require('headless')
,   ejs = require('ejs')
,   fs = require('fs');

var  filters = rootRequire('lib/ejs-filters')
;

filters.loadFilters(ejs);

var Checker = function () {};

Checker.prototype.check = function (options) {
	//accepted options:
	//	- url : URL for a document to load
	//	- profile : smartphone profile
    //  - lang : language for translation
	//	- checklist : array of checks to do
	//	- events : where to send the various events
    //  - id : generated id to save an unique screenshot
	if(!options.events) return this.throw("The events option is required for reporting.");
	if(!options.url) return this.throw("Without url there is nothing to check.");
    if(!options.checklist) return this.throw("Without checklist there is nothing to check");
    if(!options.id) return this.throw("Without id, the app can't generate screenshot");
    // Read from profiles directory instead?
    var validProfiles = new Array();
    fs.readdir(path.join(__dirname, "profiles"), function (err, files){
        validProfiles = files;
    });

    if(!options.profile || validProfiles.indexOf(options.profile) === -1) {
        options.profile = 'default';
    }
     var profile = require('./profiles/' + options.profile + '.json')
    ,	sink = options.events
    ,	checklist = options.checklist
    ,   resume = {
            ok : 0
        ,   issues : 0
        }
    ,	self = this
    ;
    self.profile = profile;
    self.sink = sink;
    self.checklist = checklist;
    self.resume = resume;
    self.options = options;
    this.emulateBrowser(profile, options.url, options.id);
};
Checker.prototype.emulateBrowser = function (profile, url, id, callback) {
    var self = this;
    var opt = {display: {width: profile.width, height: profile.height}};
    headless(opt,function(err, childProcess, servernum) {
{'fraction_non_alphanumeric': 0.13882030178326474, 'fraction_numerical': 0.0019204389574759945, 'mean_word_length': 3.1478953356086463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1918500', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1087, 'n_words': 307}