<commit_before>/*
 * grunt-ng-json2js
 * https://github.com/mbcooper/grunt-ng-json2js
 *
 * Copyright (c) 2014 mbcooper
 * Licensed under the MIT license.
 */

'use strict';

var MODULE_NAME = 'ng_json2js';
var util = require('util');
var _ = require('lodash');

module.exports = function (grunt) {

    function requiredOptions(options, properties) {
        var pluralize = grunt.util.pluralize;
        var missing = properties.filter(function (key) {
            return !options[key];
        });

        if (!_.isEmpty(missing)) {
            throw grunt.util.error('Required option property' + pluralize(missing.length, 'y/ies') + ' ' + missing.join(', ') + ' is missing');
        }
    }

    // Please see the Grunt documentation for more information regarding task
    // creation: http://gruntjs.com/creating-tasks

    grunt.registerMultiTask(MODULE_NAME, 'Converts json to AngularJS modules for test fixtures', function () {
        // Merge task-specific and/or target-specific options with these defaults.
        var options = this.options({
            stripPrefix: '',
            prependPrefix: ''
        });

        var TEMPLATE = 'angular.module(\'%s\', []).value(\'%s\', %s);\n';

        // Iterate over all specified file groups.
        this.files.forEach(function (f) {
            _.each(f.src, function (sourceFile) {

                if (!grunt.file.exists(sourceFile)) {
                    grunt.log.warn('Source file "' + sourceFile + '" not found.');

                } else {
                    var src = grunt.file.read(sourceFile);
                    var jsonPath = sourceFile;

                    var moduleName = (options.stripPrefix) ?
                        jsonPath.replace(options.stripPrefix, '') :
                        jsonPath;

                    moduleName = (options.prependPrefix) ?
                    options.prependPrefix + moduleName :
                        moduleName;

                    var valueName = jsonPath.replace(/\.json$/, '');

                    valueName = valueName.replace(/(?:-|\/)([a-zA-Z0-9])/g, function (all, letter) {
                        return letter.toUpperCase();
                    });


                    var outputPath = jsonPath.replace(/\.json$/, '') + '.js';
                    var output = util.format(TEMPLATE, moduleName, valueName, src);

                    // delete destination if it exists
                    if (grunt.file.exists(outputPath)) {
                        grunt.file.delete(outputPath);
                    }
                    // Write the destination file.

                    grunt.file.write(outputPath, output);

                    // Print a success message.
                    grunt.log.writeln('File "' + outputPath + '" created.');
                }

            });

        });
    });

};
<commit_msg>Adds lodash dep<commit_after>/*
 * grunt-ng-json2js
 * https://github.com/mbcooper/grunt-ng-json2js
 *
 * Copyright (c) 2014 mbcooper
 * Licensed under the MIT license.
 */

'use strict';

var MODULE_NAME = 'ng_json2js';
var util = require('util');
var _ = require('lodash');

module.exports = function (grunt) {

    function requiredOptions(options, properties) {
        var pluralize = grunt.util.pluralize;
        var missing = properties.filter(function (key) {
            return !options[key];
        });
        if (!_.isEmpty(missing)) {
            throw grunt.util.error('Required option property' + pluralize(missing.length, 'y/ies') + ' ' + missing.join(', ') + ' is missing');
        }
    }

    // Please see the Grunt documentation for more information regarding task
    // creation: http://gruntjs.com/creating-tasks

    grunt.registerMultiTask(MODULE_NAME, 'Converts json to AngularJS modules for test fixtures', function () {
        // Merge task-specific and/or target-specific options with these defaults.
        var options = this.options({
            stripPrefix: '',
            prependPrefix: ''
        });

        var TEMPLATE = 'angular.module(\'%s\', []).value(\'%s\', %s);\n';

        // Iterate over all specified file groups.
        this.files.forEach(function (f) {
            _.each(f.src, function (sourceFile) {

                if (!grunt.file.exists(sourceFile)) {
                    grunt.log.warn('Source file "' + sourceFile + '" not found.');

                } else {
                    var src = grunt.file.read(sourceFile);
                    var jsonPath = sourceFile;

                    var moduleName = (options.stripPrefix) ?
                        jsonPath.replace(options.stripPrefix, '') :
                        jsonPath;

                    moduleName = (options.prependPrefix) ?
                    options.prependPrefix + moduleName :
                        moduleName;

                    var valueName = jsonPath.replace(/\.json$/, '');

                    valueName = valueName.replace(/(?:-|\/)([a-zA-Z0-9])/g, function (all, letter) {
                        return letter.toUpperCase();
                    });

                    var outputPath = jsonPath.replace(/\.json$/, '') + '.js';
                    var output = util.format(TEMPLATE, moduleName, valueName, src);

                    // delete destination if it exists
                    if (grunt.file.exists(outputPath)) {
                        grunt.file.delete(outputPath);
                    }
                    // Write the destination file.

                    grunt.file.write(outputPath, output);

                    // Print a success message.
                    grunt.log.writeln('File "' + outputPath + '" created.');
                }

            });

        });
    });

};

{'fraction_non_alphanumeric': 0.12925886898489639, 'fraction_numerical': 0.003161222339304531, 'mean_word_length': 1.5921711424670004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1636439', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1466, 'n_words': 330}