<commit_before>/***********************************************************************
 * This class copies bower dependencies to the specified destination
 * Author: Copyright 2012-2014, <NAME>
 * License: MIT
 ***********************************************************************/
//TODO: add bower package filter to limit which bower packages are consumed
/**
 * Bower Map Class
 * @param grunt
 * @param bowerPath
 * @param destPath
 * @param shim
 * @param map
 * @param replace
 * @param ignore
 * @param maintainCommonPaths
 * @param useNamespace
 * @param extensions
 * @param done
 * @returns { BowerMap }
 * @constructor
 */
module.exports = function BowerMap( grunt, bowerPath, destPath, shim, map, replace, ignore,
                                    maintainCommonPaths, useNamespace, extensions, done ) {

	'use strict';

	/*================================================
	 * Dependencies
	 *===============================================*/
	var bower = require( 'bower' );
	var path = require( 'path' );
	var glob = require( 'glob' );

	/*================================================
	 * Public Attributes
	 *===============================================*/


	/*================================================
	 * Private Attributes
	 *===============================================*/
	var expandedMap = {};

	var pathSepRegExp = /[\\\/]/gi;

	path.fix = function( val ){
		return path.normalize( val.replace( pathSepRegExp, path.sep ) );
	};

	/*================================================
	 * Public Methods
	 *===============================================*/
	this.execute = function() {

		grunt.verbose.writeln( 'BowerMap::execute' );

		//first make sure everything needed is set
		if ( validateParameters() ) {

			//expand map
			expandedMap = expandMap( map );

			//get component paths
			bower.commands.list( {paths: true} )
					.on( 'end', handleListResults );
		}

	};


	/*================================================
	 * Private Methods
	 *===============================================*/
	/**
	 * copies file and re
	 * @param src
	 * @param dest
	 * @param replacements
	 */
	function copyReplace( src, dest, replacements ){

		var source = grunt.file.read( src );
		for ( var s in replacements ){
			var r = replacements[s];
			var re = new RegExp( s, "g" );
			source = source.replace( re, r );
		}
		grunt.file.write( dest, source );

	}


	/**
	 * validates bower copy task parameters
	 * @returns {boolean}
	 */
	function validateParameters() {
		grunt.verbose.writeln( 'BowerMap::validateParameters' );
		//flag used to determine if validation passes
		var check = true;
<commit_msg>use grunt copy if replacements is false<commit_after>/***********************************************************************
 * This class copies bower dependencies to the specified destination
 * Author: Copyright 2012-2014, <NAME>
 * License: MIT
 ***********************************************************************/
//TODO: add bower package filter to limit which bower packages are consumed
/**
 * Bower Map Class
 * @param grunt
 * @param bowerPath
 * @param destPath
 * @param shim
 * @param map
 * @param replace
 * @param ignore
 * @param maintainCommonPaths
 * @param useNamespace
 * @param extensions
 * @param done
 * @returns { BowerMap }
 * @constructor
 */
module.exports = function BowerMap( grunt, bowerPath, destPath, shim, map, replace, ignore,
                                    maintainCommonPaths, useNamespace, extensions, done ) {

	'use strict';

	/*================================================
	 * Dependencies
	 *===============================================*/
	var bower = require( 'bower' );
	var path = require( 'path' );
	var glob = require( 'glob' );

	/*================================================
	 * Public Attributes
	 *===============================================*/


	/*================================================
	 * Private Attributes
	 *===============================================*/
	var expandedMap = {};

	var pathSepRegExp = /[\\\/]/gi;

	path.fix = function( val ){
		return path.normalize( val.replace( pathSepRegExp, path.sep ) );
	};

	/*================================================
	 * Public Methods
	 *===============================================*/
	this.execute = function() {

		grunt.verbose.writeln( 'BowerMap::execute' );

		//first make sure everything needed is set
		if ( validateParameters() ) {

			//expand map
			expandedMap = expandMap( map );

			//get component paths
			bower.commands.list( {paths: true} )
					.on( 'end', handleListResults );
		}

	};


	/*================================================
	 * Private Methods
	 *===============================================*/
	/**
	 * copies file and re
	 * @param src
	 * @param dest
	 * @param replacements
	 */
	function copyReplace( src, dest, replacements ){

        if ( replacements ){
            var source = grunt.file.read( src );
            for ( var s in replacements ){
                var r = replacements[s];
                var re = new RegExp( s, "g" );
                source = source.replace( re, r );
            }
            grunt.file.write( dest, source );
        }
        else{
            grunt.file.copy( src, dest );
        }

	}


	/**
	 * validates bower copy task parameters
	 * @returns {boolean}
	 */
	function validateParameters() {
		grunt.verbose.writeln( 'BowerMap::validateParameters' );
		//flag used to determine if validation passes
		var check = true;

{'fraction_non_alphanumeric': 0.32449127906976744, 'fraction_numerical': 0.0029069767441860465, 'mean_word_length': 3.6613039796782387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4849868', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1318, 'n_words': 400}