/**
 * The-M-Project Build Script
 * Version: 0.1.0
 */

var _ = require('lodash');

var path = require('path');

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

    var additionalMarkdownFiles = {};

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            banner: '/*!\n' +
                '* Project:   Bikini - Everything a model needs\n' +
                '* Copyright: (c) <%= grunt.template.today("yyyy") %> M-Way Solutions GmbH.\n' +
                '* Version:   <%= pkg.version %>\n' +
                '* Date:      <%= grunt.template.today() %>\n' +
                '* License:   https://raw.githubusercontent.com/mwaylabs/bikini/master/MIT-LICENSE.txt\n' +
                '*/'
        },
        jsonlint: {
            sample: {
                src: [ 'package.json', 'bower.json' ]
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                ignores: ['src/_*.js', 'src/bikini*.js' ]
            },
            src: [ 'src/**/*.js' ]
        },
        preprocess: {
            options: {
                context: {
                    BANNER: '<%= meta.banner %>',
                    VERSION: '<%= pkg.version %>'
                }
            },
            dev: {
                files: {
                    '.tmp/bikini.js': 'src/bikini.js'
                }
            },
            dist: {
                files: {
                    'dist/bikini.js': 'src/bikini.js',
                    'dist/bikangular.js': 'bikangular/bikangular.js'
                }
            }
        },
        uglify: {
            options: {
                preserveComments: 'some'
            },
            core: {
                src: 'dist/bikini.js',
                dest: 'dist/bikini.min.js',
                options: {
                    sourceMap: 'dist/bikini.map',
                    sourceMappingURL: 'bikini.map',
                    sourceMapPrefix: 1
                }
            }
        },
        watch: {
            js: {
                files: ['src/**/*'],
                tasks: ['build-js'],
                options: {
                    spawn: false
                }
            },
            test: {
                files: ['test/**/*'],
                tasks: ['test'],
                options: {
                    spawn: false
                }
            }
        },
        mocha: {
            options: {
                bail: true,
                reporter: "Spec"
            },
            all: ['test/test.html']
        },
        jsdoc : {
            dist : {
                src: ['dist/bikini.js'],
                options:{
                    destination: 'doc',
                    private: false
                }
            }
        },
        'curl-dir': {
            customFilepaths: {
                src: (function() {
                    return Object.keys(additionalMarkdownFiles);
                })(),
                router: function (url) {
                    return additionalMarkdownFiles[url];
                },
                dest: 'doc-template/additional'
            }
        },
        clean: {
            md: {
                src: [
                    'doc-template/additional/Sample-Apps.md',
                    'doc-template/additional/Demo-App.md',
                    'doc-template/additional/Generator.md',
                    'doc-template/.tmp/index.md'
                ]
            }
        },
        express: {
            test: {
              options: {
                script: './server/server.js'
              }
            }
        },
        'gh-pages': {
		    options: {
		      base: 'doc'
		    },
		    src: ['**']
		  }
    });


    grunt.loadTasks('tasks');

    grunt.loadNpmTasks('grunt-express-server');

    grunt.registerTask('build', ['preprocess:dev', ]);

    grunt.registerTask('dev', ['default', 'watch']);
    grunt.registerTask('test', ['jshint', 'build',/*'express:test',*/ 'mocha']);
    grunt.registerTask('dist', ['jshint', 'preprocess:dist', 'uglify', 'build-doc']);
    grunt.registerTask('precommit', ['travis']);
    grunt.registerTask('travis', ['jsonlint', 'default', 'test']);
    grunt.registerTask('default', ['build']);

    grunt.registerTask('build-doc', ['clean:md','curl-dir', 'rewriteMarkdownFiles', 'jsdoc', 'clean:md', 'gh-pages']);

};

@@ -2746,17 +2746,16 @@
    jsdoc
- 
 : %7B%0A    
@@ -2766,17 +2766,16 @@
     dist
- 
 : %7B%0A    
@@ -2835,16 +2835,17 @@
 options:
+ 
 %7B%0A      
@@ -3039,16 +3039,17 @@
 function
+ 
 () %7B%0A   
@@ -3698,32 +3698,34 @@
 %7B%0A              
+  
 options: %7B%0A     
@@ -3711,32 +3711,36 @@
      options: %7B%0A
+    
                 
@@ -3764,24 +3764,26 @@
 /server.js'%0A
+  
             
@@ -3829,26 +3829,32 @@
 h-pages': %7B%0A
-%09%09
+        
     options:
@@ -3856,18 +3856,26 @@
 ions: %7B%0A
-%09%09
+          
       ba
@@ -3888,19 +3888,31 @@
 oc'%0A
-%09%09    %7D,%0A%09%09
+            %7D,%0A        
     
@@ -3927,10 +3927,14 @@
 *'%5D%0A
-%09%09
+      
   %7D%0A
@@ -4072,18 +4072,16 @@
 ess:dev'
-, 
 %5D);%0A%0A   
@@ -4180,16 +4180,17 @@
 'build',
+ 
 /*'expre
@@ -4509,16 +4509,17 @@
 ean:md',
+ 
 'curl-di

reformat code