<commit_before>var util = require('util');

/**
 * Inspect the output of the previous task.
 * This can be used to debug the build chain or provide extra output in the build process.
 *
 * @method log
 * @param spec {Object} .message - message to prefix the current state.
 * @param promise {EventEmitter}
 * @protected
 */
function inspectTask(spec, promise) {

    if (spec && spec.hasOwnProperty('message')) {
        util.log(spec.message);
    }

    if (this._state) {
        util.log(this._state.get().value);
    } else {
        util.log('No output to log from previous task');
    }

    promise.emit('complete', 'log', ''); // TODO: Maybe this should be the log output? the event arg
}

exports.tasks = {
    'inspect' : {
        callback: inspectTask
    }
};<commit_msg>Rewrote the inspect task to deal with all types and provide non-timestamped output.<commit_after>/**
 * Inspect the output from the previous task.
 *
 * ---
 * INPUTS:
 *
 *  - FILES
 *  Output filenames, one per line.
 *
 *  - STRINGS
 *  Output strings, separated by line feeds.
 *
 *  - STRING
 *  Output string.
 *
 *  - UNDEFINED
 *  Output a message about being undefined.
 *
 * OUTPUT:
 *
 *  - FILES|STRINGS|STRING
 *  Same data as the input, untouched.
 * ---
 */

var util = require('util'),
    State = require('buildy/lib/state');

/**
 * Inspect the output of the previous task.
 * This can be used to debug the build chain or provide extra output in the build process.
 *
 * @method log
 * @param spec {Object}
 * @param spec.header {String} Message to be logged prior to the input contents.
 * @param spec.footer {String} Message to be logged after the input contents.
 * @param spec.depth {Integer} How much to recurse when inspecting an object
 * @param spec.show_hidden {Boolean} [show_hidden=false] Show an objects non enumerable properties.
 * @param promise {EventEmitter}
 * @protected
 */
function inspectTask(spec, promise) {

    spec = spec || {};

    spec.depth = spec && spec.depth || 2;
    spec.show_hidden = spec && spec.show_hidden || false;

    if (spec && spec.header) {
        console.log(spec.header);
    }

    switch (this._state.get().type) {

        case State.TYPES.FILES:
            util.log(this._state.get().type);
            this._state.get().value.forEach(function(filename) {
                console.log(filename);
            });
            break;

        case State.TYPES.STRINGS:
            util.log(this._state.get().type);
            this._state.get().value.forEach(function(str) {
                console.log(str);
            });
            break;

        case State.TYPES.STRING:
            util.log(this._state.get().type);
            console.log(this._state.get().value);

            break;

        case State.TYPES.UNDEFINED:
            util.log(this._state.get().type);
            console.log('No output to display for type UNDEFINED');

            break;

        default:

    }

    if (spec && spec.footer) {
        console.log(spec.footer);
    }

    promise.emit('complete', 'inspect', ''); // TODO: Maybe this should be the log output? the event arg
}

exports.tasks = {
    'inspect' : {
        callback: inspectTask
    }
};
{'fraction_non_alphanumeric': 0.1284375, 'fraction_numerical': 0.0003125, 'mean_word_length': 2.3730242360379346, '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': '768854', 'n_tokens_mistral': 956, 'n_tokens_neox': 936, 'n_words': 281}