<commit_before>/*
 * Generated on 2014-03-26
 * generator-assemble v0.4.11
 * https://github.com/assemble/generator-assemble
 *
 * Copyright (c) 2014 Hariadi Hinta
 * Licensed under the MIT license.
 */

'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// '<%= config.src %>/templates/pages/{,*/}*.hbs'
// use this if you want to match all subfolders:
// '<%= config.src %>/templates/pages/**/*.hbs'

module.exports = function(grunt) {

  require('time-grunt')(grunt);
  //jit-grunt loads only the npm tasks required for the grunt task.
  //makes livereload much faster.
  require('jit-grunt')(grunt, {
    replace: 'grunt-text-replace'
  });

  // Project configuration.
  grunt.initConfig({
    config: {
      production: {
        options: {
          variables: {
            environment: 'production',
            environmentData: 'website-guts/data/environments/production/environmentVariables.json',
            assets_dir: '/dist/assets',
            link_path: '',
            sassImagePath: '/dist/assets/img',
            compress_js: true,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n' +
                           '  try { \n\n',
            concat_footer: '  } catch(error){ \n\n' +
                           '  //report errors to GA \n\n' +
                           '  window.console.log("js error: " + error);' +
                           '  } \n' +
                           '})(jQuery);'
          }
        }
      },
      preview: {
        options: {
          variables: {
            aws: grunt.file.readJSON('configs/s3Config.json'),
            environment: 'preview',
            environmentData: 'website-guts/data/environments/production/environmentVariables.json',
            assets_dir: '/assets',
            link_path: '',
            sassImagePath: '/assets/img',
            compress_js: true,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n' +
                           '  try { \n\n',
            concat_footer: '  } catch(error){ \n\n' +
                           '  //report errors to GA \n\n' +
                           '  window.console.log("js error: " + error);' +
                           '  } \n' +
                           '})(jQuery);'
          }
        }
      },
      dev: {
        options: {
          variables: {
            environment: 'dev',
            environmentData: 'website-guts/data/environments/development/environmentVariables.json',
            assets_dir: '/dist/assets',
            link_path: '/dist',
            sassSourceMap: true,
            sassImagePath: '/dist/assets/img',
            compress_js: false,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n',
            concat_footer: '})(jQuery);'
          }
        }
      },
      content: 'website',
      guts: 'website-guts',
      dist: 'dist',
      temp: 'temp',
      helpers: 'website-guts/helpers',
      bowerDir: 'bower_components'
    },
    watch: {
      assemble: {
        files: [
          '<%= config.content %>/{,*/}*.{md,hbs,yml,json}',
          '<%= config.guts %>/templates/**/*.hbs',
          '<%= config.content %>/**/*.hbs'
        ],
        tasks: ['config:dev', 'assemble']
      },
      sass: {
        files: '<%= config.guts %>/assets/css/**/*.scss',
        tasks: ['config:dev', 'sass', 'replace', 'autoprefixer', 'clean:postBuild']
      },
      img: {
        files: ['<%= config.guts %>/assets/img/*.{png,jpg,svg}'],
        tasks: ['copy:img']
      },
      js: {
        files: ['<%= config.guts %>/assets/js/**/*.js', '<%= config.temp %>/assets/js/**/*.js'],
        tasks: ['config:dev', 'jshint', 'concat', 'clean:postBuild']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.dist %>/**/*.html',
          '<%= config.dist %>/assets/css/**/*.css',
          '<%= config.dist %>/assets/js/**/*.js'
        ]
      }
    },
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: '0.0.0.0',
        middleware: function(connect, options, middlewares){
          middlewares.unshift(function(req, res, next){
            if(req.method === 'POST'){

              if(req.url === '/account/free_trial_landing'){

                res.writeHead(200, {'Content-Type': 'application/json'});
                res.end( grunt.file.read('website-guts/endpoint-mocks/formSuccess.json') );

              } else if(req.url === '/account/free_trial_landing/account_exists'){

                res.writeHead(400, {'Content-Type': 'application/json'});
                res.end( grunt.file.read('website-guts/endpoint-mocks/accountExists.json') );

              } else {

                return next();

              }

            } else if(req.url === '/account/info') {

              res.writeHead(200, {'Content-Type': 'application/json'});
              res.end( grunt.file.read('website-guts/endpoint-mocks/accountInfo.json') );

            } else{

              return next();

            }

          });
          return middlewares;
        }
      },
      livereload: {
        options: {
          open: {
            target: 'http://0.0.0.0:9000/dist',
            base: '.'
          }
        }
      }
    },
    assemble: {
      options: {
        layoutdir: '<%= config.guts %>/templates/layouts/',
        assetsDir: '<%= grunt.config.get("assets_dir") %>',
        linkPath: '<%= grunt.config.get("link_path") %>',
        sassImagePath: '<%= grunt.config.get("sassImagePath") %>',
        environmentIsProduction: '<%= grunt.config.get("environmentIsProduction") %>',
        environmentIsDev: '<%= grunt.config.get("environmentIsDev") %>',
        data: ['<%= config.content %>/**/*.json', '<%= config.content %>/**/*.yml', '<%= grunt.config.get("environmentData") %>'],
        partials: ['<%= config.guts %>/templates/partials/*.hbs'],
        helpers: ['<%= config.helpers %>/helper-*.js']
      },
      modals: {
        options: {
          ext: '.hbs'
        },
        files: [
          {
            src: 'templates/components/modals/**/*.hbs',
            dest: '<%= config.guts %>/templates/partials/',
            cwd: '<%= config.guts %>/',
            expand: true,
            filter: 'isFile',
            flatten: true,
            rename: function(dest, src) {
              var split = src.split('.');
              return dest + split[0] + '_compiled';
            }
          }
        ]
      },
      pages: {
        files: [
          {
            src: ['**/*.hbs'],
            dest: '<%= config.dist %>/',
            cwd: '<%= config.content %>/',
            expand: true
          }
        ]
      }
    },
    sass: {
      prod: {
        options: {
          sourceMap: false,
          imagePath: '<%= grunt.config.get("sassImagePath") %>',
          precision: 3,
          outputStyle: 'compressed'
        },
        files: [
          {
            src: '<%= config.guts %>/assets/css/styles.scss',
            dest: '<%= config.temp %>/css/styles.css'
          }
        ]
      },
      dev: {
        options: {
          sourceMap: true,
          imagePath: '<%= grunt.config.get("sassImagePath") %>',
          precision: 3
        },
        files: [
          {
            src: '<%= config.guts %>/assets/css/styles.scss',
            dest: '<%= config.temp %>/css/styles.css'
          }
        ]
      }
    },
    replace: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        overwrite: true,
        replacements: [
          {
            from: 'website-guts/',
            to: '../../../website-guts/'
          }
        ]
      }
    },
    autoprefixer: {
      options: {
        options: ['last 2 versions', 'Firefox ESR'],
        map: true
      },
      files: {
        flatten: true,
        src: '<%= config.temp %>/css/styles.css',
        dest: '<%= config.dist %>/assets/css/styles.css'
      }
    },
    copy: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        dest: '<%= config.dist %>/assets/css/styles.css.map'
      },
      cssFontFile: {
        src: ['<%= config.guts %>/assets/css/fonts.css'],
        dest: '<%= config.dist %>/assets/css/fonts.css'
      },
      jquery: {
        files: [
          {
            '<%= config.dist %>/assets/js/libraries/jquery-1.6.4.min.js': ['<%= config.guts %>/assets/js/libraries/jquery-1.6.4.min.js']
          }
        ]
      },
      fastclick: {
        files: [
          {
            '<%= config.dist %>/assets/js/libraries/fastclick.js': ['<%= config.bowerDir %>/fastclick/lib/fastclick.js']
          }
        ]
      },
      img: {
        files: [
          {
            cwd: '<%= config.guts %>/assets/img/',
            src: '**',
            dest: '<%= config.dist %>/assets/img/',
            expand: true
          }
        ]
      }
    },
    clean: {
      preBuild: ['<%= config.dist %>/'],
      postBuild: ['<%= config.temp %>']
    },
    s3: {
      options: {
        key: '<%= grunt.config.get("aws.key") %>',
        secret: '<%= grunt.config.get("aws.secret") %>',
        bucket: '<%= grunt.config.get("aws.bucket") %>',
        access: 'public-read',
      },
      dev: {
        upload: [
          {
            src: '<%= config.dist %>/**/*',
            dest: '/',
            rel: '<%= config.dist %>'
          }
        ]
      }
    },
    jshint: {
      options: {
        trailing: true,
        curly: true,
        eqeqeq: true,
        indent: 4,
        latedef: true,
        noempty: true,
        nonbsp: true,
        undef: true,
        unused: true,
        quotmark: 'single',
        browser: true,
        globals: {
          jQuery: true,
          $: true,
          console: false,
          Handlebars: false,
          moment: false,
          _gaq: false
        },
        '-W087': (function() {
          if(grunt.config.get("environment") == "dev") {
            return true;
          } else {
            return false;
          }
        }())
      },
      files: ['<%= config.guts %>/assets/js/**/*.js', '!<%= config.guts %>/assets/js/libraries/**/*.js']
    },
    concat: {
      modernizrYep: {
        files: {
          '<%= config.dist %>/assets/js/libraries/modernizr-yepnope.js': ['<%= config.guts %>/assets/js/libraries/modernizr-2.8.2.min.js','<%= config.bowerDir %>/yepnope/yepnope.1.5.4-min.js']
        }
      },
      namespacePages: {
        options: {
          banner: '<%= grunt.config.get("concat_banner") %>',
          footer: '<%= grunt.config.get("concat_footer") %>'
        },
        src: ['pages/*.js', 'layouts/*.js'],
        expand: true,
        cwd: '<%= config.guts %>/assets/js/',
        dest: '<%= config.dist %>/assets/js/'
      },
      namespaceGlobal: {
        options: {
          banner: '<%= grunt.config.get("concat_banner") %>',
          footer: '<%= grunt.config.get("concat_footer") %>'
        },
        files: {
            '<%= config.temp %>/assets/js/global.js': ['<%= config.guts %>/assets/js/global.js', '<%= config.guts %>/assets/js/components/*.js']
        }
      },
      concatBundle: {
        files: {
          '<%= config.dist %>/assets/js/bundle.js': [
            '<%= config.bowerDir %>/jquery-cookie/jquery.cookie.js',
            '<%= config.bowerDir %>/history.js/scripts/bundled-uncompressed/html4+html5/jquery.history.js',
            '<%= config.guts %>/assets/js/libraries/handlebars-v1.3.0.js',
            '<%= config.bowerDir %>/momentjs/moment.js',
            '<%= config.bowerDir %>/oform/dist/oForm.min.js',
            '<%= config.temp %>/assets/js/global.js',
            '<%= config.guts %>/assets/js/components/oForm-globals.js'
          ]
        }
      }
    },
    uglify: {
      options: {
        mangle: false,
        compress: false,
        beautify: false
      },
      globalJS: {
        files: {
          '<%= config.dist %>/assets/js/libraries/fastclick.js': ['<%= config.bowerDir %>/fastclick/lib/fastclick.js'],
          '<%= config.dist %>/assets/js/bundle.js': ['<%= config.dist %>/assets/js/bundle.js']
        }
      },
      pageFiles: {
        files: [
          {
            expand: true,
            cwd: '<%= config.dist %>/assets/js/',
            src: 'pages/*.js',
            dest: '<%= config.dist %>/assets/js/pages',
            flatten: true
          }
        ]
      },
      layoutFiles: {
        files: [
          {
            expand: true,
            cwd: '<%= config.dist %>/assets/js/',
            src: 'layouts/*.js',
            dest: '<%= config.dist %>/assets/js/layouts',
            flatten: true
          }
        ]
      }
    },
    'phantomcss-gitdiff': {
      options: {
        baseUrl: 'http://0.0.0.0:9000/',
        serverRoot: 'dist/',
        gitDiff: true,
      },
      desktop: {
        options: {
          screenshots: 'screens/desktop/',
          viewportSize: [1024, 768]
        },
        src: [
          'dist/{,**/}*.html'
        ]
      },
      mobile: {
        options: {
          screenshots: 'screens/mobile/',
          viewportSize: [320, 480]
        },
        src: [
          'dist/{,**/}*.html'
        ]
      }
    },
    imagemin: {
      prod: {
        files: [
          {
            cwd: '<%= config.guts %>/assets/img/',
            src: '**/*.{jpg,jpeg,gif,png,svg}',
            dest: '<%= config.dist %>/assets/img/',
            expand: true
          }
        ]
      }
    }
  });

  grunt.registerTask('server', [
    'config:dev',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'sass:dev',
    'replace',
    'autoprefixer',
    'copy',
    'clean:postBuild',
    'connect:livereload',
    'watch'
  ]);

  grunt.registerTask('build', [
    'config:production',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'imagemin:prod',
    'copy:cssFontFile',
    'copy:jquery',
    'uglify',
    'sass:prod',
    'replace',
    'autoprefixer',
    'clean:postBuild'
  ]);

  grunt.registerTask('preview', [
    'config:preview',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'copy',
    's3',
    'clean:postBuild'
  ]);

  grunt.registerTask('default', [
    'build'
  ]);

};
<commit_msg>Uses uglify's drop_console option in the production config.<commit_after>/*
 * Generated on 2014-03-26
 * generator-assemble v0.4.11
 * https://github.com/assemble/generator-assemble
 *
 * Copyright (c) 2014 Hariadi Hinta
 * Licensed under the MIT license.
 */

'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// '<%= config.src %>/templates/pages/{,*/}*.hbs'
// use this if you want to match all subfolders:
// '<%= config.src %>/templates/pages/**/*.hbs'

module.exports = function(grunt) {

  require('time-grunt')(grunt);
  //jit-grunt loads only the npm tasks required for the grunt task.
  //makes livereload much faster.
  require('jit-grunt')(grunt, {
    replace: 'grunt-text-replace'
  });

  // Project configuration.
  grunt.initConfig({
    config: {
      production: {
        options: {
          variables: {
            environment: 'production',
            environmentData: 'website-guts/data/environments/production/environmentVariables.json',
            assets_dir: '/dist/assets',
            link_path: '',
            sassImagePath: '/dist/assets/img',
            compress_js: true,
            drop_console: true,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n' +
                           '  try { \n\n',
            concat_footer: '  } catch(error){ \n\n' +
                           '  //report errors to GA \n\n' +
                           '  window.console.log("js error: " + error);' +
                           '  } \n' +
                           '})(jQuery);'
          }
        }
      },
      preview: {
        options: {
          variables: {
            aws: grunt.file.readJSON('configs/s3Config.json'),
            environment: 'preview',
            environmentData: 'website-guts/data/environments/production/environmentVariables.json',
            assets_dir: '/assets',
            link_path: '',
            sassImagePath: '/assets/img',
            compress_js: true,
            drop_console: false,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n' +
                           '  try { \n\n',
            concat_footer: '  } catch(error){ \n\n' +
                           '  //report errors to GA \n\n' +
                           '  window.console.log("js error: " + error);' +
                           '  } \n' +
                           '})(jQuery);'
          }
        }
      },
      dev: {
        options: {
          variables: {
            environment: 'dev',
            environmentData: 'website-guts/data/environments/development/environmentVariables.json',
            assets_dir: '/dist/assets',
            link_path: '/dist',
            sassSourceMap: true,
            sassImagePath: '/dist/assets/img',
            compress_js: false,
            drop_console: false,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n',
            concat_footer: '})(jQuery);'
          }
        }
      },
      content: 'website',
      guts: 'website-guts',
      dist: 'dist',
      temp: 'temp',
      helpers: 'website-guts/helpers',
      bowerDir: 'bower_components'
    },
    watch: {
      assemble: {
        files: [
          '<%= config.content %>/{,*/}*.{md,hbs,yml,json}',
          '<%= config.guts %>/templates/**/*.hbs',
          '<%= config.content %>/**/*.hbs'
        ],
        tasks: ['config:dev', 'assemble']
      },
      sass: {
        files: '<%= config.guts %>/assets/css/**/*.scss',
        tasks: ['config:dev', 'sass', 'replace', 'autoprefixer', 'clean:postBuild']
      },
      img: {
        files: ['<%= config.guts %>/assets/img/*.{png,jpg,svg}'],
        tasks: ['copy:img']
      },
      js: {
        files: ['<%= config.guts %>/assets/js/**/*.js', '<%= config.temp %>/assets/js/**/*.js'],
        tasks: ['config:dev', 'jshint', 'concat', 'clean:postBuild']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.dist %>/**/*.html',
          '<%= config.dist %>/assets/css/**/*.css',
          '<%= config.dist %>/assets/js/**/*.js'
        ]
      }
    },
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: '0.0.0.0',
        middleware: function(connect, options, middlewares){
          middlewares.unshift(function(req, res, next){
            if(req.method === 'POST'){

              if(req.url === '/account/free_trial_landing'){

                res.writeHead(200, {'Content-Type': 'application/json'});
                res.end( grunt.file.read('website-guts/endpoint-mocks/formSuccess.json') );

              } else if(req.url === '/account/free_trial_landing/account_exists'){

                res.writeHead(400, {'Content-Type': 'application/json'});
                res.end( grunt.file.read('website-guts/endpoint-mocks/accountExists.json') );

              } else {

                return next();

              }

            } else if(req.url === '/account/info') {

              res.writeHead(200, {'Content-Type': 'application/json'});
              res.end( grunt.file.read('website-guts/endpoint-mocks/accountInfo.json') );

            } else{

              return next();

            }

          });
          return middlewares;
        }
      },
      livereload: {
        options: {
          open: {
            target: 'http://0.0.0.0:9000/dist',
            base: '.'
          }
        }
      }
    },
    assemble: {
      options: {
        layoutdir: '<%= config.guts %>/templates/layouts/',
        assetsDir: '<%= grunt.config.get("assets_dir") %>',
        linkPath: '<%= grunt.config.get("link_path") %>',
        sassImagePath: '<%= grunt.config.get("sassImagePath") %>',
        environmentIsProduction: '<%= grunt.config.get("environmentIsProduction") %>',
        environmentIsDev: '<%= grunt.config.get("environmentIsDev") %>',
        data: ['<%= config.content %>/**/*.json', '<%= config.content %>/**/*.yml', '<%= grunt.config.get("environmentData") %>'],
        partials: ['<%= config.guts %>/templates/partials/*.hbs'],
        helpers: ['<%= config.helpers %>/helper-*.js']
      },
      modals: {
        options: {
          ext: '.hbs'
        },
        files: [
          {
            src: 'templates/components/modals/**/*.hbs',
            dest: '<%= config.guts %>/templates/partials/',
            cwd: '<%= config.guts %>/',
            expand: true,
            filter: 'isFile',
            flatten: true,
            rename: function(dest, src) {
              var split = src.split('.');
              return dest + split[0] + '_compiled';
            }
          }
        ]
      },
      pages: {
        files: [
          {
            src: ['**/*.hbs'],
            dest: '<%= config.dist %>/',
            cwd: '<%= config.content %>/',
            expand: true
          }
        ]
      }
    },
    sass: {
      prod: {
        options: {
          sourceMap: false,
          imagePath: '<%= grunt.config.get("sassImagePath") %>',
          precision: 3,
          outputStyle: 'compressed'
        },
        files: [
          {
            src: '<%= config.guts %>/assets/css/styles.scss',
            dest: '<%= config.temp %>/css/styles.css'
          }
        ]
      },
      dev: {
        options: {
          sourceMap: true,
          imagePath: '<%= grunt.config.get("sassImagePath") %>',
          precision: 3
        },
        files: [
          {
            src: '<%= config.guts %>/assets/css/styles.scss',
            dest: '<%= config.temp %>/css/styles.css'
          }
        ]
      }
    },
    replace: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        overwrite: true,
        replacements: [
          {
            from: 'website-guts/',
            to: '../../../website-guts/'
          }
        ]
      }
    },
    autoprefixer: {
      options: {
        options: ['last 2 versions', 'Firefox ESR'],
        map: true
      },
      files: {
        flatten: true,
        src: '<%= config.temp %>/css/styles.css',
        dest: '<%= config.dist %>/assets/css/styles.css'
      }
    },
    copy: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        dest: '<%= config.dist %>/assets/css/styles.css.map'
      },
      cssFontFile: {
        src: ['<%= config.guts %>/assets/css/fonts.css'],
        dest: '<%= config.dist %>/assets/css/fonts.css'
      },
      jquery: {
        files: [
          {
            '<%= config.dist %>/assets/js/libraries/jquery-1.6.4.min.js': ['<%= config.guts %>/assets/js/libraries/jquery-1.6.4.min.js']
          }
        ]
      },
      fastclick: {
        files: [
          {
            '<%= config.dist %>/assets/js/libraries/fastclick.js': ['<%= config.bowerDir %>/fastclick/lib/fastclick.js']
          }
        ]
      },
      img: {
        files: [
          {
            cwd: '<%= config.guts %>/assets/img/',
            src: '**',
            dest: '<%= config.dist %>/assets/img/',
            expand: true
          }
        ]
      }
    },
    clean: {
      preBuild: ['<%= config.dist %>/'],
      postBuild: ['<%= config.temp %>']
    },
    s3: {
      options: {
        key: '<%= grunt.config.get("aws.key") %>',
        secret: '<%= grunt.config.get("aws.secret") %>',
        bucket: '<%= grunt.config.get("aws.bucket") %>',
        access: 'public-read',
      },
      dev: {
        upload: [
          {
            src: '<%= config.dist %>/**/*',
            dest: '/',
            rel: '<%= config.dist %>'
          }
        ]
      }
    },
    jshint: {
      options: {
        trailing: true,
        curly: true,
        eqeqeq: true,
        indent: 4,
        latedef: true,
        noempty: true,
        nonbsp: true,
        undef: true,
        unused: true,
        quotmark: 'single',
        browser: true,
        globals: {
          jQuery: true,
          $: true,
          console: false,
          Handlebars: false,
          moment: false,
          _gaq: false
        },
        '-W087': (function() {
          if(grunt.config.get("environment") == "dev") {
            return true;
          } else {
            return false;
          }
        }())
      },
      files: ['<%= config.guts %>/assets/js/**/*.js', '!<%= config.guts %>/assets/js/libraries/**/*.js']
    },
    concat: {
      modernizrYep: {
        files: {
          '<%= config.dist %>/assets/js/libraries/modernizr-yepnope.js': ['<%= config.guts %>/assets/js/libraries/modernizr-2.8.2.min.js','<%= config.bowerDir %>/yepnope/yepnope.1.5.4-min.js']
        }
      },
      namespacePages: {
        options: {
          banner: '<%= grunt.config.get("concat_banner") %>',
          footer: '<%= grunt.config.get("concat_footer") %>'
        },
        src: ['pages/*.js', 'layouts/*.js'],
        expand: true,
        cwd: '<%= config.guts %>/assets/js/',
        dest: '<%= config.dist %>/assets/js/'
      },
      namespaceGlobal: {
        options: {
          banner: '<%= grunt.config.get("concat_banner") %>',
          footer: '<%= grunt.config.get("concat_footer") %>'
        },
        files: {
            '<%= config.temp %>/assets/js/global.js': ['<%= config.guts %>/assets/js/global.js', '<%= config.guts %>/assets/js/components/*.js']
        }
      },
      concatBundle: {
        files: {
          '<%= config.dist %>/assets/js/bundle.js': [
            '<%= config.bowerDir %>/jquery-cookie/jquery.cookie.js',
            '<%= config.bowerDir %>/history.js/scripts/bundled-uncompressed/html4+html5/jquery.history.js',
            '<%= config.guts %>/assets/js/libraries/handlebars-v1.3.0.js',
            '<%= config.bowerDir %>/momentjs/moment.js',
            '<%= config.bowerDir %>/oform/dist/oForm.min.js',
            '<%= config.temp %>/assets/js/global.js',
            '<%= config.guts %>/assets/js/components/oForm-globals.js'
          ]
        }
      }
    },
    uglify: {
      options: {
        mangle: false,
        beautify: false,
        compress: {
          drop_console: '<%= grunt.config.get("compress_js") %>'
        }
      },
      globalJS: {
        files: {
          '<%= config.dist %>/assets/js/libraries/fastclick.js': ['<%= config.bowerDir %>/fastclick/lib/fastclick.js'],
          '<%= config.dist %>/assets/js/bundle.js': ['<%= config.dist %>/assets/js/bundle.js']
        }
      },
      pageFiles: {
        files: [
          {
            expand: true,
            cwd: '<%= config.dist %>/assets/js/',
            src: 'pages/*.js',
            dest: '<%= config.dist %>/assets/js/pages',
            flatten: true
          }
        ]
      },
      layoutFiles: {
        files: [
          {
            expand: true,
            cwd: '<%= config.dist %>/assets/js/',
            src: 'layouts/*.js',
            dest: '<%= config.dist %>/assets/js/layouts',
            flatten: true
          }
        ]
      }
    },
    'phantomcss-gitdiff': {
      options: {
        baseUrl: 'http://0.0.0.0:9000/',
        serverRoot: 'dist/',
        gitDiff: true,
      },
      desktop: {
        options: {
          screenshots: 'screens/desktop/',
          viewportSize: [1024, 768]
        },
        src: [
          'dist/{,**/}*.html'
        ]
      },
      mobile: {
        options: {
          screenshots: 'screens/mobile/',
          viewportSize: [320, 480]
        },
        src: [
          'dist/{,**/}*.html'
        ]
      }
    },
    imagemin: {
      prod: {
        files: [
          {
            cwd: '<%= config.guts %>/assets/img/',
            src: '**/*.{jpg,jpeg,gif,png,svg}',
            dest: '<%= config.dist %>/assets/img/',
            expand: true
          }
        ]
      }
    }
  });

  grunt.registerTask('server', [
    'config:dev',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'sass:dev',
    'replace',
    'autoprefixer',
    'copy',
    'clean:postBuild',
    'connect:livereload',
    'watch'
  ]);

  grunt.registerTask('build', [
    'config:production',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'imagemin:prod',
    'copy:cssFontFile',
    'copy:jquery',
    'uglify',
    'sass:prod',
    'replace',
    'autoprefixer',
    'clean:postBuild'
  ]);

  grunt.registerTask('preview', [
    'config:preview',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'copy',
    's3',
    'clean:postBuild'
  ]);

  grunt.registerTask('default', [
    'build'
  ]);

};
<|endoftext|>


<commit_before>/*
 * grunt-compc
 * https://github.com/artema/grunt-compc
 *
 * Copyright (c) 2015 Artem Abashev, contributors
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/**/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
        tests: ['tmp'],
    },

    // Configuration to be run (and then tested).
    compc: {
      options: {
      },
      default: {
        src: [],
          options: {
            'version': undefined
          }
        },
        test_build: {
          src: ['test/Test1.as'],
          dest: 'tmp/test_build.swc',
          options: {
            'source-path': ['test']
          }
      }
    },

    // Unit tests.
    nodeunit: {
        tests: ['test/**/*_test.js']
    }

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['clean', 'compc', 'nodeunit', 'clean']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint', 'test']);
  grunt.registerTask('travis', ['jshint', 'test']);

};
<commit_msg>moving a line to prep for a de-dupe of code<commit_after>/*
 * grunt-compc
 * https://github.com/artema/grunt-compc
 *
 * Copyright (c) 2015 Artem Abashev, contributors
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/**/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
        tests: ['tmp'],
    },

    // Configuration to be run (and then tested).
    compc: {
      options: {
      },
      default: {
        src: [],
          options: {
            'version': undefined
          }
        },
        test_build: {
          src: ['test/Test1.as'],
          dest: 'tmp/test_build.swc',
          options: {
            'source-path': ['test']
          }
      }
    },

    // Unit tests.
    nodeunit: {
        tests: ['test/**/*_test.js']
    }

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-clean');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['clean', 'compc', 'nodeunit', 'clean']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint', 'test']);
  grunt.registerTask('travis', ['jshint', 'test']);

};
<|endoftext|>


<commit_before>
const RG = require('./rg.js');
RG.Item = require('./item.js');

RG.Inv = {};

//---------------------------------------------------------------------------
// EQUIPMENT AND INVENTORY
//---------------------------------------------------------------------------

/* Models one slot in the inventory. */
RG.Inv.EquipSlot = function(eq, type, stacked) {
    RG.Object.Ownable.call(this, eq);

    let _item = null;
    let _hasItem = false;
    let _unequipped = null;
    let _stacked = false;

    if (!RG.isNullOrUndef([stacked])) {_stacked = stacked;}

    this.isStacked = function() {return _stacked;};

    this.getUnequipped = function() {
        return _unequipped;
    };

    /* Returns the equipped item for this slot.*/
    this.getItem = function() {
        if (_hasItem) {return _item;}
        return null;
    };

    /* Equips given item to first available place in slot.*/
    this.equipItem = function(item) {
        if (this.canEquip(item)) {
            if (!_stacked || !_hasItem) {
                item.setOwner(this);
                _item = item;
                _hasItem = true;
            }
            else if (RG.addStackedItems(_item, item)) {
                    _hasItem = true;
                }
            return _hasItem;
        }
        return false;
    };

    /* Unequips N items from the slot. */
    this.unequipItem = function(n) {
        if (_hasItem) {
            if (!_stacked) {
                _hasItem = false;
                _unequipped = _item;
                return true;
            }
            else if (n > 0) {
                    _unequipped = RG.removeStackedItems(_item, n);
                    if (_item.count === 0) {_hasItem = false;}
                    return true;
                }
        }
        return false;
    };

    this.canEquip = function(item) {
        if (!_hasItem) {
            return true;
        }
        else if (_stacked) { // Can only equip same items to the stack
            return item.equals(_item);
        }
        return false;
    };

};
RG.extend2(RG.Inv.EquipSlot, RG.Object.Ownable);

/* Models equipment on an actor.*/
RG.Inv.Equipment = function(actor) {
    RG.Object.Ownable.call(this, actor);

    const _equipped = [];

    const _slots = {
        hand: new RG.Inv.EquipSlot(this, 'hand'),
        shield: new RG.Inv.EquipSlot(this, 'shield'),
        head: new RG.Inv.EquipSlot(this, 'head'),
        chest: new RG.Inv.EquipSlot(this, 'chest'),
        neck: new RG.Inv.EquipSlot(this, 'neck'),
        feet: new RG.Inv.EquipSlot(this, 'feet'),
        missile: new RG.Inv.EquipSlot(this, 'missile', true),
        spiritgem: new RG.Inv.EquipSlot(this, 'spiritgem')
    };

    const _hasSlot = function(slotType) {
        return _slots.hasOwnProperty(slotType);
    };

    this.getWeight = function() {
        let total = 0;
        for (let i = 0; i < _equipped.length; i++) {
            total += _equipped[i].getWeight() * _equipped[i].count;
        }
        return total;
    };

    this.getSlotTypes = function() {return Object.keys(_slots);};

    this.getItems = function() {return _equipped;};

    /* Returns last unequipped item for the slot.*/
    this.getUnequipped = function(slotType) {
        if (_hasSlot(slotType)) {
            return _slots[slotType].getUnequipped();
        }
        else {
            RG.err('Equipment', 'getUnequipped',
                'No slot type: ' + slotType);
        }
        return null;
    };

    /* Returns an item in the given slot.*/
    this.getItem = function(slot) {
        if (_slots.hasOwnProperty(slot)) {
            return _slots[slot].getItem();
        }
        return null;
    };

    /* Equips given item. Slot is chosen automatically from suitable available
     * ones.*/
    this.equipItem = function(item) {
        if (item.hasOwnProperty('getArmourType')) {
            if (_slots[item.getArmourType()].equipItem(item)) {
                _equipped.push(item);
                return true;
            }
        }
        // No equip property, can only equip to hand
        else if (item.getType() === 'missile') {
            if (_slots.missile.equipItem(item)) {
                _addStackedItem(item);
                return true;
            }
        }
        else if (_slots.hand.equipItem(item)) {
            _equipped.push(item);
            return true;
        }
        return false;
    };

    const _addStackedItem = function(item) {
        let matchFound = false;
        for (let i = 0; i < _equipped.length; i++) {
            if (_equipped[i].equals(item)) {
                matchFound = true;
                break;
            }
        }
        if (!matchFound) {_equipped.push(item);}
    };

    /* Removes an item, or n items if specified.*/
    const _removeItem = function(item, n) {
        const index = _equipped.indexOf(item);
        if (index >= 0) {
            if (n > 0) {
                if (_equipped[index].hasOwnProperty('count')) {
                    if (_equipped[index].count === 0) {
                        _equipped.splice(index, 1);
                    }
                }
                return true;
            }
            else {
                _equipped.splice(index, 1);
                return true;
            }
        }
        else {
            RG.err('Equipment', 'unequipItem', 'Index < 0. Horribly wrong.');
        }
        return false;
    };

    /* Returns true if given item is equipped.*/
    this.isEquipped = function(item) {
        const index = _equipped.indexOf(item);
        return index !== -1;
    };

    this.getEquipped = function(slotType) {
        return this.getItem(slotType);
    };

    /* Unequips given slotType and index. */
    this.unequipItem = function(slotType, n) {
        if (_hasSlot(slotType)) {
            const item = _slots[slotType].getItem();
            if (_slots[slotType].unequipItem(n)) {
                return _removeItem(item, n);
            }
        }
        else {
            const msg = 'Non-existing slot type ' + slotType;
            RG.err('Equipment', 'unequipItem', msg);
        }
        return false;
    };

    this.propertySum = function(funcname) {
        let result = 0;
        const slotKeys = Object.keys(_slots);
        slotKeys.forEach(slot => {
            const item = this.getItem(slot);
            if (item !== null) {
                if (item.hasOwnProperty(funcname)) {
                    result += item[funcname]();
                }
                else if (item.has('Stats')) {
                    const sComp = item.get('Stats');
                    if (sComp.hasOwnProperty(funcname)) {
                        result += sComp[funcname]();
                    }
                }
            }
        });
        return result;
    };

    this.toJSON = function() {
        const json = [];
        for (let i = 0; i < _equipped.length; i++) {
            json.push(_equipped[i].toJSON());
        }
        return json;
    };

    // Dynamically generate accessors for different stats
    const _mods = ['getDefense', 'getAttack', 'getProtection',
        'getSpeed', 'getWillpower',
        'getAccuracy', 'getAgility', 'getStrength'];

    const that = this;
    for (let i = 0; i < _mods.length; i++) {

        /* eslint no-loop-func: 0 */
        // Use closure to fix the function name
        const getFunc = function() {
            const privVar = _mods[i];
            return function() {
                return that.propertySum(privVar);
            };
        };

        this[_mods[i]] = getFunc();
    }

};
RG.extend2(RG.Inv.Equipment, RG.Object.Ownable);

/* Object models inventory items and equipment on actor. This object handles
 * movement of items between inventory and equipment. */
RG.Inv.Inventory = function(actor) {
    RG.Object.Ownable.call(this, actor);
    const _actor = actor;

    const _inv = new RG.Item.Container(actor);
    const _eq = new RG.Inv.Equipment(actor);

    // Wrappers for container methods
    this.addItem = function(item) {_inv.addItem(item);};
    this.hasItem = function(item) {return _inv.hasItem(item);};
    this.removeItem = function(item) {return _inv.removeItem(item);};

    this.removeNItems = function(item, n) {
        return _inv.removeNItems(item, n);
    };

    this.getRemovedItem = function() {return _inv.getRemovedItem();};

    this.useItem = function(item, obj) {
        if (_inv.hasItem(item)) {
            if (item.hasOwnProperty('useItem')) {
                item.useItem(obj);
                return true;
            }
        }
        else {
            RG.err('Inv.Inventory', 'useItem', 'Not in inventory, cannot use!');
        }
        return false;
    };

    /* Returns true if given item can be carried.*/
    this.canCarryItem = function(item) {
        const eqWeight = _eq.getWeight();
        const invWeight = _inv.getWeight();
        const newWeight = eqWeight + invWeight + item.getWeight();
        const maxWeight = _actor.getMaxWeight();
        if (newWeight > maxWeight) {return false;}
        return true;
    };

    /* Drops selected item to the actor's current location.*/
    this.dropItem = function(item) {
        if (_inv.removeItem(item)) {
            const level = _actor.getLevel();
            if (level.addItem(item, _actor.getX(), _actor.getY())) {
                return true;
            }
            else {
                _inv.addItem(item);
            }
        }
        return false;
    };

    this.getInventory = function() {return _inv;};
    this.getEquipment = function() {return _eq;};

    /* Removes item from inventory and equips it.*/
    this.equipItem = function(item) {
        if (_inv.hasItem(item)) {
            // If item has count > 2, can't use the same item ref
            const eqItem = _getItemToEquip(item);
            if (RG.isNullOrUndef[eqItem]) {
                RG.err('Inv.Inventory', 'equipItem',
                    'equippedItem is null. Should not happen');
                return false; // For suppressed errors
            }

            if (_eq.equipItem(eqItem)) {
                return true;
            }
            else {
                _inv.addItem(eqItem); // Failed, add back to inv
            }
        }
        else {
            RG.err('Inv.Inventory', 'equipItem',
                'Cannot equip. Not in inventory.');
        }
        return false;
    };

    const _getItemToEquip = function(item) {
        const res = _inv.removeItem(item);
        if (res) {
            const rmvItem = _inv.getRemovedItem();
            return rmvItem;
        }
        return null;
    };

    /* Equips up to N items of given type. */
    this.equipNItems = function(item, n) {
        if (_inv.hasItem(item)) {
            const res = _inv.removeNItems(item, n);
            if (res) {
                const removedItem = _inv.getRemovedItem();
                if (_eq.equipItem(removedItem)) {
                    return true;
                }
                else {
                    _inv.addItem(removedItem);
                }
            }
        }
        return false;
    };

    /* Unequips item and puts it back to inventory.*/
    this.unequipItem = function(slotType, n) {
        const eqItem = _eq.getItem(slotType);
        if (!RG.isNullOrUndef([eqItem])) {
            if (_eq.unequipItem(slotType, n)) {
                const rmvItems = _eq.getUnequipped(slotType);
                if (rmvItems !== null) {
                    this.addItem(rmvItems);
                    return true;
                }
            }
        }
        return false;
    };

    /* Unequips and returns N items. Doesn't add to inv.*/
    this.unequipAndGetItem = function(slotType, n) {
        const eqItem = _eq.getItem(slotType);
        if (!RG.isNullOrUndef([eqItem])) {
            if (_eq.unequipItem(slotType, n)) {
                return _eq.getUnequipped(slotType);
            }
        }
        return null;
    };

    this.getWeapon = function() {
        const item = _eq.getItem('hand');
        if (!RG.isNullOrUndef([item])) {return item;}
        return null;
    };

    this.getEquipped = function(slotType) {
        return _eq.getItem(slotType);
    };

};
RG.extend2(RG.Inv.Inventory, RG.Object.Ownable);

module.exports = RG.Inv;
<commit_msg>Added getmissileweapon.<commit_after>
const RG = require('./rg.js');
RG.Item = require('./item.js');

RG.Inv = {};

//---------------------------------------------------------------------------
// EQUIPMENT AND INVENTORY
//---------------------------------------------------------------------------

/* Models one slot in the inventory. */
RG.Inv.EquipSlot = function(eq, type, stacked) {
    RG.Object.Ownable.call(this, eq);

    let _item = null;
    let _hasItem = false;
    let _unequipped = null;
    let _stacked = false;

    if (!RG.isNullOrUndef([stacked])) {_stacked = stacked;}

    this.isStacked = function() {return _stacked;};

    this.getUnequipped = function() {
        return _unequipped;
    };

    /* Returns the equipped item for this slot.*/
    this.getItem = function() {
        if (_hasItem) {return _item;}
        return null;
    };

    /* Equips given item to first available place in slot.*/
    this.equipItem = function(item) {
        if (this.canEquip(item)) {
            if (!_stacked || !_hasItem) {
                item.setOwner(this);
                _item = item;
                _hasItem = true;
            }
            else if (RG.addStackedItems(_item, item)) {
                    _hasItem = true;
                }
            return _hasItem;
        }
        return false;
    };

    /* Unequips N items from the slot. */
    this.unequipItem = function(n) {
        if (_hasItem) {
            if (!_stacked) {
                _hasItem = false;
                _unequipped = _item;
                return true;
            }
            else if (n > 0) {
                    _unequipped = RG.removeStackedItems(_item, n);
                    if (_item.count === 0) {_hasItem = false;}
                    return true;
                }
        }
        return false;
    };

    this.canEquip = function(item) {
        if (!_hasItem) {
            return true;
        }
        else if (_stacked) { // Can only equip same items to the stack
            return item.equals(_item);
        }
        return false;
    };

};
RG.extend2(RG.Inv.EquipSlot, RG.Object.Ownable);

/* Models equipment on an actor.*/
RG.Inv.Equipment = function(actor) {
    RG.Object.Ownable.call(this, actor);

    const _equipped = [];

    const _slots = {
        hand: new RG.Inv.EquipSlot(this, 'hand'),
        shield: new RG.Inv.EquipSlot(this, 'shield'),
        head: new RG.Inv.EquipSlot(this, 'head'),
        chest: new RG.Inv.EquipSlot(this, 'chest'),
        neck: new RG.Inv.EquipSlot(this, 'neck'),
        feet: new RG.Inv.EquipSlot(this, 'feet'),
        missile: new RG.Inv.EquipSlot(this, 'missile', true),
        missileweapon: new RG.Inv.EquipSlot(this, 'missileweapon'),
        spiritgem: new RG.Inv.EquipSlot(this, 'spiritgem')
    };

    const _hasSlot = function(slotType) {
        return _slots.hasOwnProperty(slotType);
    };

    this.getWeight = function() {
        let total = 0;
        for (let i = 0; i < _equipped.length; i++) {
            total += _equipped[i].getWeight() * _equipped[i].count;
        }
        return total;
    };

    this.getSlotTypes = function() {return Object.keys(_slots);};

    this.getItems = function() {return _equipped;};

    /* Returns last unequipped item for the slot.*/
    this.getUnequipped = function(slotType) {
        if (_hasSlot(slotType)) {
            return _slots[slotType].getUnequipped();
        }
        else {
            RG.err('Equipment', 'getUnequipped',
                'No slot type: ' + slotType);
        }
        return null;
    };

    /* Returns an item in the given slot.*/
    this.getItem = function(slot) {
        if (_slots.hasOwnProperty(slot)) {
            return _slots[slot].getItem();
        }
        return null;
    };

    /* Equips given item. Slot is chosen automatically from suitable available
     * ones.*/
    this.equipItem = function(item) {
        if (item.hasOwnProperty('getArmourType')) {
            if (_slots[item.getArmourType()].equipItem(item)) {
                _equipped.push(item);
                return true;
            }
        }
        // No equip property, can only equip to hand
        else if (item.getType() === 'missile') {
            if (_slots.missile.equipItem(item)) {
                _addStackedItem(item);
                return true;
            }
        }
        else if (item.getType() === 'missileweapon') {
            if (_slots.missileweapon.equipItem(item)) {
                _equipped.push(item);
                return true;
            }
        }
        else if (_slots.hand.equipItem(item)) {
            _equipped.push(item);
            return true;
        }
        return false;
    };

    const _addStackedItem = function(item) {
        let matchFound = false;
        for (let i = 0; i < _equipped.length; i++) {
            if (_equipped[i].equals(item)) {
                matchFound = true;
                break;
            }
        }
        if (!matchFound) {_equipped.push(item);}
    };

    /* Removes an item, or n items if specified.*/
    const _removeItem = function(item, n) {
        const index = _equipped.indexOf(item);
        if (index >= 0) {
            if (n > 0) {
                if (_equipped[index].hasOwnProperty('count')) {
                    if (_equipped[index].count === 0) {
                        _equipped.splice(index, 1);
                    }
                }
                return true;
            }
            else {
                _equipped.splice(index, 1);
                return true;
            }
        }
        else {
            RG.err('Equipment', 'unequipItem', 'Index < 0. Horribly wrong.');
        }
        return false;
    };

    /* Returns true if given item is equipped.*/
    this.isEquipped = function(item) {
        const index = _equipped.indexOf(item);
        return index !== -1;
    };

    this.getEquipped = function(slotType) {
        return this.getItem(slotType);
    };

    /* Unequips given slotType and index. */
    this.unequipItem = function(slotType, n) {
        if (_hasSlot(slotType)) {
            const item = _slots[slotType].getItem();
            if (_slots[slotType].unequipItem(n)) {
                return _removeItem(item, n);
            }
        }
        else {
            const msg = 'Non-existing slot type ' + slotType;
            RG.err('Equipment', 'unequipItem', msg);
        }
        return false;
    };

    this.propertySum = function(funcname) {
        let result = 0;
        const slotKeys = Object.keys(_slots);
        slotKeys.forEach(slot => {
            const item = this.getItem(slot);
            if (item !== null) {
                if (item.hasOwnProperty(funcname)) {
                    result += item[funcname]();
                }
                else if (item.has('Stats')) {
                    const sComp = item.get('Stats');
                    if (sComp.hasOwnProperty(funcname)) {
                        result += sComp[funcname]();
                    }
                }
            }
        });
        return result;
    };

    this.toJSON = function() {
        const json = [];
        for (let i = 0; i < _equipped.length; i++) {
            json.push(_equipped[i].toJSON());
        }
        return json;
    };

    // Dynamically generate accessors for different stats
    const _mods = ['getDefense', 'getAttack', 'getProtection',
        'getSpeed', 'getWillpower',
        'getAccuracy', 'getAgility', 'getStrength'];

    const that = this;
    for (let i = 0; i < _mods.length; i++) {

        /* eslint no-loop-func: 0 */
        // Use closure to fix the function name
        const getFunc = function() {
            const privVar = _mods[i];
            return function() {
                return that.propertySum(privVar);
            };
        };

        this[_mods[i]] = getFunc();
    }

};
RG.extend2(RG.Inv.Equipment, RG.Object.Ownable);

/* Object models inventory items and equipment on actor. This object handles
 * movement of items between inventory and equipment. */
RG.Inv.Inventory = function(actor) {
    RG.Object.Ownable.call(this, actor);
    const _actor = actor;

    const _inv = new RG.Item.Container(actor);
    const _eq = new RG.Inv.Equipment(actor);

    // Wrappers for container methods
    this.addItem = function(item) {_inv.addItem(item);};
    this.hasItem = function(item) {return _inv.hasItem(item);};
    this.removeItem = function(item) {return _inv.removeItem(item);};

    this.removeNItems = function(item, n) {
        return _inv.removeNItems(item, n);
    };

    this.getRemovedItem = function() {return _inv.getRemovedItem();};

    this.useItem = function(item, obj) {
        if (_inv.hasItem(item)) {
            if (item.hasOwnProperty('useItem')) {
                item.useItem(obj);
                return true;
            }
        }
        else {
            RG.err('Inv.Inventory', 'useItem', 'Not in inventory, cannot use!');
        }
        return false;
    };

    /* Returns true if given item can be carried.*/
    this.canCarryItem = function(item) {
        const eqWeight = _eq.getWeight();
        const invWeight = _inv.getWeight();
        const newWeight = eqWeight + invWeight + item.getWeight();
        const maxWeight = _actor.getMaxWeight();
        if (newWeight > maxWeight) {return false;}
        return true;
    };

    /* Drops selected item to the actor's current location.*/
    this.dropItem = function(item) {
        if (_inv.removeItem(item)) {
            const level = _actor.getLevel();
            if (level.addItem(item, _actor.getX(), _actor.getY())) {
                return true;
            }
            else {
                _inv.addItem(item);
            }
        }
        return false;
    };

    this.getInventory = function() {return _inv;};
    this.getEquipment = function() {return _eq;};

    /* Removes item from inventory and equips it.*/
    this.equipItem = function(item) {
        if (_inv.hasItem(item)) {
            // If item has count > 2, can't use the same item ref
            const eqItem = _getItemToEquip(item);
            if (RG.isNullOrUndef[eqItem]) {
                RG.err('Inv.Inventory', 'equipItem',
                    'equippedItem is null. Should not happen');
                return false; // For suppressed errors
            }

            if (_eq.equipItem(eqItem)) {
                return true;
            }
            else {
                _inv.addItem(eqItem); // Failed, add back to inv
            }
        }
        else {
            RG.err('Inv.Inventory', 'equipItem',
                'Cannot equip. Not in inventory.');
        }
        return false;
    };

    const _getItemToEquip = function(item) {
        const res = _inv.removeItem(item);
        if (res) {
            const rmvItem = _inv.getRemovedItem();
            return rmvItem;
        }
        return null;
    };

    /* Equips up to N items of given type. */
    this.equipNItems = function(item, n) {
        if (_inv.hasItem(item)) {
            const res = _inv.removeNItems(item, n);
            if (res) {
                const removedItem = _inv.getRemovedItem();
                if (_eq.equipItem(removedItem)) {
                    return true;
                }
                else {
                    _inv.addItem(removedItem);
                }
            }
        }
        return false;
    };

    /* Unequips item and puts it back to inventory.*/
    this.unequipItem = function(slotType, n) {
        const eqItem = _eq.getItem(slotType);
        if (!RG.isNullOrUndef([eqItem])) {
            if (_eq.unequipItem(slotType, n)) {
                const rmvItems = _eq.getUnequipped(slotType);
                if (rmvItems !== null) {
                    this.addItem(rmvItems);
                    return true;
                }
            }
        }
        return false;
    };

    /* Unequips and returns N items. Doesn't add to inv.*/
    this.unequipAndGetItem = function(slotType, n) {
        const eqItem = _eq.getItem(slotType);
        if (!RG.isNullOrUndef([eqItem])) {
            if (_eq.unequipItem(slotType, n)) {
                return _eq.getUnequipped(slotType);
            }
        }
        return null;
    };

    this.getWeapon = function() {
        const item = _eq.getItem('hand');
        if (!RG.isNullOrUndef([item])) {return item;}
        return null;
    };

    this.getMissileWeapon = function() {
        const item = _eq.getItem('missileweapon');
        if (!RG.isNullOrUndef([item])) {return item;}
        return null;
    };

    this.getEquipped = function(slotType) {
        return _eq.getItem(slotType);
    };

};
RG.extend2(RG.Inv.Inventory, RG.Object.Ownable);

module.exports = RG.Inv;
<|endoftext|>


<commit_before>/*
 * grunt-strip-code
 * https://github.com/nuzzio/grunt-strip-code
 *
 * Copyright (c) 2015 Rene Cabral
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function (grunt) {

    grunt.initConfig({

        paths: {
            fixtures: 'test/fixtures/',
            expected: 'test/expected/',
            tmp: 'test/tmp/'
        },

        jshint: {
            all: [
                'Gruntfile.js',
                'tasks/*.js',
                '<%= nodeunit.tests %>'
            ],
            options: {
                jshintrc: '.jshintrc'
            }
        },

        /**
         * Clear old tests
         */
        clean: {
            tests: 'test/tmp'
        },

        /**
         * Copy test fixtures to the tmp directory
         */

        copy: {
            tests: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= paths.fixtures %>',
                        src: '*',
                        dest: '<%= paths.tmp %>'
                    }
                ]
            }
        },

        /**
         * Run task on test files.
         */
        strip_code: {

            options: {
                testMode: true
            },

            default_options: {
                src: 'test/tmp/default_options.js'
            },

            strip_html_and_js_code: {
                src: 'test/tmp/sample.html',
                options: {
                    blocks: [
                        {
                            start_block: '<!--#BEGIN DEBUG#-->',
                            end_block: '<!--#END DEBUG#-->'
                        },
                        {
                            start_block: '/* BEGIN DEBUG */',
                            end_block: '/* END DEBUG */'
                        }
                    ]
                }
            },
            start_end_options: {
                options: {
                    blocks: [
                        {
                            start_block: '/* {test} */',
                            end_block: '/* {/test} */'
                        },
                        {
                            start_block: '/* test-code */',
                            end_block: '/* end-test-code */'
                        }
                    ]
                },
                src: 'test/tmp/start_end_options.js'
            },
            pattern_options: {
                options: {
                    patterns: / *console\.log\([\w\S ]+\);?\n?/g
                },
                src: 'test/tmp/patterns_options.js'
            },
            dest_specified: {
                files: [
                    {
                        src: 'test/tmp/dest_specified.js',
                        dest: 'test/tmp/dest_specified2.js'
                    }
                ]
            },
            multiple_files: {
                src: [
                    'test/tmp/multiple_files*.js',
                    'test/tmp/another_multiple_file.js'
                ]
            },
            intersection_false: {
                options: {
                    blocks: [
                        {
                            start_block: '/* {test} */',
                            end_block: '/* {/test} */'
                        },
                        {
                            start_block: '/* test-code */',
                            end_block: '/* end-test-code */'
                        }
                    ]
                },
                src: 'test/tmp/intersection-false.js'
            },
            parity_false: {
                src: 'test/tmp/parity-false.js'
            },
            legacy_pattern: {
                options: {
                    pattern: / *console\.log\([\w\S ]+\);?\n?/g
                },
                src: 'test/tmp/legacy_pattern.js'
            },
            legacy_pattern_start_end: {
                options: {
                    start_comment: 'start-test-block',
                    end_comment: 'end-test-block',
                    pattern: / *console\.log\([\w\S ]+\);?\n?/g
                },
                src: 'test/tmp/legacy_pattern_start_end.js'
            },
            legacy_start_end: {
                options: {
                    start_comment: 'start-test-block',
                    end_comment: 'end-test-block'
                },
                src: 'test/tmp/legacy_start_end.js'
            }
        },

        /**
         * Run tests
         */
        nodeunit: {
            all: ['test/*_test.js'],
            options: {
                reporter: 'verbose'
            }
        }

    });

    /**
     * Load this plugin's task(s).
     */
    grunt.loadTasks('tasks');

    /**
     * Load plugins.
     */
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-nodeunit');

    /**
     * - first clean the "tmp" dir
     * - then run this plugin's task(s)
     * - then test the result
     */
    grunt.registerTask('test', ['clean', 'copy', 'strip_code', 'nodeunit']);

    /**
     * - lint
     * - run all tests
     */
    grunt.registerTask('default', ['jshint', 'test']);

};
<commit_msg>added coveralls related tasks<commit_after>/*
 * grunt-strip-code
 * https://github.com/nuzzio/grunt-strip-code
 *
 * Copyright (c) 2015 Rene Cabral
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function (grunt) {

    var coverage = process.env.GRUNT_STRIP_CODE_COVERAGE;

    grunt.initConfig({

        paths: {
            fixtures: 'test/fixtures/',
            expected: 'test/expected/',
            tmp: 'test/tmp/',
            nodeunit: {
                tests: 'test/**/*_test.js'
            }
        },

        jshint: {
            all: [
                'Gruntfile.js',
                'tasks/*.js',
                '<%= paths.nodeunit.tests %>'
            ],
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            }
        },

        /**
         * Clear old tests
         */
        clean: {
            tests: 'test/tmp'
        },

        /**
         * Copy test fixtures to the tmp directory
         */

        copy: {
            tests: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= paths.fixtures %>',
                        src: '*',
                        dest: '<%= paths.tmp %>'
                    }
                ]
            }
        },

        /**
         * Run task on test files.
         */
        strip_code: {

            options: {
                testMode: true
            },

            default_options: {
                src: 'test/tmp/default_options.js'
            },

            strip_html_and_js_code: {
                src: 'test/tmp/sample.html',
                options: {
                    blocks: [
                        {
                            start_block: '<!--#BEGIN DEBUG#-->',
                            end_block: '<!--#END DEBUG#-->'
                        },
                        {
                            start_block: '/* BEGIN DEBUG */',
                            end_block: '/* END DEBUG */'
                        }
                    ]
                }
            },
            start_end_options: {
                options: {
                    blocks: [
                        {
                            start_block: '/* {test} */',
                            end_block: '/* {/test} */'
                        },
                        {
                            start_block: '/* test-code */',
                            end_block: '/* end-test-code */'
                        }
                    ]
                },
                src: 'test/tmp/start_end_options.js'
            },
            pattern_options: {
                options: {
                    patterns: / *console\.log\([\w\S ]+\);?\n?/g
                },
                src: 'test/tmp/patterns_options.js'
            },
            dest_specified: {
                files: [
                    {
                        src: 'test/tmp/dest_specified.js',
                        dest: 'test/tmp/dest_specified2.js'
                    }
                ]
            },
            multiple_files: {
                src: [
                    'test/tmp/multiple_files*.js',
                    'test/tmp/another_multiple_file.js'
                ]
            },
            intersection_false: {
                options: {
                    blocks: [
                        {
                            start_block: '/* {test} */',
                            end_block: '/* {/test} */'
                        },
                        {
                            start_block: '/* test-code */',
                            end_block: '/* end-test-code */'
                        }
                    ]
                },
                src: 'test/tmp/intersection-false.js'
            },
            parity_false: {
                src: 'test/tmp/parity-false.js'
            },
            legacy_pattern: {
                options: {
                    pattern: / *console\.log\([\w\S ]+\);?\n?/g
                },
                src: 'test/tmp/legacy_pattern.js'
            },
            legacy_pattern_start_end: {
                options: {
                    start_comment: 'start-test-block',
                    end_comment: 'end-test-block',
                    pattern: / *console\.log\([\w\S ]+\);?\n?/g
                },
                src: 'test/tmp/legacy_pattern_start_end.js'
            },
            legacy_start_end: {
                options: {
                    start_comment: 'start-test-block',
                    end_comment: 'end-test-block'
                },
                src: 'test/tmp/legacy_start_end.js'
            }
        },

        /**
         * Run tests
         */
        nodeunit: {
            all: ['test/*_test.js'],
            options: {
                reporter: coverage ? 'lcov' : 'verbose',
                reporterOutput: coverage ? 'coverage/all-file-comparison_test.lcov' : undefined
            }
        },

        jscoverage: {
            tasks: {
                expand: true,
                cwd: 'tasks/',
                src: '*.js',
                dest: 'coverage/tasks/'
            }
        },

        coveralls: {
            tests: {
                // LCOV coverage file (can be string, glob or array)
                src: 'coverage/all-file-comparison_test.lcov'
            }
        }

    });

    /**
     * Load this plugin's task(s).
     */
    grunt.loadTasks(coverage ? 'coverage/tasks' : 'tasks');

    /**
     * Load plugins.
     */
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-nodeunit');
    grunt.loadNpmTasks('grunt-jscoverage');
    grunt.loadNpmTasks('grunt-coveralls');

    /**
     * - first clean the "tmp" dir
     * - then run this plugin's task(s)
     * - then test the result
     */
    grunt.registerTask('test', ['jshint', 'clean', 'copy', 'strip_code', 'nodeunit']);
    grunt.registerTask('instrument', ['jscoverage']);
    grunt.registerTask('post_coverage', ['test', 'coveralls']);

    /**
     * - lint
     * - run all tests
     */
    grunt.registerTask('default', ['test']);

};
<|endoftext|>


<commit_before>var youtube_url_re = /(?:>>>*?)?(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\/?\?((?:[^\s#&=]+=[^\s#&]*&)*)?v=([\w-]{11})((?:&[^\s#&=]+=[^\s#&]*)*)&?(#t=[\dhms]{1,9})?/;
var youtube_time_re = /^#t=(?:(\d\d?)h)?(?:(\d\d?)m)?(?:(\d\d?)s)?$/;

function make_video(id, params, start) {
	if (!params)
		params = {allowFullScreen: 'true'};
	params.allowScriptAccess = 'always';
	var query = {version: 3, autohide: 1, showinfo: 0, fs: 1,
		modestbranding: 1};
	if (start)
		query.start = start;
	if (params.autoplay)
		query.autoplay = params.autoplay;
	if (params.loop) {
		query.loop = '1';
		query.playlist = id;
	}

	var bits = [];
	for (var k in query)
		bits.push(encodeURIComponent(k) + '=' +
				encodeURIComponent(query[k]));
	var uri = encodeURI('http://www.youtube.com/v/' + id) + '?' +
			bits.join('&');
	var dims = video_dims();
	var $obj = $('<object></object>').attr(dims);
	for (var name in params)
		$obj.append($('<param></param>').attr({name: name,
				value: params[name]}));
	$('<embed></embed>').attr(params).attr(dims).attr({src: uri,
		type: 'application/x-shockwave-flash'}).appendTo($obj);
	return $obj;
}

function video_dims() {
	if (window.screen && screen.width <= 320)
		return {width: 240, height: 200};
	else
		return {width: 425, height: 355};
}

$(document).on('click', '.watch', function (event) {
	if (event.which > 1)
		return;
	var $target = $(event.target);
	var $video = $target.find('object');
	if ($video.length) {
		$video.siblings('br').andSelf().remove();
		$target.css('width', 'auto');
		event.preventDefault();
		return;
	}
	if ($target.data('noembed'))
		return;
	var m = $target.attr('href').match(youtube_url_re);
	if (!m) {
		/* Shouldn't happen, but degrade to normal click action */
		return;
	}
	var start = 0;
	if (m[4]) {
		var t = m[4].match(youtube_time_re);
		if (t) {
			if (t[1])
				start += parseInt(t[1], 10) * 3600;
			if (t[2])
				start += parseInt(t[2], 10) * 60;
			if (t[3])
				start += parseInt(t[3], 10);
		}
	}

	var $obj = make_video(m[2], null, start);
	with_dom(function () {
		$target.css('width', video_dims().width).append('
', $obj);
	});
	event.preventDefault();
});

$(document).on('mouseenter', '.watch', function (event) {
	var $target = $(event.target);
	if ($target.data('requestedTitle'))
		return;
	$target.data('requestedTitle', true);
	/* Edit textNode in place so that we don't mess with the embed */
	var node = $target.contents().filter(function () {
		return this.nodeType === 3;
	})[0];
	if (!node)
		return;
	var orig = node.textContent;
	node.textContent = orig + '...';
	var m = $target.attr('href').match(youtube_url_re);
	if (!m)
		return;
	$.ajax({
		url: '//gdata.youtube.com/feeds/api/videos/' + m[2],
		data: {v: '2', alt: 'jsonc'},
		dataType: 'json',
		success: function (data) {
			var title = data && data.data && data.data.title;
			if (title) {
				node.textContent = orig + ': ' + title;
				$target.css({color: 'black'});
			}
			else
				node.textContent = orig + ' (gone?)';

			if (data && data.data && data.data.accessControl &&
				data.data.accessControl.embed == 'denied') {
				node.textContent += ' (EMBEDDING DISABLED)';
				$target.data('noembed', true);
			}
		},
		error: function () {
			node.textContent = orig + '???';
		},
	});
});
<commit_msg>Don't break scroll lock on YouTube title expansion<commit_after>var youtube_url_re = /(?:>>>*?)?(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\/?\?((?:[^\s#&=]+=[^\s#&]*&)*)?v=([\w-]{11})((?:&[^\s#&=]+=[^\s#&]*)*)&?(#t=[\dhms]{1,9})?/;
var youtube_time_re = /^#t=(?:(\d\d?)h)?(?:(\d\d?)m)?(?:(\d\d?)s)?$/;

function make_video(id, params, start) {
	if (!params)
		params = {allowFullScreen: 'true'};
	params.allowScriptAccess = 'always';
	var query = {version: 3, autohide: 1, showinfo: 0, fs: 1,
		modestbranding: 1};
	if (start)
		query.start = start;
	if (params.autoplay)
		query.autoplay = params.autoplay;
	if (params.loop) {
		query.loop = '1';
		query.playlist = id;
	}

	var bits = [];
	for (var k in query)
		bits.push(encodeURIComponent(k) + '=' +
				encodeURIComponent(query[k]));
	var uri = encodeURI('http://www.youtube.com/v/' + id) + '?' +
			bits.join('&');
	var dims = video_dims();
	var $obj = $('<object></object>').attr(dims);
	for (var name in params)
		$obj.append($('<param></param>').attr({name: name,
				value: params[name]}));
	$('<embed></embed>').attr(params).attr(dims).attr({src: uri,
		type: 'application/x-shockwave-flash'}).appendTo($obj);
	return $obj;
}

function video_dims() {
	if (window.screen && screen.width <= 320)
		return {width: 240, height: 200};
	else
		return {width: 425, height: 355};
}

$(document).on('click', '.watch', function (event) {
	if (event.which > 1)
		return;
	var $target = $(event.target);
	var $video = $target.find('object');
	if ($video.length) {
		$video.siblings('br').andSelf().remove();
		$target.css('width', 'auto');
		event.preventDefault();
		return;
	}
	if ($target.data('noembed'))
		return;
	var m = $target.attr('href').match(youtube_url_re);
	if (!m) {
		/* Shouldn't happen, but degrade to normal click action */
		return;
	}
	var start = 0;
	if (m[4]) {
		var t = m[4].match(youtube_time_re);
		if (t) {
			if (t[1])
				start += parseInt(t[1], 10) * 3600;
			if (t[2])
				start += parseInt(t[2], 10) * 60;
			if (t[3])
				start += parseInt(t[3], 10);
		}
	}

	var $obj = make_video(m[2], null, start);
	with_dom(function () {
		$target.css('width', video_dims().width).append('
', $obj);
	});
	event.preventDefault();
});

$(document).on('mouseenter', '.watch', function (event) {
	var $target = $(event.target);
	if ($target.data('requestedTitle'))
		return;
	$target.data('requestedTitle', true);
	/* Edit textNode in place so that we don't mess with the embed */
	var node = $target.contents().filter(function () {
		return this.nodeType === 3;
	})[0];
	if (!node)
		return;
	var orig = node.textContent;
	with_dom(function () {
		node.textContent = orig + '...';
	});
	var m = $target.attr('href').match(youtube_url_re);
	if (!m)
		return;

	$.ajax({
		url: '//gdata.youtube.com/feeds/api/videos/' + m[2],
		data: {v: '2', alt: 'jsonc'},
		dataType: 'json',
		success: function (data) {
			with_dom(gotInfo.bind(null, data));
		},
		error: function () {
			with_dom(function () {
				node.textContent = orig + '???';
			});
		},
	});

	function gotInfo(data) {
		var title = data && data.data && data.data.title;
		if (title) {
			node.textContent = orig + ': ' + title;
			$target.css({color: 'black'});
		}
		else
			node.textContent = orig + ' (gone?)';

		if (data && data.data && data.data.accessControl &&
				data.data.accessControl.embed == 'denied') {
			node.textContent += ' (EMBEDDING DISABLED)';
			$target.data('noembed', true);
		}
	}
});
<|endoftext|>


<commit_before>'use strict';
module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        watch: {
            sass: {
                files: ['assets/css/**/*.{scss,sass}'],
                tasks: ['sass', 'cssmin']
            },
            js: {
                files: '<%= jshint.all %>',
                tasks: ['jshint', 'uglify']
            },
            images: {
                files: ['assets/images/**/*.{png,jpg,gif}'],
                tasks: ['imagemin']
            }
        },

        // sass
        sass: {
            dist: {
                options: {
                    style: 'expanded',
                },
                files: {
                    'assets/css/build/main.css': 'assets/css/main.scss'
                }
            }
        },

        // css minify
        cssmin: {
            options: {
                keepSpecialComments: 1
            },
            minify: {
                expand: true,
                cwd: 'assets/css/build',
                src: ['*.css', '!*.min.css'],
                ext: '.css'
            }
        },

        // javascript linting with jshint
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                "force": true
            },
            all: [
                'Gruntfile.js',
                'assets/js/source/**/*.js'
            ]
        },

        // Generate zip file
        compress: {
          main: {
            options: {
              archive: "/Users/justin/Desktop/carpeaqua-2017.zip"
            },
            files: [{
              src: [
                './assets/**/*',
                'default.hbs',
                'error.hbs',
                'index.hbs',
                'package.json',
                './partials/**/*',
                'post.hbs',
              ]
            }]
          }
        },

        // uglify to concat, minify, and make source maps
        uglify: {
            plugins: {
                files: {
                    'assets/js/plugins.min.js': [
                        'node_modules/jquery/dist/jquery.js',
                        'node_modules/bigfoot/dist/bigfoot.js',
                        'node_modules/highlight/src/highlight.js',
                    ]
                }
            },
            main: {
                files: {
                    'assets/js/main.min.js': [
                        'assets/js/source/main.js'
                    ]
                }
            }
        },

        // image optimization
        imagemin: {
            dist: {
                options: {
                    optimizationLevel: 7,
                    progressive: true,
                    interlaced: true
                },
                files: [{
                    expand: true,
                    cwd: 'assets/images/',
                    src: ['**/*.{png,jpg,gif}'],
                    dest: 'assets/images/'
                }]
            }
        },

        // deploy via rsync
        deploy: {
            options: {
                src: "./",
                args: ["--verbose"],
                exclude: ['.git*', 'node_modules', '.sass-cache', 'Gruntfile.js', 'package.json', '.DS_Store', 'README.md', 'config.rb', 'Gemfile', 'yarn.lock', '.jshintrc', 'Brewfile', 'Gemfile.lock'],
                recursive: true,
                syncDestIgnoreExcl: true
            },
            staging: {
                 options: {
                    dest: "~/Projects/carpeaqua-ghost/content/themes/carpeaqua-2017/"
                }
            }
        }

    });

    // rename tasks
    grunt.renameTask('rsync', 'deploy');

    // register task
    grunt.registerTask('default', ['sass', 'cssmin', 'uglify', 'imagemin', 'watch']);

};
<commit_msg>Remove script from deploy<commit_after>'use strict';
module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        watch: {
            sass: {
                files: ['assets/css/**/*.{scss,sass}'],
                tasks: ['sass', 'cssmin']
            },
            js: {
                files: '<%= jshint.all %>',
                tasks: ['jshint', 'uglify']
            },
            images: {
                files: ['assets/images/**/*.{png,jpg,gif}'],
                tasks: ['imagemin']
            }
        },

        // sass
        sass: {
            dist: {
                options: {
                    style: 'expanded',
                },
                files: {
                    'assets/css/build/main.css': 'assets/css/main.scss'
                }
            }
        },

        // css minify
        cssmin: {
            options: {
                keepSpecialComments: 1
            },
            minify: {
                expand: true,
                cwd: 'assets/css/build',
                src: ['*.css', '!*.min.css'],
                ext: '.css'
            }
        },

        // javascript linting with jshint
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                "force": true
            },
            all: [
                'Gruntfile.js',
                'assets/js/source/**/*.js'
            ]
        },

        // Generate zip file
        compress: {
          main: {
            options: {
              archive: "/Users/justin/Desktop/carpeaqua-2017.zip"
            },
            files: [{
              src: [
                './assets/**/*',
                'default.hbs',
                'error.hbs',
                'index.hbs',
                'package.json',
                './partials/**/*',
                'post.hbs',
              ]
            }]
          }
        },

        // uglify to concat, minify, and make source maps
        uglify: {
            plugins: {
                files: {
                    'assets/js/plugins.min.js': [
                        'node_modules/jquery/dist/jquery.js',
                        'node_modules/bigfoot/dist/bigfoot.js',
                        'node_modules/highlight/src/highlight.js',
                    ]
                }
            },
            main: {
                files: {
                    'assets/js/main.min.js': [
                        'assets/js/source/main.js'
                    ]
                }
            }
        },

        // image optimization
        imagemin: {
            dist: {
                options: {
                    optimizationLevel: 7,
                    progressive: true,
                    interlaced: true
                },
                files: [{
                    expand: true,
                    cwd: 'assets/images/',
                    src: ['**/*.{png,jpg,gif}'],
                    dest: 'assets/images/'
                }]
            }
        },

        // deploy via rsync
        deploy: {
            options: {
                src: "./",
                args: ["--verbose"],
                exclude: ['.git*', 'node_modules', '.sass-cache', 'Gruntfile.js', 'package.json', '.DS_Store', 'README.md', 'config.rb', 'Gemfile', 'yarn.lock', '.bundle', 'script', '.jshintrc', 'Brewfile', 'Gemfile.lock'],
                recursive: true,
                syncDestIgnoreExcl: true
            },
            staging: {
                 options: {
                    dest: "~/Projects/carpeaqua-ghost/content/themes/carpeaqua-2017/"
                }
            }
        }

    });

    // rename tasks
    grunt.renameTask('rsync', 'deploy');

    // register task
    grunt.registerTask('default', ['sass', 'cssmin', 'uglify', 'imagemin', 'watch']);

};
<|endoftext|>


<commit_before>module.exports = function (grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    compass: {
      dist: {
        options: {
          config: 'config.rb'
        }
      }
    },

    concat: {
      vendor: {
        src: [
          'node_modules/jquery/dist/jquery.min.js'
        ],
        dest: 'pub/js/vendor.min.js'
      },
      app: {
        src: [
          'scripts/*.js'
        ],
        dest: 'pub/js/game.min.js'
      }
    },

    connect: {
      pub: {
        options: {
          base: 'pub',
          open: true,
          useAvailablePort: true
        }
      }
    },

    uglify: {
      vendor: {
        src: 'pub/js/vendor.min.js',
        dest: 'pub/js/vendor.min.js'
      },
      app: {
        src: 'pub/js/game.min.js',
        dest: 'pub/js/game.min.js'
      }
    },

    watch: {
      scripts: {
        files: ['scripts/*.js'],
        // tasks: ['concat', 'uglify'],
        tasks: ['concat'],
        options: {
          livereload: true,
          spawn: false
        }
      },

      styles: {
        files: ['sass/*.scss'],
        tasks: ['compass'],
        options: {
          livereload: true,
          spawn: false
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-connect');
  // grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // grunt.registerTask('default', ['compass', 'concat', 'connect', 'uglify', 'watch']);
  grunt.registerTask('default', ['compass', 'concat', 'connect', 'watch']);
};
<commit_msg>Specifying the hostname on grunt connect.<commit_after>module.exports = function (grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    compass: {
      dist: {
        options: {
          config: 'config.rb'
        }
      }
    },

    concat: {
      vendor: {
        src: [
          'node_modules/jquery/dist/jquery.min.js'
        ],
        dest: 'pub/js/vendor.min.js'
      },
      app: {
        src: [
          'scripts/*.js'
        ],
        dest: 'pub/js/game.min.js'
      }
    },

    connect: {
      pub: {
        options: {
          base: 'pub',
          hostname: 'localhost',
          open: true,
          useAvailablePort: true
        }
      }
    },

    uglify: {
      vendor: {
        src: 'pub/js/vendor.min.js',
        dest: 'pub/js/vendor.min.js'
      },
      app: {
        src: 'pub/js/game.min.js',
        dest: 'pub/js/game.min.js'
      }
    },

    watch: {
      scripts: {
        files: ['scripts/*.js'],
        // tasks: ['concat', 'uglify'],
        tasks: ['concat'],
        options: {
          livereload: true,
          spawn: false
        }
      },

      styles: {
        files: ['sass/*.scss'],
        tasks: ['compass'],
        options: {
          livereload: true,
          spawn: false
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-connect');
  // grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // grunt.registerTask('default', ['compass', 'concat', 'connect', 'uglify', 'watch']);
  grunt.registerTask('default', ['compass', 'concat', 'connect', 'watch']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

  // Load all available grunt tasks
  require('load-grunt-tasks')(grunt);
  // Bootcamp doesn't use a `grunt-` prefix so load it manually
  grunt.loadNpmTasks('bootcamp');

  // Configure tasks
  grunt.initConfig({

    dir : {
      src : 'sass',
      dist : 'dist'
    },

    pkg: grunt.file.readJSON('package.json'),
    projectName: '<%= pkg.name.toLowerCase() %>',

    // Concat
    concat: {
      options: {
        separator: '\n\n',
        banner: '/*! <%= projectName %> v<%= pkg.version %> – <%= grunt.template.today("dd.mm.yyyy") %> */\n\n',
      },
      dist: {
        src: [
          '<%= dir.src %>/<%= projectName %>/_config.scss',
          '<%= dir.src %>/<%= projectName %>/_support.scss',
          '<%= dir.src %>/<%= projectName %>/_api.scss'
        ],
        dest: '<%= dir.dist %>/_<%= projectName %>.scss',
      },
    },

    // Sass
    sass: {
      test: {
        options: {
          style: 'expanded',
          compass: false,
          bundleExec: true,
          loadPath: './node_modules/bootcamp/dist'
        },
        files: {
          './tmp/results.css': './test/test.scss'
        }
      }
    },

    // Tests
    bootcamp: {
      test: {
        files: {
          src: ['./tmp/results.css']
        }
      }
    },

    // Watch
    watch: {
      dist: {
        files: [
                './test/**/*.scss',
                './<%= dir.src %>/**/*.scss'
                ],
        tasks: ['test']
      }
    },

    // Docs
    sassdoc: {
      'default': {
        'src': './<%= dir.src %>',
        'dest': './docs',
        'options': {
          'config': './.sassdocrc'
        }
      }
    },

    open : {
      docs : {
        path: './docs/index.html',
        app: 'Google Chrome'
      }
    },

    // Shell
    shell: {
        options: {
            stderr: false
        },
        // Copy docs folder to gh-branch and push it
        ghpages: {
            command: [
              "git checkout gh-pages",
              "git checkout master ./docs",
              "git add -A",
              "git c -m 'docs: Update Docs to v<%= pkg.version %>'",
              "git push origin gh-pages",
              "git checkout master"
            ].join('&&')
        }
    },

    // Versioning
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: ['pkg'],
        commit: true,
        commitMessage: 'version: Bump to %VERSION%',
        commitFiles: ['package.json', 'bower.json', 'docs/*', 'dist/*'],
        createTag: true,
        tagName: '%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'origin',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
        globalReplace: false
      }
    }
  });

  // Define own tasks
  grunt.registerTask('test', ['sass', 'bootcamp']);
  grunt.registerTask('dev', ['test', 'watch']);
  grunt.registerTask('build', ['test', 'sassdoc', 'concat']);
  grunt.registerTask('docs', ['sassdoc', 'open:docs']);
  grunt.registerTask('deploy', ['sassdoc', 'build', 'bump-commit', 'shell:ghpages'])
  grunt.registerTask('patch', ['bump-only:patch', 'deploy']);
  grunt.registerTask('minor', ['bump-only:minor', 'deploy']);
};<commit_msg>build: Remove duplicate docs generation<commit_after>module.exports = function(grunt) {

  // Load all available grunt tasks
  require('load-grunt-tasks')(grunt);
  // Bootcamp doesn't use a `grunt-` prefix so load it manually
  grunt.loadNpmTasks('bootcamp');

  // Configure tasks
  grunt.initConfig({

    dir : {
      src : 'sass',
      dist : 'dist'
    },

    pkg: grunt.file.readJSON('package.json'),
    projectName: '<%= pkg.name.toLowerCase() %>',

    // Concat
    concat: {
      options: {
        separator: '\n\n',
        banner: '/*! <%= projectName %> v<%= pkg.version %> – <%= grunt.template.today("dd.mm.yyyy") %> */\n\n',
      },
      dist: {
        src: [
          '<%= dir.src %>/<%= projectName %>/_config.scss',
          '<%= dir.src %>/<%= projectName %>/_support.scss',
          '<%= dir.src %>/<%= projectName %>/_api.scss'
        ],
        dest: '<%= dir.dist %>/_<%= projectName %>.scss',
      },
    },

    // Sass
    sass: {
      test: {
        options: {
          style: 'expanded',
          compass: false,
          bundleExec: true,
          loadPath: './node_modules/bootcamp/dist'
        },
        files: {
          './tmp/results.css': './test/test.scss'
        }
      }
    },

    // Tests
    bootcamp: {
      test: {
        files: {
          src: ['./tmp/results.css']
        }
      }
    },

    // Watch
    watch: {
      dist: {
        files: [
                './test/**/*.scss',
                './<%= dir.src %>/**/*.scss'
                ],
        tasks: ['test']
      }
    },

    // Docs
    sassdoc: {
      'default': {
        'src': './<%= dir.src %>',
        'dest': './docs',
        'options': {
          'config': './.sassdocrc'
        }
      }
    },

    open : {
      docs : {
        path: './docs/index.html',
        app: 'Google Chrome'
      }
    },

    // Shell
    shell: {
        options: {
            stderr: false
        },
        // Copy docs folder to gh-branch and push it
        ghpages: {
            command: [
              "git checkout gh-pages",
              "git checkout master ./docs",
              "git add -A",
              "git c -m 'docs: Update Docs to v<%= pkg.version %>'",
              "git push origin gh-pages",
              "git checkout master"
            ].join('&&')
        }
    },

    // Versioning
    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: ['pkg'],
        commit: true,
        commitMessage: 'version: Bump to %VERSION%',
        commitFiles: ['package.json', 'bower.json', 'docs/*', 'dist/*'],
        createTag: true,
        tagName: '%VERSION%',
        tagMessage: 'Version %VERSION%',
        push: true,
        pushTo: 'origin',
        gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
        globalReplace: false
      }
    }
  });

  // Define own tasks
  grunt.registerTask('test', ['sass', 'bootcamp']);
  grunt.registerTask('dev', ['test', 'watch']);
  grunt.registerTask('build', ['test', 'sassdoc', 'concat']);
  grunt.registerTask('docs', ['sassdoc', 'open:docs']);
  grunt.registerTask('deploy', ['build', 'bump-commit', 'shell:ghpages'])
  grunt.registerTask('patch', ['bump-only:patch', 'deploy']);
  grunt.registerTask('minor', ['bump-only:minor', 'deploy']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

// Grunt config
grunt.initConfig({
// Copy config
copy: {
  build: {
    files: [
      {
        expand: true,
        cwd: 'src/',
        src: ['**/*', '!**/*.ts'],
        dest: 'build/'
      }
    ]
  }
},
// Typescript config
typescript: {
  compile: {
    src: ['./src/**/*.ts'],
    dest: './build/app.js',
    options: {
      noImplicitAny: true
    }
  }
},
// Connect options
connect: {
  server: {
    options: {
      port: 4000,
      base: 'build/',
      hostname: '*'
    }
  }
},
// Watch files
watch: {
  js: {
    files: 'src/**/*.ts',
    tasks: [ 'typescript' ]
  }
},
// Clean build
clean: {
  build: {
    src: [ 'build/' ]
  }
}
})

// Load Grunt Tasks
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-typescript')

// Tasks definitions
grunt.registerTask('js',      [ 'typescript' ])
grunt.registerTask('build',   [ 'js' ])
grunt.registerTask('server',  [ 'connect' ])
grunt.registerTask('default', [ 'clean', 'copy', 'server', 'build', 'watch' ])
}
<commit_msg>Quick fix copy task<commit_after>module.exports = function(grunt) {

// Grunt config
grunt.initConfig({
// Copy config
copy: {
  build: {
    files: [
      {
        expand: true,
        cwd: 'src/',
        src: ['**/*', '!**/*.ts'],
        dest: 'build/',
        filter: 'isFile'
      }
    ]
  }
},
// Typescript config
typescript: {
  compile: {
    src: ['./src/**/*.ts'],
    dest: './build/app.js',
    options: {
      noImplicitAny: true
    }
  }
},
// Connect options
connect: {
  server: {
    options: {
      port: 4000,
      base: 'build/',
      hostname: '*'
    }
  }
},
// Watch files
watch: {
  js: {
    files: 'src/**/*.ts',
    tasks: [ 'typescript' ]
  }
},
// Clean build
clean: {
  build: {
    src: [ 'build/' ]
  }
}
})

// Load Grunt Tasks
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-typescript')

// Tasks definitions
grunt.registerTask('js',      [ 'typescript' ])
grunt.registerTask('build',   [ 'js' ])
grunt.registerTask('server',  [ 'connect' ])
grunt.registerTask('default', [ 'clean', 'copy', 'server', 'build', 'watch' ])
}
<|endoftext|>