<commit_before>
var fs = require('fs'),
    path = require('path'),
    mkdirp = require('mkdirp'),
    exec = require('child_process').exec,
    rimraf = require('rimraf'),
    express = require('express');
    base = path.join(process.cwd(), 'tests'),
    covDir = '/tmp/yui-coverage/';

require('colors');

if (!path.existsSync('./tests')) {
    console.error("Not inside a module directory: cd yui3/src/yui; yui-coverage".red.bold);
    process.exit(1);
}

process.on('SIGINT', function() {
    console.error('Cleaning up tmp files'.magenta);
    rimraf(covDir, function() {
        console.error('Cleanup complete'.white);
        process.exit(0);
    });
});

var moduleName = path.basename(process.cwd());

var mods = {};
mods[moduleName] = true;

if (moduleName === 'yui') {
    mods['yui-core'] = true;
}

var modules = [];

var meta = JSON.parse(fs.readFileSync(path.join('./meta', moduleName + '.json')));

for (var i in meta[moduleName]) {
    switch (i) {
        case 'use':
            meta[moduleName].use.forEach(function(k) {
                mods[k] = true;
            });
            break;
        case 'submodules':
        case 'plugins':
            Object.keys(meta[moduleName][i]).forEach(function(k) {
                mods[k] = true;
            });
            break;
    }
}

modules = Object.keys(mods);

var app = express.createServer();
app.configure(function() {
    app.use(express.bodyParser());
});

var io = require('socket.io').listen(app);
io.set('log level', 1);

var resultSocket;

io.sockets.on('connection', function (socket) {
    resultSocket = socket;
});


app.get('/', function(req, res, next) {
    fs.readdir(base, function(err, d) {
        var files = [];
        d.forEach(function(file) {
            var ext = path.extname(file);
            if (ext.indexOf('htm') > 0) {
                files.push(file);
            }
        });
        if (files.length > 1) {
            var str = '<h1>Choose your test file</h1><ul>';<commit_msg>Fixed meta walking logic to grab meta for modules with multiple keys<commit_after>
var fs = require('fs'),
    path = require('path'),
    mkdirp = require('mkdirp'),
    exec = require('child_process').exec,
    rimraf = require('rimraf'),
    express = require('express');
    base = path.join(process.cwd(), 'tests'),
    covDir = '/tmp/yui-coverage/';

require('colors');

if (!path.existsSync('./tests')) {
    console.error("Not inside a module directory: cd yui3/src/yui; yui-coverage".red.bold);
    process.exit(1);
}

process.on('SIGINT', function() {
    console.error('Cleaning up tmp files'.magenta);
    rimraf(covDir, function() {
        console.error('Cleanup complete'.white);
        process.exit(0);
    });
});

var moduleName = path.basename(process.cwd());

var mods = {};
//mods[moduleName] = true;

if (moduleName === 'yui') {
    mods['yui-core'] = true;
}

var modules = [];

var meta = JSON.parse(fs.readFileSync(path.join('./meta', moduleName + '.json')));


for (var i in meta) {
    mods[i] = true;
    for (var m in meta[i]) {
        switch (m) {
            case 'use':
                meta[i].use.forEach(function(k) {
                    mods[k] = true;
                });
                break;
            case 'submodules':
            case 'plugins':
                Object.keys(meta[i][m]).forEach(function(k) {
                    mods[k] = true;
                });
                break;
        }
    }
}

modules = Object.keys(mods).sort();

var app = express.createServer();
app.configure(function() {
    app.use(express.bodyParser());
});

var io = require('socket.io').listen(app);
io.set('log level', 1);

var resultSocket;

io.sockets.on('connection', function (socket) {
    resultSocket = socket;
});


app.get('/', function(req, res, next) {
    fs.readdir(base, function(err, d) {
        var files = [];
        d.forEach(function(file) {
            var ext = path.extname(file);
            if (ext.indexOf('htm') > 0) {
                files.push(file);
            }
        });
        if (files.length > 1) {
            var str = '<h1>Choose your test file</h1><ul>';
{'fraction_non_alphanumeric': 0.17928190198932556, 'fraction_numerical': 0.0038816108685104317, 'mean_word_length': 2.3684640522875817, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '4571830', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1322, 'n_words': 273}