tasks/faker.js
function getFunctionNameAndArgs(value) {
    var pattern = /^(.*)\{\{([^()]+?)(\((.+)\))?\}\}(.*)$/g,
    match, func, args;
    var argArray = [], surroundings = [];
    var retValue;

    while (match = pattern.exec(value)) {
      surroundings[0] = match[1];
      func = match[2];
      args = match[4];
      surroundings[1] = match[5];
    }

    if (args !== undefined ){
      if (args.indexOf("[") !== -1){
        // is an array as string
        args = JSON.parse(args);
        argArray.push(args);
      } else {
        // one or more string/number params
        args = args.replace(/, /gi, ",");
        args = args.replace(/'/gi, "", "gi");
        argArray = args.split(',');
      }
    }
    // return value if no Faker method is detected
    retValue = func ?
      executeFunctionByName(func,argArray) :
      value;

    if(surroundings[0]) {	// prefix
      retValue = surroundings[0] + retValue;
    }

    if(surroundings[1]) {	// postfix
      retValue += surroundings[1];
    }

    return retValue;
  }
function getFunctionNameAndArgs(value) {
    var pattern = /^(.*)\{\{([^()]+?)(\((.+)\))?\}\}(.*)$/g,
    match, func, args;
    var argArray = [], surroundings = [];
    var retValue;

    while (match = pattern.exec(value)) {
      surroundings[0] = match[1];
      func = match[2];
      args = match[4];
      surroundings[1] = match[5];
    }

    if (args !== undefined ){
      if (args.indexOf("[") !== -1){
        // is an array as string
        args = JSON.parse(args);
        argArray.push(args);
      } else {
        // one or more string/number params
        args = args.replace(/, /gi, ",");
        args = args.replace(/'/gi, "", "gi");
        argArray = args.split(',');
      }
    }
    // return value if no Faker method is detected
    retValue = func ?
      executeFunctionByName(func,argArray) :
      value;

    if(surroundings[0]) {	// prefix
      retValue = surroundings[0] + retValue;
    }

    if(surroundings[1]) {	// postfix
      retValue += surroundings[1];
    }

    return retValue;
  }
function getFunctionNameAndArgs ( value ) { var pattern = / ^(.*)\{\{([^()]+?)(\((.+)\))?\}\}(.*)$ / g , match , func , args ; var argArray = [ ] , surroundings = [ ] ; var retValue ; while ( match = pattern . exec ( value ) ) { surroundings [ 0 ] = match [ 1 ] ; func = match [ 2 ] ; args = match [ 4 ] ; surroundings [ 1 ] = match [ 5 ] ; } if ( args !== undefined ) { if ( args . indexOf ( "[" ) !== - 1 ) { // is an array as string args = JSON . parse ( args ) ; argArray . push ( args ) ; } else { // one or more string/number params args = args . replace ( / ,  / gi , "," ) ; args = args . replace ( / ' / gi , "" , "gi" ) ; argArray = args . split ( ',' ) ; } } // return value if no Faker method is detected retValue = func ? executeFunctionByName ( func , argArray ) : value ; if ( surroundings [ 0 ] ) { // prefix retValue = surroundings [ 0 ] + retValue ; } if ( surroundings [ 1 ] ) { // postfix retValue += surroundings [ 1 ] ; } return retValue ; }
Get func name, extract args, and exec on their values
Get func name extract args and exec on their values