<commit_before>// Generated on 2013-09-19 using generator-angular 0.4.0
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
    port: LIVERELOAD_PORT
});

var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

var fs = require('fs');

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // configurable paths
    var yeomanConfig = {
        app: 'app',
        dist: 'dist',
        doc: 'doc'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            coffee: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.coffee'],
                tasks: ['coffee:test']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css',
                       '<%= yeoman.app %>/styles/images'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/**/*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/**/*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/**/*.js',
                    '{.tmp,<%= yeoman.app %>}/configuration/**/*.json',
                    '<%= yeoman.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            },
            karma: {
                files: ['app/scripts/**/*.js', 'test/unit/**/*.js'],
                tasks: ['karma:unit:run']
            },
            doc: {
                files: ['{.tmp,<%= yeoman.app %>}/scripts/**/*.js'],
                tasks: ['docular', 'open:doc']
            }
        },
        autoprefixer: {
            options: ['last 1 version'],
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [function (request, response, next) {
                                if (request.url.indexOf('/api') !== -1) {
                                    setTimeout(function () {
                                        next();
                                    }, 1000);
                                } else {
                                    next();
                                }
                            },
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app),
                            function (request, response, next) {

                                console.log("request method: " + JSON.stringify(request.method));
                                var rawpath = request.url.split('?')[0];
                                console.log("request url: " + JSON.stringify(request.url));
                                var path = require('path').resolve(__dirname, 'app/' + rawpath);

                                console.log("request path : " + JSON.stringify(path));

                                console.log("request current dir : " + JSON.stringify(__dirname));

                                if ((request.method === 'PUT' || request.method === 'POST')) {

                                    console.log('inside put/post');

                                    request.content = '';

                                    request.addListener("data", function (chunk) {
                                        request.content += chunk;
                                    });

                                    request.addListener("end", function () {
                                        console.log("request content: " + JSON.stringify(request.content));

                                        if (fs.existsSync(path)) {

                                            fs.writeFile(path, request.content, function (err) {
                                                if (err) {
                                                    throw err;
                                                }
                                                console.log('file saved');
                                                response.end('file was saved');
                                            });
                                            return;
                                        }

                                        if (request.url === '/log') {

                                            var filePath = 'server/log/server.log';

                                            var logData = JSON.parse(request.content);

                                            fs.appendFile(filePath, logData.logUrl + '\n' + logData.logMessage + '\n', function (err) {
                                                if (err) {
                                                    throw err;
                                                }
                                                console.log('log saved');
                                                response.end('log was saved');
                                            });
                                            return;
                                        }
                                    });
                                    return;
                                }
                                next();
                            }];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app),
                            mountFolder(connect, 'test')];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [mountFolder(connect, yeomanConfig.dist)];
                    }
                }
            },
            doc: {
                options: {
                    port: 3000,
                    middleware: function (connect) {
                        return [mountFolder(connect, yeomanConfig.doc)];
                    }
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            },
            doc: {
                url: 'http://localhost:3000'
            }
        },
        clean: {
            dist: {<commit_msg>Changed URL for doc for deployment<commit_after>// Generated on 2013-09-19 using generator-angular 0.4.0
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
    port: LIVERELOAD_PORT
});

var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

var fs = require('fs');

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // configurable paths
    var yeomanConfig = {
        app: 'app',
        dist: 'dist',
        doc: 'doc'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            coffee: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.coffee'],
                tasks: ['coffee:test']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css',
                       '<%= yeoman.app %>/styles/images'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/**/*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/**/*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/**/*.js',
                    '{.tmp,<%= yeoman.app %>}/configuration/**/*.json',
                    '<%= yeoman.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            },
            karma: {
                files: ['app/scripts/**/*.js', 'test/unit/**/*.js'],
                tasks: ['karma:unit:run']
            },
            doc: {
                files: ['{.tmp,<%= yeoman.app %>}/scripts/**/*.js'],
                tasks: ['docular', 'open:doc']
            }
        },
        autoprefixer: {
            options: ['last 1 version'],
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [function (request, response, next) {
                                if (request.url.indexOf('/api') !== -1) {
                                    setTimeout(function () {
                                        next();
                                    }, 1000);
                                } else {
                                    next();
                                }
                            },
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app),
                            function (request, response, next) {

                                console.log("request method: " + JSON.stringify(request.method));
                                var rawpath = request.url.split('?')[0];
                                console.log("request url: " + JSON.stringify(request.url));
                                var path = require('path').resolve(__dirname, 'app/' + rawpath);

                                console.log("request path : " + JSON.stringify(path));

                                console.log("request current dir : " + JSON.stringify(__dirname));

                                if ((request.method === 'PUT' || request.method === 'POST')) {

                                    console.log('inside put/post');

                                    request.content = '';

                                    request.addListener("data", function (chunk) {
                                        request.content += chunk;
                                    });

                                    request.addListener("end", function () {
                                        console.log("request content: " + JSON.stringify(request.content));

                                        if (fs.existsSync(path)) {

                                            fs.writeFile(path, request.content, function (err) {
                                                if (err) {
                                                    throw err;
                                                }
                                                console.log('file saved');
                                                response.end('file was saved');
                                            });
                                            return;
                                        }

                                        if (request.url === '/log') {

                                            var filePath = 'server/log/server.log';

                                            var logData = JSON.parse(request.content);

                                            fs.appendFile(filePath, logData.logUrl + '\n' + logData.logMessage + '\n', function (err) {
                                                if (err) {
                                                    throw err;
                                                }
                                                console.log('log saved');
                                                response.end('log was saved');
                                            });
                                            return;
                                        }
                                    });
                                    return;
                                }
                                next();
                            }];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app),
                            mountFolder(connect, 'test')];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [mountFolder(connect, yeomanConfig.dist)];
                    }
                }
            },
            doc: {
                options: {
                    port: 3000,
                    middleware: function (connect) {
                        return [mountFolder(connect, yeomanConfig.doc)];
                    }
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            },
            doc: {
                url: 'http://appverse.gftlabs.com:3000'
            }
        },
        clean: {
            dist: {
{'fraction_non_alphanumeric': 0.12465842550422902, 'fraction_numerical': 0.005074821080026025, 'mean_word_length': 0.7927455096804292, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 122, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '47281', 'n_tokens_mistral': 3546, 'n_tokens_neox': 3265, 'n_words': 633}