config/grunt/tasks/generate_db.js
function createAnimationObject(categoryName, fileName){
    var animation,
        inputFilepath = config.src + categoryName + '/' + fileName + '.css',
        inputPlainFilepath = config.unprefixedSrc + categoryName + '/' + fileName + '.css',
        outpuFilepath = config.dest + categoryName + '/' + 'db_'+ fileName + '.json',
        currentFileSource,
        currentFilePlainSource,
        metadataObject;

    // read the file
    currentFileSource = grunt.file.read(inputFilepath);
    currentFilePlainSource = grunt.file.read(inputPlainFilepath);

    // extract relevant data
    animation = parseString(currentFileSource);

    // TODO: quitar los comentarios antes de guardarlo
    if(animation.length > 0){
      animation = animation[0];
      animation.cssCode = new CleanCSS({
        noAdvanced:false,
        aggressiveMerging:false,
        keepBreaks:true
      }).minify(currentFileSource);

      animation.plainCssCode = new CleanCSS({
        noAdvanced:false,
        aggressiveMerging:false,
        keepBreaks:true
      }).minify(currentFilePlainSource);
      animation.cssCode = beautify_css(animation.cssCode, { indent_size: 2 });
      animation.plainCssCode = beautify_css(animation.plainCssCode, { indent_size: 2 });
    }

    // write destiny
    grunt.file.write(outpuFilepath, JSON.stringify(animation, null, 4));
  }
function createAnimationObject(categoryName, fileName){
    var animation,
        inputFilepath = config.src + categoryName + '/' + fileName + '.css',
        inputPlainFilepath = config.unprefixedSrc + categoryName + '/' + fileName + '.css',
        outpuFilepath = config.dest + categoryName + '/' + 'db_'+ fileName + '.json',
        currentFileSource,
        currentFilePlainSource,
        metadataObject;

    // read the file
    currentFileSource = grunt.file.read(inputFilepath);
    currentFilePlainSource = grunt.file.read(inputPlainFilepath);

    // extract relevant data
    animation = parseString(currentFileSource);

    // TODO: quitar los comentarios antes de guardarlo
    if(animation.length > 0){
      animation = animation[0];
      animation.cssCode = new CleanCSS({
        noAdvanced:false,
        aggressiveMerging:false,
        keepBreaks:true
      }).minify(currentFileSource);

      animation.plainCssCode = new CleanCSS({
        noAdvanced:false,
        aggressiveMerging:false,
        keepBreaks:true
      }).minify(currentFilePlainSource);
      animation.cssCode = beautify_css(animation.cssCode, { indent_size: 2 });
      animation.plainCssCode = beautify_css(animation.plainCssCode, { indent_size: 2 });
    }

    // write destiny
    grunt.file.write(outpuFilepath, JSON.stringify(animation, null, 4));
  }
function createAnimationObject ( categoryName , fileName ) { var animation , inputFilepath = config . src + categoryName + '/' + fileName + '.css' , inputPlainFilepath = config . unprefixedSrc + categoryName + '/' + fileName + '.css' , outpuFilepath = config . dest + categoryName + '/' + 'db_' + fileName + '.json' , currentFileSource , currentFilePlainSource , metadataObject ; // read the file currentFileSource = grunt . file . read ( inputFilepath ) ; currentFilePlainSource = grunt . file . read ( inputPlainFilepath ) ; // extract relevant data animation = parseString ( currentFileSource ) ; // TODO: quitar los comentarios antes de guardarlo if ( animation . length > 0 ) { animation = animation [ 0 ] ; animation . cssCode = new CleanCSS ( { noAdvanced : false , aggressiveMerging : false , keepBreaks : true } ) . minify ( currentFileSource ) ; animation . plainCssCode = new CleanCSS ( { noAdvanced : false , aggressiveMerging : false , keepBreaks : true } ) . minify ( currentFilePlainSource ) ; animation . cssCode = beautify_css ( animation . cssCode , { indent_size : 2 } ) ; animation . plainCssCode = beautify_css ( animation . plainCssCode , { indent_size : 2 } ) ; } // write destiny grunt . file . write ( outpuFilepath , JSON . stringify ( animation , null , 4 ) ) ; }
Create and save the animation object as json
@author Dariel Noel <darielnoel@gmail.com>
@since  2015-03-10
@param  {[type]}   categoryName [description]
@param  {[type]}   fileName     [description]
@return {[type]}                [description]
Create and save the animation object as json