<commit_before>/*
 * Copyright 2013, All Rights Reserved.
 *
 * Code licensed under the BSD License:
 * https://github.com/eduardolundgren/dotfiles/blob/master/LICENSE.md
 *
 * @author Eduardo Lundgren <eduardo.lundgren@gmail.com>
 */

'use strict';

var userhome = require('userhome');

var choicesDock = require('./templates/.osx-dock');
var choicesFinder = require('./templates/.osx-finder');
var choicesGeneral = require('./templates/.osx-general');
var choicesIterm = require('./templates/.osx-iterm');
var choicesTrackpad = require('./templates/.osx-trackpad');

function copyConfigChoicesAsBooleans(config, choices, from, to) {
    choices.forEach(function(choice) {
        config[to][choice.value] =
            config.choices[from].indexOf(choice.value) > -1;
    });
}

module.exports = function(grunt) {

    grunt.initConfig({

        // -- Bump -------------------------------------------------------------

        bump: {

            options: {
                commit: true,
                commitFiles: ['package.json'],
                commitMessage: 'Release v%VERSION%',
                createTag: true,
                files: ['package.json'],
                push: true,
                pushTo: 'origin',
                tagMessage: '',
                tagName: 'v%VERSION%'
            }

        },

        // -- Config -----------------------------------------------------------

        config: {

            aliases: {
                path_aliases: userhome('.dotfiles/.aliases')
            },

            git: {
                path_gitconfig: userhome('.dotfiles/.gitconfig'),
                path_gitconfig_system: userhome('.gitconfig'),
                path_gitignore: userhome('.dotfiles/.gitignore_global'),
                path_gitignore_system: userhome('.gitignore_global')
            },

            osx: {
                path_osx: userhome('.dotfiles/.osx')
            },

            ruby: {
                path_build: userhome('.dotfiles/.rbenv/plugins/ruby-build'),
                path_rbenv: userhome('.dotfiles/.rbenv'),
                path_rbenv_system: userhome('.rbenv')
            },

            themes: {
                path_dracula: userhome('.dotfiles/themes/dracula'),
            },

            z: {
                path_z_system: userhome('.z')
            },

            zsh: {
                path_oh_my_zsh: userhome('.dotfiles/.oh-my-zsh'),
                path_plugin_syntax: userhome('.dotfiles/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting'),
                path_theme_dracula: userhome('.dotfiles/.oh-my-zsh/themes/dracula.zsh-theme'),
                path_zshrc: userhome('.dotfiles/.zshrc'),
                path_zshrc_system: userhome('.zshrc')
            }

        },

        // -- Prompt -----------------------------------------------------------

        prompt: {

            config: {
                options: {
                    questions: [
                        {
                            config: 'config.osx.computername',
                            default: 'eduardo',
                            message: 'Which computer name would you like to use?'
                        },
                        {
                            config: 'config.git.name',
                            default: 'Eduardo Lundgren',
                            message: 'Which Git name would you like to use?'
                        },
                        {
                            config: 'config.git.email',
                            default: 'eduardo.lundgren@liferay.com',
                            message: 'Which Git email would you like to use?'
                        },
                        {
                            config: 'config.editor',
                            default: 'subl',
                            message: 'Which editor would you like to use?'
                        },
                        {
                            config: 'config.zsh.plugins',
                            default: 'ant git history-substring-search z zsh-syntax-highlighting',
                            message: 'Which Oh My Zsh plugins would you like to use?'
                        },
                        {
                            config: 'config.zsh.theme_oh_my_zsh',
                            default: 'dracula',
                            message: 'Which Oh My Zsh theme would you like to use?'
                        },
                        {
                            choices: choicesGeneral,
                            config: 'config.choices.general',
                            message: 'Which OSX general options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesDock,
                            config: 'config.choices.dock',
                            message: 'Which Dock options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesFinder,
                            config: 'config.choices.finder',
                            message: 'Which Finder options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesIterm,
                            config: 'config.choices.iterm',
                            message: 'Which iTerm options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesTrackpad,
                            config: 'config.choices.trackpad',
                            message: 'Which Trackpad options would you like to use?',
                            type: 'checkbox'
                        }
                    ]
                }
            }

        },

        // -- Clean ------------------------------------------------------------

        clean: {

            all: {
                options: {
                    force: true
                },
                src: [
                    userhome('.dotfiles'),
                    '<%= config.ruby.path_rbenv_system %>',
                    '<%= config.z.path_z_system %>',
                    '<%= config.zsh.path_zshrc_system %>'
                ]
            }

        },

        // -- Templates --------------------------------------------------------

        template: {

            aliases: {
                options: {
                    data: '<%= config %>'
                },
                files: {
                    '<%= config.aliases.path_aliases %>': ['templates/.aliases']
                }
            },

            git: {
                options: {
                    data: '<%= config %>'
                },
                files: {
                    '<%= config.git.path_gitconfig %>': ['templates/.gitconfig'],
                    '<%= config.git.path_gitignore %>': ['templates/.gitignore_global']
                }
            },

            osx: {
                options: {
                    data: function() {
                        var config = grunt.config.data.config;
                        copyConfigChoicesAsBooleans(config, choicesDock, 'dock', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesFinder, 'finder', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesGeneral, 'general', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesIterm, 'iterm', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesTrackpad, 'trackpad', 'osx');
                        return config;
                    }
                },
                files: {
                    '<%= config.osx.path_osx %>': ['templates/.osx']
                }
            },

            zsh: {
                options: {
                    data: '<%= config %>'
                },
                files: {
                    '<%= config.zsh.path_zshrc %>': ['templates/.zshrc']
                }
            }

        },

        // -- Git --------------------------------------------------------------

        gitclone: {

            ruby_rbenv: {
                options: {
                    directory: '<%= config.ruby.path_rbenv %>',
                    repository: 'https://github.com/sstephenson/rbenv.git'
                }
            },

            ruby_build: {
                options: {
                    directory: '<%= config.ruby.path_build %>',
                    repository: 'https://github.com/sstephenson/ruby-build.git'
                }
            },

            oh_my_zsh: {
                options: {
                    directory: '<%= config.zsh.path_oh_my_zsh %>',
                    repository: 'https://github.com/robbyrussell/oh-my-zsh.git'
                }
            },

            theme_dracula: {
                options: {
                    directory: '<%= config.themes.path_dracula %>',
                    repository: 'https://github.com/zenorocha/dracula-theme.git'
                }
            },

            zsh_syntax_highlighting: {
                options: {
                    directory: '<%= config.zsh.path_plugin_syntax %>',
                    repository: 'https://github.com/zsh-users/zsh-syntax-highlighting.git'
                }
            }

        },

        // -- Symbolic links ---------------------------------------------------

        symlink: {

            git_config: {
                dest: '<%= config.git.path_gitconfig_system %>',
                relativeSrc: '<%= config.git.path_gitconfig %>'
            },

            git_ignore: {
                dest: '<%= config.git.path_gitignore_system %>',
                relativeSrc: '<%= config.git.path_gitignore %>'
            },

            ruby: {
                dest: '<%= config.ruby.path_rbenv_system %>',
                relativeSrc: '<%= config.ruby.path_rbenv %>'
            },

            sublime: {
                dest: '/usr/local/bin/subl',
                relativeSrc: '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'
            },

            zsh: {
                dest: '<%= config.zsh.path_zshrc_system %>',
                relativeSrc: '<%= config.zsh.path_zshrc %>'
            },

            zsh_theme_dracula: {
                dest: '<%= config.zsh.path_theme_dracula %>',
                relativeSrc: '<%= config.themes.path_dracula %>/zsh/dracula.zsh-theme'
            }

        },

        // -- Exec -------------------------------------------------------------

        shell: {

            osx: {
                command: 'source <%= config.osx.path_osx %>'
            },

            z: {
                command: 'touch <%= config.z.path_z_system %>'
            },

            zsh: {
                command: 'chsh -s /bin/zsh'
            },

            theme_alfred: {
                command: 'open <%= config.themes.path_dracula %>/alfred/Dracula.alfredappearance'
            },

            theme_iterm: {
                command: 'open <%= config.themes.path_dracula %>/iterm/Dracula.itermcolors'
            },

            node_latest: {
                command: 'sudo n latest'
            },

            node_stable: {
                command: 'sudo n stable'
            },

            ruby_compass: {
                command: 'sudo gem install compass'
            },

            ruby_jekyll: {
                command: 'sudo gem install jekyll'
            },

            ruby_update: {
                command: 'sudo gem update --system'
            }

        }

    });

    grunt.task.registerTask('banner', function() {
        console.log(grunt.file.read('templates/.banner'));
    });

    grunt.loadNpmTasks('grunt-bump');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-git');
    grunt.loadNpmTasks('grunt-prompt');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-symlink');
    grunt.loadNpmTasks('grunt-template');

    grunt.registerTask('setup', ['banner', 'prompt', 'clean', 'template', 'gitclone', 'shell', 'symlink']);

};<commit_msg>Install brew - Fix #37<commit_after>/*
 * Copyright 2013, All Rights Reserved.
 *
 * Code licensed under the BSD License:
 * https://github.com/eduardolundgren/dotfiles/blob/master/LICENSE.md
 *
 * @author Eduardo Lundgren <eduardo.lundgren@gmail.com>
 */

'use strict';

var userhome = require('userhome');

var choicesDock = require('./templates/.osx-dock');
var choicesFinder = require('./templates/.osx-finder');
var choicesGeneral = require('./templates/.osx-general');
var choicesIterm = require('./templates/.osx-iterm');
var choicesTrackpad = require('./templates/.osx-trackpad');

function copyConfigChoicesAsBooleans(config, choices, from, to) {
    choices.forEach(function(choice) {
        config[to][choice.value] =
            config.choices[from].indexOf(choice.value) > -1;
    });
}

module.exports = function(grunt) {

    grunt.initConfig({

        // -- Bump -------------------------------------------------------------

        bump: {

            options: {
                commit: true,
                commitFiles: ['package.json'],
                commitMessage: 'Release v%VERSION%',
                createTag: true,
                files: ['package.json'],
                push: true,
                pushTo: 'origin',
                tagMessage: '',
                tagName: 'v%VERSION%'
            }

        },

        // -- Config -----------------------------------------------------------

        config: {

            aliases: {
                path_aliases: userhome('.dotfiles/.aliases')
            },

            git: {
                path_gitconfig: userhome('.dotfiles/.gitconfig'),
                path_gitconfig_system: userhome('.gitconfig'),
                path_gitignore: userhome('.dotfiles/.gitignore_global'),
                path_gitignore_system: userhome('.gitignore_global')
            },

            osx: {
                path_osx: userhome('.dotfiles/.osx')
            },

            ruby: {
                path_build: userhome('.dotfiles/.rbenv/plugins/ruby-build'),
                path_rbenv: userhome('.dotfiles/.rbenv'),
                path_rbenv_system: userhome('.rbenv')
            },

            themes: {
                path_dracula: userhome('.dotfiles/themes/dracula'),
            },

            z: {
                path_z_system: userhome('.z')
            },

            zsh: {
                path_oh_my_zsh: userhome('.dotfiles/.oh-my-zsh'),
                path_plugin_syntax: userhome('.dotfiles/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting'),
                path_theme_dracula: userhome('.dotfiles/.oh-my-zsh/themes/dracula.zsh-theme'),
                path_zshrc: userhome('.dotfiles/.zshrc'),
                path_zshrc_system: userhome('.zshrc')
            }

        },

        // -- Prompt -----------------------------------------------------------

        prompt: {

            config: {
                options: {
                    questions: [
                        {
                            config: 'config.osx.computername',
                            default: 'eduardo',
                            message: 'Which computer name would you like to use?'
                        },
                        {
                            config: 'config.git.name',
                            default: 'Eduardo Lundgren',
                            message: 'Which Git name would you like to use?'
                        },
                        {
                            config: 'config.git.email',
                            default: 'eduardo.lundgren@liferay.com',
                            message: 'Which Git email would you like to use?'
                        },
                        {
                            config: 'config.editor',
                            default: 'subl',
                            message: 'Which editor would you like to use?'
                        },
                        {
                            config: 'config.zsh.plugins',
                            default: 'ant git history-substring-search z zsh-syntax-highlighting',
                            message: 'Which Oh My Zsh plugins would you like to use?'
                        },
                        {
                            config: 'config.zsh.theme_oh_my_zsh',
                            default: 'dracula',
                            message: 'Which Oh My Zsh theme would you like to use?'
                        },
                        {
                            choices: choicesGeneral,
                            config: 'config.choices.general',
                            message: 'Which OSX general options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesDock,
                            config: 'config.choices.dock',
                            message: 'Which Dock options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesFinder,
                            config: 'config.choices.finder',
                            message: 'Which Finder options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesIterm,
                            config: 'config.choices.iterm',
                            message: 'Which iTerm options would you like to use?',
                            type: 'checkbox'
                        },
                        {
                            choices: choicesTrackpad,
                            config: 'config.choices.trackpad',
                            message: 'Which Trackpad options would you like to use?',
                            type: 'checkbox'
                        }
                    ]
                }
            }

        },

        // -- Clean ------------------------------------------------------------

        clean: {

            all: {
                options: {
                    force: true
                },
                src: [
                    userhome('.dotfiles'),
                    '<%= config.ruby.path_rbenv_system %>',
                    '<%= config.z.path_z_system %>',
                    '<%= config.zsh.path_zshrc_system %>'
                ]
            }

        },

        // -- Templates --------------------------------------------------------

        template: {

            aliases: {
                options: {
                    data: '<%= config %>'
                },
                files: {
                    '<%= config.aliases.path_aliases %>': ['templates/.aliases']
                }
            },

            git: {
                options: {
                    data: '<%= config %>'
                },
                files: {
                    '<%= config.git.path_gitconfig %>': ['templates/.gitconfig'],
                    '<%= config.git.path_gitignore %>': ['templates/.gitignore_global']
                }
            },

            osx: {
                options: {
                    data: function() {
                        var config = grunt.config.data.config;
                        copyConfigChoicesAsBooleans(config, choicesDock, 'dock', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesFinder, 'finder', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesGeneral, 'general', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesIterm, 'iterm', 'osx');
                        copyConfigChoicesAsBooleans(config, choicesTrackpad, 'trackpad', 'osx');
                        return config;
                    }
                },
                files: {
                    '<%= config.osx.path_osx %>': ['templates/.osx']
                }
            },

            zsh: {
                options: {
                    data: '<%= config %>'
                },
                files: {
                    '<%= config.zsh.path_zshrc %>': ['templates/.zshrc']
                }
            }

        },

        // -- Git --------------------------------------------------------------

        gitclone: {

            ruby_rbenv: {
                options: {
                    directory: '<%= config.ruby.path_rbenv %>',
                    repository: 'https://github.com/sstephenson/rbenv.git'
                }
            },

            ruby_build: {
                options: {
                    directory: '<%= config.ruby.path_build %>',
                    repository: 'https://github.com/sstephenson/ruby-build.git'
                }
            },

            oh_my_zsh: {
                options: {
                    directory: '<%= config.zsh.path_oh_my_zsh %>',
                    repository: 'https://github.com/robbyrussell/oh-my-zsh.git'
                }
            },

            theme_dracula: {
                options: {
                    directory: '<%= config.themes.path_dracula %>',
                    repository: 'https://github.com/zenorocha/dracula-theme.git'
                }
            },

            zsh_syntax_highlighting: {
                options: {
                    directory: '<%= config.zsh.path_plugin_syntax %>',
                    repository: 'https://github.com/zsh-users/zsh-syntax-highlighting.git'
                }
            }

        },

        // -- Symbolic links ---------------------------------------------------

        symlink: {

            git_config: {
                dest: '<%= config.git.path_gitconfig_system %>',
                relativeSrc: '<%= config.git.path_gitconfig %>'
            },

            git_ignore: {
                dest: '<%= config.git.path_gitignore_system %>',
                relativeSrc: '<%= config.git.path_gitignore %>'
            },

            ruby: {
                dest: '<%= config.ruby.path_rbenv_system %>',
                relativeSrc: '<%= config.ruby.path_rbenv %>'
            },

            sublime: {
                dest: '/usr/local/bin/subl',
                relativeSrc: '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'
            },

            zsh: {
                dest: '<%= config.zsh.path_zshrc_system %>',
                relativeSrc: '<%= config.zsh.path_zshrc %>'
            },

            zsh_theme_dracula: {
                dest: '<%= config.zsh.path_theme_dracula %>',
                relativeSrc: '<%= config.themes.path_dracula %>/zsh/dracula.zsh-theme'
            }

        },

        // -- Exec -------------------------------------------------------------

        shell: {

            osx: {
                command: 'source <%= config.osx.path_osx %>'
            },

            z: {
                command: 'touch <%= config.z.path_z_system %>'
            },

            zsh: {
                command: 'chsh -s /bin/zsh'
            },

            theme_alfred: {
                command: 'open <%= config.themes.path_dracula %>/alfred/Dracula.alfredappearance'
            },

            theme_iterm: {
                command: 'open <%= config.themes.path_dracula %>/iterm/Dracula.itermcolors'
            },

            node_latest: {
                command: 'sudo n latest'
            },

            node_stable: {
                command: 'sudo n stable'
            },

            ruby_compass: {
                command: 'sudo gem install compass'
            },

            ruby_jekyll: {
                command: 'sudo gem install jekyll'
            },

            ruby_update: {
                command: 'sudo gem update --system'
            },

            brew: {
                command: 'ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"'
            }

        }

    });

    grunt.task.registerTask('banner', function() {
        console.log(grunt.file.read('templates/.banner'));
    });

    grunt.loadNpmTasks('grunt-bump');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-git');
    grunt.loadNpmTasks('grunt-prompt');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-symlink');
    grunt.loadNpmTasks('grunt-template');

    grunt.registerTask('setup', ['banner', 'prompt', 'clean', 'template', 'gitclone', 'shell', 'symlink']);

};<|endoftext|>


<commit_before>import moment from 'moment';
import {HttpClient} from 'aurelia-http-client';

var getFood = 'http://sugars.herokuapp.com/api/food',
    postEntry = 'http://sugars.herokuapp.com/api/entry';

export class Entry{
  static inject() { return [HttpClient]; }
  constructor(http){
    this.heading = 'New Entry';
    this.glucose = 0;
    this.quantity = 0;
    this.exercise = 0;
    this.chosenFood =
      {
        name : 'Default',
        unit : 'unit',
        defaultAmount : 0,
        carbs : 0
      };
    this.food = [];
    this.images = [];
    this.http = http;
    // this.food = [
    //   {
    //     name : 'Pizza',
    //     unit : 'slice',
    //     amount : 1,
    //     carbs : 30
    //   },
    //   {
    //     name : 'Rice',
    //     unit : 'cup',
    //     amount : 1,
    //     carbs : 45
    //   },
    //   {
    //     name : 'Bread',
    //     unit : 'slice',
    //     amount : 1,
    //     carbs : 20
    //   }
    // ];
  }

  activate(){
    return this.http.get(getFood).then(response => {
      this.food = response.content;
    });
  }

  entry(){
    var data = {
      glucoseLevel : this.glucose,
      exerciseCarbs : this.exercise,
      insulinShort : this.short,
      foodItems : [
        {
          id : null,
          quantity : this.quantity,
          carbs : this.chosenFood.carbs,
          name : this.chosenFood.name,
          unit : this.chosenFood.unit,
          defaultAmount : this.chosenFood.defaultAmount
        }]
    };

    return this.http.post(postEntry, JSON.stringify(data)).then(response => {

      if (response.statusCode === 201) {
        console.log('Success');
      } else {
        console.log('Response', response);
        alert('Something went wrong');
      }
    });
  }

  get time(){
    return moment().format("dddd, Do MMMM YYYY, h:mm a");
  }

  get totalCarbs(){
    var calculation = parseInt(this.quantity) * parseInt(this.chosenFood.carbs);
    return `${calculation}`;
  }

  get plural(){
    if (this.quantity > 1 || this.quantity === 0) {
      return 's';
    }
  }

  get calc(){
    var normalAdjust = (parseInt(this.glucose) - 7) / 3,
        foodAdjust = (isNaN(parseInt(this.totalCarbs) / 10)) ? 0 : parseInt(this.totalCarbs) / 10,
        exerciseAdjust = parseInt(this.exercise),
        calculation = Math.round(((normalAdjust + foodAdjust - exerciseAdjust) * 10) / 10);

        calculation = (calculation < 0) ? 0 : calculation;

    return `${calculation}`;
  }

  addFood(){
    return alert('adding some foods');
  }

}

//1. user inputs data, new entry record is saved on submit.
//2. user inputs new food name, number of carbs per unit and quantity, new food record is saved on submit ("unit" can be default unit name)
//3. api returns food list

<commit_msg>Ben helps so much he depress<commit_after>import moment from 'moment';
import {HttpClient} from 'aurelia-http-client';

var getFood = 'http://sugars.herokuapp.com/api/food',
    postEntry = 'http://sugars.herokuapp.com/api/entry';

export class Entry{
  static inject() { return [HttpClient]; }
  constructor(http){
    this.heading = 'New Entry';
    this.glucose = 0;
    this.quantity = 0;
    this.exercise = 0;
    this.chosenFood =
      {
        name : 'Default',
        unit : 'unit',
        defaultAmount : 0,
        carbs : 0
      };
    this.food = [];
    this.images = [];
    this.http = http;
    // this.food = [
    //   {
    //     name : 'Pizza',
    //     unit : 'slice',
    //     amount : 1,
    //     carbs : 30
    //   },
    //   {
    //     name : 'Rice',
    //     unit : 'cup',
    //     amount : 1,
    //     carbs : 45
    //   },
    //   {
    //     name : 'Bread',
    //     unit : 'slice',
    //     amount : 1,
    //     carbs : 20
    //   }
    // ];
  }

  activate(){
    return this.http.get(getFood).then(response => {
      this.food = response.content;
    });
  }

  entry(){
    var data = {
      glucoseLevel : this.glucose,
      exerciseCarbs : this.exercise,
      insulinShort : this.short,
      foodItems : [
        {
          id : null,
          quantity : this.quantity,
          carbs : this.chosenFood.carbs,
          name : this.chosenFood.name,
          unit : this.chosenFood.unit,
          defaultAmount : this.chosenFood.defaultAmount
        }]
    };

    return this.http.post(postEntry, JSON.stringify(data)).then(response => {

      if (response.statusCode === 200) {
        console.log('Success');
      } else {
        console.log('Response', response);
        alert('Something went wrong');
      }
    });
  }

  get time(){
    return moment().format("dddd, Do MMMM YYYY, h:mm a");
  }

  get totalCarbs(){
    var calculation = parseInt(this.quantity) * parseInt(this.chosenFood.carbs);
    return `${calculation}`;
  }

  get plural(){
    if (this.quantity > 1 || this.quantity === 0) {
      return 's';
    }
  }

  get calc(){
    var normalAdjust = (parseInt(this.glucose) - 7) / 3,
        foodAdjust = (isNaN(parseInt(this.totalCarbs) / 10)) ? 0 : parseInt(this.totalCarbs) / 10,
        exerciseAdjust = parseInt(this.exercise),
        calculation = Math.round(((normalAdjust + foodAdjust - exerciseAdjust) * 10) / 10);

        calculation = (calculation < 0) ? 0 : calculation;

    return `${calculation}`;
  }

  addFood(){
    return alert('adding some foods');
  }

}

//1. user inputs data, new entry record is saved on submit.
//2. user inputs new food name, number of carbs per unit and quantity, new food record is saved on submit ("unit" can be default unit name)
//3. api returns food list

<|endoftext|>


<commit_before>var get = Ember.get, set = Ember.set;

// This object is a regular JS object for performance. It is only
// used internally for bookkeeping purposes.
var DataProxy = DS._DataProxy = function(record) {
  this.record = record;
  this.unsavedData = {};
  this.associations = {};
};

DataProxy.prototype = {
  get: function(key) { return Ember.get(this, key); },
  set: function(key, value) { return Ember.set(this, key, value); },

  setAssociation: function(key, value) {
    this.associations[key] = value;
  },

  savedData: function() {
    var savedData = this._savedData;
    if (savedData) { return savedData; }

    var record = this.record,
        clientId = get(record, 'clientId'),
        store = get(record, 'store');

    if (store) {
      savedData = store.dataForRecord(record);
      this._savedData = savedData;
      return savedData;
    }
  },

  unknownProperty: function(key) {
    var unsavedData = this.unsavedData,
        associations = this.associations,
        savedData = this.savedData(),
        store;

    var value = unsavedData[key], association;

    // if this is a belongsTo association, this will
    // be a clientId.
    association = associations[key];

    if (association !== undefined) {
      store = get(this.record, 'store');
      return store.clientIdToId[association];
    }

    if (savedData && value === undefined) {
      value = savedData[key];
    }

    return value;
  },

  setUnknownProperty: function(key, value) {
    var record = this.record,
        unsavedData = this.unsavedData;

    unsavedData[key] = value;

    record.hashWasUpdated();

    return value;
  },

  commit: function() {
    this.saveData();

    this.record.notifyPropertyChange('data');
  },

  rollback: function() {
    this.unsavedData = {};

    this.record.notifyPropertyChange('data');
  },

  saveData: function() {
    var record = this.record;

    var unsavedData = this.unsavedData;
    var savedData = this.savedData();

    for (var prop in unsavedData) {
      if (unsavedData.hasOwnProperty(prop)) {
        savedData[prop] = unsavedData[prop];
        delete unsavedData[prop];
      }
    }
  },

  adapterDidUpdate: function() {
    this.unsavedData = {};
  }
};
<commit_msg>Add a bit of documentation to data proxy<commit_after>var get = Ember.get, set = Ember.set;

//  When a record is changed on the client, it is considered "dirty"--there are
//  pending changes that need to be saved to a persistence layer, such as a
//  server.
//
//  If the record is rolled back, it re-enters a clean state, any changes are
//  discarded, and its attributes are reset back to the last known good copy
//  of the data that came from the server.
//
//  If the record is committed, the changes are sent to the server to be saved,
//  and once the server confirms that they are valid, the record's "canonical"
//  data becomes the original canonical data plus the changes merged in.
//
//  A DataProxy is an object that encapsulates this change tracking. It
//  contains three buckets:
//
//  * `savedData` - the last-known copy of the data from the server
//  * `unsavedData` - a hash that contains any changes that have not yet
//     been committed
//  * `associations` - this is similar to `savedData`, but holds the client
//    ids of associated records
//
//  When setting a property on the object, the value is placed into the
//  `unsavedData` bucket:
//
//      proxy.set('key', 'value');
//
//      // unsavedData:
//      {
//        key: "value"
//      }
//
//  When retrieving a property from the object, it first looks to see
//  if that value exists in the `unsavedData` bucket, and returns it if so.
//  Otherwise, it returns the value from the `savedData` bucket.
//
//  When the adapter notifies a record that it has been saved, it merges the
//  `unsavedData` bucket into the `savedData` bucket. If the record's
//  transaction is rolled back, the `unsavedData` hash is simply discarded.
//
//  This object is a regular JS object for performance. It is only
//  used internally for bookkeeping purposes.

var DataProxy = DS._DataProxy = function(record) {
  this.record = record;

  this.unsavedData = {};

  this.associations = {};
};

DataProxy.prototype = {
  get: function(key) { return Ember.get(this, key); },
  set: function(key, value) { return Ember.set(this, key, value); },

  setAssociation: function(key, value) {
    this.associations[key] = value;
  },

  savedData: function() {
    var savedData = this._savedData;
    if (savedData) { return savedData; }

    var record = this.record,
        clientId = get(record, 'clientId'),
        store = get(record, 'store');

    if (store) {
      savedData = store.dataForRecord(record);
      this._savedData = savedData;
      return savedData;
    }
  },

  unknownProperty: function(key) {
    var unsavedData = this.unsavedData,
        associations = this.associations,
        savedData = this.savedData(),
        store;

    var value = unsavedData[key], association;

    // if this is a belongsTo association, this will
    // be a clientId.
    association = associations[key];

    if (association !== undefined) {
      store = get(this.record, 'store');
      return store.clientIdToId[association];
    }

    if (savedData && value === undefined) {
      value = savedData[key];
    }

    return value;
  },

  setUnknownProperty: function(key, value) {
    var record = this.record,
        unsavedData = this.unsavedData;

    unsavedData[key] = value;

    record.hashWasUpdated();

    return value;
  },

  commit: function() {
    this.saveData();

    this.record.notifyPropertyChange('data');
  },

  rollback: function() {
    this.unsavedData = {};

    this.record.notifyPropertyChange('data');
  },

  saveData: function() {
    var record = this.record;

    var unsavedData = this.unsavedData;
    var savedData = this.savedData();

    for (var prop in unsavedData) {
      if (unsavedData.hasOwnProperty(prop)) {
        savedData[prop] = unsavedData[prop];
        delete unsavedData[prop];
      }
    }
  },

  adapterDidUpdate: function() {
    this.unsavedData = {};
  }
};
<|endoftext|>


<commit_before>var C = 10;
var colors = require('./colors.js');
var mapCX = 1000;
var mapCY = 1000;
var unit = mapCX/30;

function u(n) { return unit*n; }

function createPoly(cX, cY, w, h, color, b1)
{
var retArray = [];
if(b1[0])
{
	retArray=retArray.concat([{
      position : {x: cX, y: cY - (h/2)},
      spatial: {x : w/2 , y: C},
      color: color[0]
    }]);
}if(b1[1])
{

	retArray=retArray.concat([{
      position : {x: cX +(w/2) + C, y: cY},
      spatial: {x : C, y: h/2 + C},
      color: color[1]
    }]);
}
if(b1[2])
{
	retArray=retArray.concat([{
      position : {x: cX, y: cY +(h/2)},
      spatial: {x : w/2, y: C},
      color: color[2]
    }]);
}
if(b1[3])
{
	retArray=retArray.concat( [  {
      position : {x: cX-(w/2)-C, y: cY},
      spatial: {x : C, y: h/2 + C},
      color: color[3]
    }]);
}
return retArray;
}

module.exports = {
  levelObjects:{
    playerStart: {x: C + 100, y: 50 + C},
    levelFinish:{x: (3*(mapCX/4)), y: (mapCY/3)}
  },
  gems: [
  ],
  walls: [
    {
      position : {x:u(6), y: u(17)},
      spatial: {x : C, y: u(8)},
      color: colors.green,
	text: 'g1'
    },
    {
      position : {x:u(6), y: u(4)},
      spatial: {x : C, y: u(5)},
      color: colors.orange,
	text: 'o1'
    },
    {
      position : {x:u(12)+C, y: u(12)},
      spatial: {x : C, y: u(12)},
      color: colors.red,
	text:'r1'
    },
    {
      position : {x:u(18), y: u(18)},
      spatial: {x : C, y: u(6)},
      color: colors.orange,
	text: 'o2'
    },
    {
      position : {x:u(18), y: u(6)},
      spatial: {x : C, y: u(6)},
      color: colors.purple,
	text:'p1'
    },
    {
      position : {x:u(22), y: u(4)},
      spatial: {x : C, y: u(4)},
      color: colors.blue,
	text:'b3'
    },
    {
      position : {x:u(26), y: u(8)-C},
      spatial: {x : u(4), y: C},
      color: colors.blue,
	text:'b4'
    },
    {
      position : {x:u(22), y: u(10)},
      spatial: {x : C, y: u(2)},
      color: colors.green
    },
    {
      position : {x:u(20)+C, y: u(12)},
      spatial: {x : u(2), y: C},
      color: colors.blue,
	text:'b5'
    },
    {
      position : {x:u(26), y: u(12)},
      spatial: {x : u(4), y: C},
      color: colors.purple,
	text:'p3'
    },
    {
      position : {x:u(25), y: u(3)},
      spatial: {x : C, y: u(3)},
      color: colors.green,
	text:'g2'
    },
    {
      position : {x:u(28), y: u(6)-C},
      spatial: {x : u(3), y: C},
      color: colors.green,
	text:'g3'
    },
    {
      position : {x:u(31)+C, y: u(6)-C},
      spatial: {x : u(1), y: C},
      color: colors.purple,
	text:'p4'
    },
    {
      position : {x:u(30), y: u(15)},
      spatial: {x : C, y: u(9)},
      color: colors.red,
	text: 'r3'
    },
    {
      position : {x:u(24)+C, y: u(17)},
      spatial: {x : u(6), y: C},
      color: colors.green,
	text:'g4'
    },
    {
      position : {x:u(31)+C, y: u(8)-C},
      spatial: {x : u(1), y: C},
      color: colors.green,
	text:'g5'
    },
    {
      position : {x:u(31)+C, y: u(12)},
      spatial: {x : u(1), y: C},
      color: colors.blue,
	text:'b6'
    }
].concat(createPoly(u(9), u(13), u(6), u(8),
	[colors.blue,colors.yellow,colors.purple,colors.red],
	[1,0,1,0] ) ).concat(
	createPoly(u(3), u(13), u(6), u(8),
	[colors.red,null,colors.blue,null],
	[true,false,true,false] )
	)

};
<commit_msg>level 4 update<commit_after>var C = 10;
var colors = require('./colors.js');
var mapCX = 1000;
var mapCY = 1000;
var unit = mapCX/30;

function u(n) { return unit*n; }

function createPoly(cX, cY, w, h, color, b1)
{
var retArray = [];
if(b1[0])
{
	retArray=retArray.concat([{
      position : {x: cX, y: cY - (h/2)},
      spatial: {x : w/2 , y: C},
      color: color[0]
    }]);
}if(b1[1])
{

	retArray=retArray.concat([{
      position : {x: cX +(w/2) + C, y: cY},
      spatial: {x : C, y: h/2 + C},
      color: color[1]
    }]);
}
if(b1[2])
{
	retArray=retArray.concat([{
      position : {x: cX, y: cY +(h/2)},
      spatial: {x : w/2, y: C},
      color: color[2]
    }]);
}
if(b1[3])
{
	retArray=retArray.concat( [  {
      position : {x: cX-(w/2)-C, y: cY},
      spatial: {x : C, y: h/2 + C},
      color: color[3]
    }]);
}
return retArray;
}

module.exports = {
  levelObjects:{
    playerStart: {x: C + 100, y: 50 + C},
    levelFinish:{x: (3*(mapCX/4)), y: (mapCY/3)}
  },
  gems: [
  ],
  walls: [
    {
      position : {x:u(6), y: u(17)},
      spatial: {x : C, y: u(8)},
      color: colors.green,
	text: 'g1'
    },
    {
      position : {x:u(6), y: u(4)},
      spatial: {x : C, y: u(5)},
      color: colors.yellow,
	text: 'o1'
    },
    {
      position : {x:u(12)+C, y: u(12)},
      spatial: {x : C, y: u(12)},
      color: colors.red,
	text:'r1'
    },
    {
      position : {x:u(18), y: u(18)},
      spatial: {x : C, y: u(6)},
      color: colors.yellow,
	text: 'o2'
    },
    {
      position : {x:u(18), y: u(6)},
      spatial: {x : C, y: u(6)},
      color: colors.purple,
	text:'p1'
    },
    {
      position : {x:u(22), y: u(4)},
      spatial: {x : C, y: u(4)},
      color: colors.blue,
	text:'b3'
    },
    {
      position : {x:u(26), y: u(8)-C},
      spatial: {x : u(4), y: C},
      color: colors.blue,
	text:'b4'
    },
    {
      position : {x:u(22), y: u(10)},
      spatial: {x : C, y: u(2)},
      color: colors.green
    },
    {
      position : {x:u(20)+C, y: u(12)},
      spatial: {x : u(2), y: C},
      color: colors.blue,
	text:'b5'
    },
    {
      position : {x:u(26), y: u(12)},
      spatial: {x : u(4), y: C},
      color: colors.purple,
	text:'p3'
    },
    {
      position : {x:u(25), y: u(3)},
      spatial: {x : C, y: u(3)},
      color: colors.green,
	text:'g2'
    },
    {
      position : {x:u(28), y: u(6)-C},
      spatial: {x : u(3), y: C},
      color: colors.green,
	text:'g3'
    },
    {
      position : {x:u(32)+C, y: u(6)-C},
      spatial: {x : u(2), y: C},
      color: colors.purple,
	text:'p4'
    },
    {
      position : {x:u(30), y: u(15)},
      spatial: {x : C, y: u(9)},
      color: colors.red,
	text: 'r3'
    },
    {
      position : {x:u(24)+C, y: u(17)},
      spatial: {x : u(6), y: C},
      color: colors.green,
	text:'g4'
    },
    {
      position : {x:u(32)+C, y: u(8)-C},
      spatial: {x : u(2), y: C},
      color: colors.green,
	text:'g5'
    },
    {
      position : {x:u(32)+C, y: u(12)},
      spatial: {x : u(2), y: C},
      color: colors.blue,
	text:'b6'
    }
].concat(createPoly(u(9), u(13), u(6), u(8),
	[colors.blue,colors.yellow,colors.purple,colors.red],
	[1,0,1,0] ) ).concat(
	createPoly(u(3), u(13), u(6), u(8),
	[colors.red,null,colors.blue,null],
	[true,false,true,false] )
	)

};
<|endoftext|>


<commit_before>/* global module: true */
module.exports = function (grunt) {
   'use strict';
   var SAUCE_USERNAME;
   var SAUCE_ACCESS_KEY;
   setSauceLabsKeys();

   require('load-grunt-tasks')(grunt);
   require('time-grunt')(grunt);

   // Project configuration.
   grunt.initConfig({
      pkg: grunt.file.readJSON('package.json'),
      meta: {
         banner: [
                '/**',
                ' * <%= pkg.name %>',
                ' * <%= pkg.description %>',
                ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>' +
                ' * @link <%= pkg.homepage %>',
                ' * @author <%= pkg.author %>',
                ' * @license MIT License, http://www.opensource.org/licenses/MIT',
                ' */'
            ].join('\n')
      },
      dirs: {
         dest: 'dist',
         dep: 'bower_components',
         source: 'src',
         test: 'test'
      },
      files: {
         src: [
               '<%= dirs.source %>/utils/settingsUtils.js',
               '<%= dirs.source %>/utils/arrayUtils.js',
               '<%= dirs.source %>/utils/logUtils.js',
               '<%= dirs.source %>/utils/objectUtils.js',
               '<%= dirs.source %>/utils/functionUtils.js',
               '<%= dirs.source %>/utils/stringUtils.js',
               '<%= dirs.source %>/utils/htmlElementUtils.js',
               '<%= dirs.source %>/moduleSystem/constants.js',
               '<%= dirs.source %>/moduleSystem/descriptorCreators.js',
               '<%= dirs.source %>/moduleSystem/settings.js',
               '<%= dirs.source %>/moduleSystem/modules/moduleLoader.js',
               '<%= dirs.source %>/moduleSystem/modules/moduleBuilder.js',
               '<%= dirs.source %>/moduleSystem/modules/loadedModulesContainer.js',
               '<%= dirs.source %>/moduleSystem/modules/modules.js',
               '<%= dirs.source %>/moduleSystem/modules/domEventListener.js',
               '<%= dirs.source %>/moduleSystem/parts/partBuilder.js',
               '<%= dirs.source %>/moduleSystem/parts/parts.js',
               '<%= dirs.source %>/eventBus/eventBus.js',
               '<%= dirs.source %>/moduleSystem/moduleSystem.js']
      },
      concat: {
         options: {
            banner: '<%= meta.banner %>'
         },
         dist: {
            src: [
               '<%= dirs.source %>/intro.js',
               '<%= files.src %>',
               '<%= dirs.source %>/outro.js'
            ],
            dest: '<%= dirs.dest %>/<%= pkg.name %>.<%= pkg.version %>.js'
         }
      },
      bower: {
         install: {},
         options: {
            copy: false
         }
      },
      uglify: {
         options: {
            banner: '<%= meta.banner %>'
         },
         dist: {
            src: ['<%= concat.dist.dest %>'],
            dest: '<%= dirs.dest %>/<%= pkg.name %>.<%= pkg.version %>.min.js'
         }
      },
      jshint: {
         files: ['<%= dirs.source %>/**/*.js'],
         options: {
            jshintrc: true
         }
      },
      jasmine: {
         options: {
            vendor: [
               '<%= dirs.dep %>/jquery/dist/jquery.js',
               '<%= dirs.dep %>/jasmine-jsreporter-real/jasmine-jsreporter.js',
               '<%= dirs.dep %>/jasmine-jquery/lib/jasmine-jquery.js'
            ],
            helpers: ['<%= dirs.test %>/helpers/**/*.js'],
            specs: [
               '<%= dirs.test %>/specs/**/*Spec.js'
            ]
         },
         test: {
            src: '<%= files.src %>',
            options: '<%= jasmine.options %>'
         },
         coverage: {
            src: '<%= jasmine.test.src %>',
            options: {
               vendor: [
                  '<%= dirs.dep %>/jquery/dist/jquery.js',
                  '<%= dirs.dep %>/jasmine-jsreporter-real/jasmine-jsreporter.js',
                  '<%= dirs.dep %>/jasmine-jquery/lib/jasmine-jquery.js'
               ],
               helpers: ['<%= dirs.test %>/helpers/**/*.js'],
               specs: [
                  '<%= dirs.test %>/specs/**/*Spec.js'
               ],
               template : require('grunt-template-jasmine-istanbul'),
			      templateOptions: {
                  coverage: 'reports/coverage.json',
                  report: [
						   {
							   type: 'html',
							   options: {
								   dir: 'reports/html'
							   }
						   },
						   {
							   type: 'lcov',
							   options: {
								   dir: 'reports/lcov'
							   }
						   },
					   ]
				   }
            }
         },
         prod: {
            src: '<%= concat.dist.dest %>',
            options: '<%= jasmine.options %>'
         },
         prodMin: {
            src: '<%= uglify.dist.dest %>',
            options: '<%= jasmine.options %>'
         }
      },
      coveralls: {
         options: {
            force: true
         },
         run: {
            src: 'reports/lcov/lcov.info'
         }
      },
      copy: {
         release: {
            src: '<%= concat.dist.dest %>',
            dest: '<%= dirs.dest %>/<%= pkg.name %>.js'
         },
         releaseMin: {
            src: '<%= uglify.dist.dest %>',
            dest: '<%= dirs.dest %>/<%= pkg.name %>.min.js'
         }
      },
      'saucelabs-jasmine': {
         all: {
            options: {
               username: SAUCE_USERNAME,
               key: SAUCE_ACCESS_KEY,
               urls: ['http://127.0.0.1:<%= connect.server.options.port %>/_SpecRunner.html'],
               build: (process.env.TRAVIS_BUILD_NUMBER) ? process.env.TRAVIS_BUILD_NUMBER : undefined,
               testname: (process.env.TRAVIS_BRANCH) ? process.env.TRAVIS_BRANCH : 'manual test',
               browsers: [{
                  browserName: 'chrome'
               }, {
                  browserName: 'firefox'
               }, {
                  browserName: 'safari',
                  version: '8'
               }, {
                  browserName: 'safari',
                  version: '7'
               }, {
                  browserName: 'safari',
                  version: '6'
               }, {
                  browserName: 'safari',
                  version: '5'
               }, {
                  browserName: 'internet explorer',
                  version: '11'
               }, {
                  browserName: 'internet explorer',
                  version: '10'
               }, {
                  browserName: 'internet explorer',
                  version: '9'
               }, {
                  browserName: 'internet explorer',
                  version: '8'
               }]
            }
         }
      },
      connect: {
         server: {
            options: {
               port: '8080',
               base: '.'
            }
         }
      }

   });

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

   // Build task.
   grunt.registerTask('build', ['bower', 'jshint', 'test', 'concat', 'uglify', 'testProd', 'copy']);

   var testJobs = ['jasmine:coverage'];
   if (SAUCE_ACCESS_KEY && SAUCE_USERNAME) {
      testJobs.push('sauce');
   }

   grunt.registerTask('test', testJobs);

   grunt.registerTask('testProd', ['jasmine:prod', 'jasmine:prodMin']);

   grunt.registerTask('sauce', ['createSpecRunner', 'connect', 'saucelabs-jasmine']);

   grunt.registerTask('createSpecRunner', [
      'jasmine:test:build'
   ]);

   function setSauceLabsKeys() {
      if(process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
         SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY;
         SAUCE_USERNAME = process.env.SAUCE_USERNAME;
      } else if(process.env.TRAVIS_BRANCH === 'master' &&
                process.env.SAUCE_USERNAME_MASTER && process.env.SAUCE_ACCESS_KEY_MASTER) {
         SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY_MASTER;
         SAUCE_USERNAME = process.env.SAUCE_USERNAME_MASTER;
      } else if(process.env.SAUCE_USERNAME_DEVELOP && process.env.SAUCE_ACCESS_KEY_DEVELOP) {
         SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY_DEVELOP;
         SAUCE_USERNAME = process.env.SAUCE_USERNAME_DEVELOP;
      }

   }
};
<commit_msg>fixed saucelabs firefox build problem<commit_after>/* global module: true */
module.exports = function (grunt) {
   'use strict';
   var SAUCE_USERNAME;
   var SAUCE_ACCESS_KEY;
   setSauceLabsKeys();

   require('load-grunt-tasks')(grunt);
   require('time-grunt')(grunt);

   // Project configuration.
   grunt.initConfig({
      pkg: grunt.file.readJSON('package.json'),
      meta: {
         banner: [
                '/**',
                ' * <%= pkg.name %>',
                ' * <%= pkg.description %>',
                ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>' +
                ' * @link <%= pkg.homepage %>',
                ' * @author <%= pkg.author %>',
                ' * @license MIT License, http://www.opensource.org/licenses/MIT',
                ' */'
            ].join('\n')
      },
      dirs: {
         dest: 'dist',
         dep: 'bower_components',
         source: 'src',
         test: 'test'
      },
      files: {
         src: [
               '<%= dirs.source %>/utils/settingsUtils.js',
               '<%= dirs.source %>/utils/arrayUtils.js',
               '<%= dirs.source %>/utils/logUtils.js',
               '<%= dirs.source %>/utils/objectUtils.js',
               '<%= dirs.source %>/utils/functionUtils.js',
               '<%= dirs.source %>/utils/stringUtils.js',
               '<%= dirs.source %>/utils/htmlElementUtils.js',
               '<%= dirs.source %>/moduleSystem/constants.js',
               '<%= dirs.source %>/moduleSystem/descriptorCreators.js',
               '<%= dirs.source %>/moduleSystem/settings.js',
               '<%= dirs.source %>/moduleSystem/modules/moduleLoader.js',
               '<%= dirs.source %>/moduleSystem/modules/moduleBuilder.js',
               '<%= dirs.source %>/moduleSystem/modules/loadedModulesContainer.js',
               '<%= dirs.source %>/moduleSystem/modules/modules.js',
               '<%= dirs.source %>/moduleSystem/modules/domEventListener.js',
               '<%= dirs.source %>/moduleSystem/parts/partBuilder.js',
               '<%= dirs.source %>/moduleSystem/parts/parts.js',
               '<%= dirs.source %>/eventBus/eventBus.js',
               '<%= dirs.source %>/moduleSystem/moduleSystem.js']
      },
      concat: {
         options: {
            banner: '<%= meta.banner %>'
         },
         dist: {
            src: [
               '<%= dirs.source %>/intro.js',
               '<%= files.src %>',
               '<%= dirs.source %>/outro.js'
            ],
            dest: '<%= dirs.dest %>/<%= pkg.name %>.<%= pkg.version %>.js'
         }
      },
      bower: {
         install: {},
         options: {
            copy: false
         }
      },
      uglify: {
         options: {
            banner: '<%= meta.banner %>'
         },
         dist: {
            src: ['<%= concat.dist.dest %>'],
            dest: '<%= dirs.dest %>/<%= pkg.name %>.<%= pkg.version %>.min.js'
         }
      },
      jshint: {
         files: ['<%= dirs.source %>/**/*.js'],
         options: {
            jshintrc: true
         }
      },
      jasmine: {
         options: {
            vendor: [
               '<%= dirs.dep %>/jquery/dist/jquery.js',
               '<%= dirs.dep %>/jasmine-jsreporter-real/jasmine-jsreporter.js',
               '<%= dirs.dep %>/jasmine-jquery/lib/jasmine-jquery.js'
            ],
            helpers: ['<%= dirs.test %>/helpers/**/*.js'],
            specs: [
               '<%= dirs.test %>/specs/**/*Spec.js'
            ]
         },
         test: {
            src: '<%= files.src %>',
            options: '<%= jasmine.options %>'
         },
         coverage: {
            src: '<%= jasmine.test.src %>',
            options: {
               vendor: [
                  '<%= dirs.dep %>/jquery/dist/jquery.js',
                  '<%= dirs.dep %>/jasmine-jsreporter-real/jasmine-jsreporter.js',
                  '<%= dirs.dep %>/jasmine-jquery/lib/jasmine-jquery.js'
               ],
               helpers: ['<%= dirs.test %>/helpers/**/*.js'],
               specs: [
                  '<%= dirs.test %>/specs/**/*Spec.js'
               ],
               template : require('grunt-template-jasmine-istanbul'),
			      templateOptions: {
                  coverage: 'reports/coverage.json',
                  report: [
						   {
							   type: 'html',
							   options: {
								   dir: 'reports/html'
							   }
						   },
						   {
							   type: 'lcov',
							   options: {
								   dir: 'reports/lcov'
							   }
						   },
					   ]
				   }
            }
         },
         prod: {
            src: '<%= concat.dist.dest %>',
            options: '<%= jasmine.options %>'
         },
         prodMin: {
            src: '<%= uglify.dist.dest %>',
            options: '<%= jasmine.options %>'
         }
      },
      coveralls: {
         options: {
            force: true
         },
         run: {
            src: 'reports/lcov/lcov.info'
         }
      },
      copy: {
         release: {
            src: '<%= concat.dist.dest %>',
            dest: '<%= dirs.dest %>/<%= pkg.name %>.js'
         },
         releaseMin: {
            src: '<%= uglify.dist.dest %>',
            dest: '<%= dirs.dest %>/<%= pkg.name %>.min.js'
         }
      },
      'saucelabs-jasmine': {
         all: {
            options: {
               username: SAUCE_USERNAME,
               key: SAUCE_ACCESS_KEY,
               urls: ['http://127.0.0.1:<%= connect.server.options.port %>/_SpecRunner.html'],
               build: (process.env.TRAVIS_BUILD_NUMBER) ? process.env.TRAVIS_BUILD_NUMBER : undefined,
               testname: (process.env.TRAVIS_BRANCH) ? process.env.TRAVIS_BRANCH : 'manual test',
               browsers: [{
                  browserName: 'chrome'
               }, {
                  browserName: 'firefox',
                  platform: 'linux'
               }, {
                  browserName: 'safari',
                  version: '8'
               }, {
                  browserName: 'safari',
                  version: '7'
               }, {
                  browserName: 'safari',
                  version: '6'
               }, {
                  browserName: 'safari',
                  version: '5'
               }, {
                  browserName: 'internet explorer',
                  version: '11'
               }, {
                  browserName: 'internet explorer',
                  version: '10'
               }, {
                  browserName: 'internet explorer',
                  version: '9'
               }, {
                  browserName: 'internet explorer',
                  version: '8'
               }]
            }
         }
      },
      connect: {
         server: {
            options: {
               port: '8080',
               base: '.'
            }
         }
      }

   });

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

   // Build task.
   grunt.registerTask('build', ['bower', 'jshint', 'test', 'concat', 'uglify', 'testProd', 'copy']);

   var testJobs = ['jasmine:coverage'];
   if (SAUCE_ACCESS_KEY && SAUCE_USERNAME) {
      testJobs.push('sauce');
   }

   grunt.registerTask('test', testJobs);

   grunt.registerTask('testProd', ['jasmine:prod', 'jasmine:prodMin']);

   grunt.registerTask('sauce', ['createSpecRunner', 'connect', 'saucelabs-jasmine']);

   grunt.registerTask('createSpecRunner', [
      'jasmine:test:build'
   ]);

   function setSauceLabsKeys() {
      if(process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
         SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY;
         SAUCE_USERNAME = process.env.SAUCE_USERNAME;
      } else if(process.env.TRAVIS_BRANCH === 'master' &&
                process.env.SAUCE_USERNAME_MASTER && process.env.SAUCE_ACCESS_KEY_MASTER) {
         SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY_MASTER;
         SAUCE_USERNAME = process.env.SAUCE_USERNAME_MASTER;
      } else if(process.env.SAUCE_USERNAME_DEVELOP && process.env.SAUCE_ACCESS_KEY_DEVELOP) {
         SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY_DEVELOP;
         SAUCE_USERNAME = process.env.SAUCE_USERNAME_DEVELOP;
      }

   }
};
<|endoftext|>


<commit_before>(function (global, Explorer3d) {
   // Keep all the DOM stuff together. Make the abstraction to the HTML here
   var dom = {
      verticalExageration: document.getElementById("exagerate"),
      selfDestruct: document.getElementById("selfDestruct"),
      labelSwitch: document.getElementById("labelSwitch"),
      objectsList: document.getElementById("objectsList"),
      fileDrop: document.getElementById("fileDrop"),
      target: document.getElementById("target"),
      projection: {
         get from() {
            return document.getElementById("projectFrom").value;
         },
         get to() {
            return document.getElementById("projectTo").value;
         }
      }
   };

   // Grab ourselves a world factory
   var factory = new Explorer3d.DefaultWorldFactory(dom.target);

   // Where are my workers? Just above here in this case. We have mapped the dependency in /dist. It's base is relative to the HTML page.
   Explorer3d.Parser.workerBase = "../dist/workers/";

   // You could lazy load these. I nearly did. I would if it was part of a bigger app.
   let geojsonParser = new Explorer3d.GeoJsonParser(),
      // Read files at 1 MB per read.
      gocadParser = new Explorer3d.GocadPusherParser();

   // Proxy the parser(s) and throttle the threads.  You can bypass this for unbounded threads.
   // Depending how many cores you have will determine actual usage. With 8 cores the bottle nec
   gocadParser = new Explorer3d.ThrottleProxyParser(gocadParser,  3);

   // Use this one for local testing
   // gocadParser = new Explorer3d.LocalGocadPusherParser()

   // Add a listener to the file drop area.
   let fileDrop = new Explorer3d.FileDrop(dom.fileDrop, function handler(file) {
      // See if we set projections
      let options = {
         from: dom.projection.from,
         to:   dom.projection.to,
         blockSize: 1024 * 1024
      };

      let promise;
      // Arbitrate the type by extension
      if (file.name.indexOf(".json") > 0) {
         promise = geojsonParser.parse({ file: file, options: options });
      } else {
         promise = gocadParser.parse({ file: file, options: options });
      }

      // Off to the parser to do its best
      promise.then(document => {
         // We got back a document so transform and show.
         var response = factory.show(Explorer3d.Transformer.transform(document));
      });
   });

   /**
    * Some UI to keep the users happy
    */

   // We'll attach something to change vertical exageration now.
   let verticalExagerate = new Explorer3d.VerticalExagerate(factory).onChange(() => {
      verticalExagerate.set(+dom.verticalExageration.value);
   });
   dom.verticalExageration.addEventListener("change", () => {
      verticalExagerate.set(+dom.verticalExageration.value);
   });

   // Wire in the ability to turn labels on and off.
   var labelSwitch = new Explorer3d.LabelSwitch(factory).onChange(() => {
      labelSwitch.set(dom.labelSwitch.checked);
   });
   dom.labelSwitch.addEventListener("change", () => {
      labelSwitch.set(dom.labelSwitch.checked);
   });

   // Get a handle on children each time it changes.
   factory.addEventListener("objects.changed", (event) => {
      let count = 1;
      let target = dom.objectsList;
      target.innerHTML = "";
      target.className = "";

      // sort by center z value
      event.objects.sort((a, b) => {
         a.geometry.computeBoundingSphere();
         b.geometry.computeBoundingSphere();
         return b.geometry.boundingSphere.center.z - a.geometry.boundingSphere.center.z
      }).forEach(obj => {
         let template = document.createElement("div");
         template.className = "layer";
         let color = obj.material.color.getStyle();
         color = color ? color : "lightgray"
         template.style.backgroundColor = color;

         let button = document.createElement("button");
         let x = document.createTextNode("X");

         let span = document.createElement("span");
         span.className = "layerspan";

         let name = obj.userData.header && obj.userData.header.name ? obj.userData.header.name : ("Unknown #" + count++);
         let text = document.createTextNode(name);
         let inp = document.createElement("input");
         inp.type = "checkbox"
         inp.checked = obj.visible;
         inp.onchange = function(ev) {
            obj.visible = ev.target.checked;
         };

         button.appendChild(x);
         button.className = "crossButton";
         button.onclick = function(event) {
            factory.remove(obj);
         }

         span.appendChild(inp);
         span.appendChild(text);

         template.appendChild(span);
         template.appendChild(button);
         target.appendChild(template);
         target.className = "active";
      });
   });

   // Pretty simple. Get the factory to reset.
   dom.selfDestruct.addEventListener("click", (event) => {
      factory.destroy();
   });
})(window, Explorer3d)<commit_msg>Better doco around API usage<commit_after>(function (global, Explorer3d) {
   /*
    * Set up some settings. Just configuration and data.
    */
   var appOptions = {
      workerCount: 7,
      browser: "modern",
      blockSize: 16 * 1024,
      hasWebGl: webgl()
   };

   var refData = {
      preWebGlMessage: "Your browser is not capable of rendering 3D.\n" +
         "Try a newer browser like the latest Firefox, Edge or Chrome\n" +
         "from Mozilla, Microsoft or Google respectively.",
      ie11Warning: "Your browser is a bit old to handle big files.\n" +
         "The latest Firefox or Edge is the best for large files.\n" +
         "Chrome is OK but struggles earlier than Firefox or Edge."
   };

   if(navigator.userAgent && navigator.userAgent.indexOf("Trident/") > 0) {
      appOptions.browser = "ie11";
      appOptions.blockSize = 2 * 1024 * 1024; // IE11 struggles with big files.
      appOptions.fileSizeLimit = 20 * appOptions.blockSize; // IE11 struggles with memory allocation.
   }

   // Keep all the DOM stuff together. Make the abstraction to the HTML here
   var dom = {
      verticalExageration: document.getElementById("exagerate"),
      selfDestruct: document.getElementById("selfDestruct"),
      labelSwitch: document.getElementById("labelSwitch"),
      objectsList: document.getElementById("objectsList"),
      fileDrop: document.getElementById("fileDrop"),
      target: document.getElementById("target"),
      projection: {
         get from() {
            return document.getElementById("projectFrom").value;
         },
         get to() {
            return document.getElementById("projectTo").value;
         }
      }
   };

/******************************************************************
 * Here is the calling of the API.
 ****************************************************************** */

   // Grab ourselves a world factory
   var factory = new Explorer3d.DefaultWorldFactory(dom.target);

   // Where are my workers? Just above here in this case. We have mapped the dependency in /dist. It's base is relative to the HTML page.
   Explorer3d.Parser.codeBase = "../dist";

   // You could lazy load these. I nearly did. I would if it was part of a bigger app.
   let gocadParser = new Explorer3d.GocadPusherParser(appOptions);

   // Proxy the parser(s) and throttle the threads.  You can bypass this for unbounded threads.
   // Depending how many cores you have will determine actual usage. With 8 cores the bottle neck will be
   // the UI thread. That would be 7 threads funneling into 1.
   gocadParser = new Explorer3d.ThrottleProxyParser(gocadParser, appOptions.workerCount);

   // Use this one for local testing. It's much slower but its easier to debug locally rather than in a web worker.
   // gocadParser = new Explorer3d.LocalGocadPusherParser(appOptions)

   // Add a listener to the file drop area.
   let fileDrop = new Explorer3d.FileDrop(dom.fileDrop, function handler(file) {
      // What are they even trying for? No dinosaurs allowed.
      if (!appOptions.hasWebGl) {
         alert(preWebGlMessage);
         return;
      }

      if(appOptions.fileSizeLimit) {
         // While size isn't standard the only browsers we care about have it.
         if(file.size && file.size > appOptions.fileSizeLimit) {
            alert(ie11Warning);
            return;
         }
      }
      // See if we set projections
      let options = {
         from: dom.projection.from,
         to:   dom.projection.to,
         blockSize: 1024 * 1024
      };
      Object.assign(options, appOptions);

      let promise = gocadParser.parse({ file: file, options: options });

      // Off to the parser to do its best
      console.log(seconds() + ": We have started the process.");
      promise.then(function(data) {
         if (data.eventName) {
            console.log(data);
         } else {
            // We got back a document so transform and show.
            var response = factory.show(data);
            console.log(seconds() + ": We have shown the document");
         }
      }).catch(function(err) {
         console.error("We failed in the simple example");
         console.error(err);
      });
   });

/********************************************************
 * End of calling the API. Now the UI.
 * This is just plain old HTML with no framework.
 * There are some UI helper calls provided by the API.
 ******************************************************** */

   /**
    * Some UI to keep the users happy
    */

   // We'll attach something to change vertical exageration now.
   let verticalExagerate = new Explorer3d.VerticalExagerate(factory).onChange(function() {
      console.log("We have a trigger to vertical exagerate");
      verticalExagerate.set(+dom.verticalExageration.value);
   });
   dom.verticalExageration.addEventListener("change", function() {
      verticalExagerate.set(+dom.verticalExageration.value);
   });

   // Wire in the ability to turn labels on and off.
   var labelSwitch = new Explorer3d.LabelSwitch(factory).onChange(function() {
      labelSwitch.set(dom.labelSwitch.checked);
   });
   dom.labelSwitch.addEventListener("change", function() {
      labelSwitch.set(dom.labelSwitch.checked);
   });

   // Get a handle on children each time it changes.
   factory.addEventListener("objects.changed", function(event) {
      let count = 1;
      let target = dom.objectsList;
      target.innerHTML = "";
      target.className = "";

      // sort by center z value
      event.objects.sort(function(a, b) {
         if (!a.geometry.boundingSphere) a.geometry.computeBoundingSphere();
         if (!b.geometry.boundingSphere) b.geometry.computeBoundingSphere();
         return b.geometry.boundingSphere.center.z - a.geometry.boundingSphere.center.z
      }).forEach(function(obj) {
         let template = document.createElement("div");
         template.className = "layer";
         let color = obj.material.color.getStyle();
         color = color ? color : "lightgray"
         template.style.backgroundColor = color;

         let button = document.createElement("button");
         let x = document.createTextNode("X");

         let span = document.createElement("span");
         span.className = "layerspan";

         let name = obj.userData.header && obj.userData.header.name ? obj.userData.header.name : ("Unknown #" + count++);
         let text = document.createTextNode(name);
         let inp = document.createElement("input");
         inp.type = "checkbox"
         inp.checked = obj.visible;
         inp.onchange = function(ev) {
            obj.visible = ev.target.checked;
         };

         button.appendChild(x);
         button.className = "crossButton";
         button.onclick = function(event) {
            factory.remove(obj);
         }

         span.appendChild(inp);
         span.appendChild(text);

         template.appendChild(span);
         template.appendChild(button);
         target.appendChild(template);
         target.className = "active";
      });
   });

   // Pretty simple. Get the factory to reset.
   dom.selfDestruct.addEventListener("click", function(event) {
      factory.destroy();
   });

   function seconds() {
      return (Date.now() % 100000) / 1000;
   }

   function webgl() {
		try {
			var canvas = document.createElement( 'canvas' );
         return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
		} catch ( e ) {
			return false;
		}
   }
})(window, Explorer3d)<|endoftext|>


<commit_before>import React, { Component } from 'react'
import { Carousel, Well } from 'react-bootstrap'

import design1 from './Noah-Fagan-portfolio-oct-14-4.jpg'
import design2 from './Noah-Fagan-portfolio-oct-14-5.jpg'
import design3 from './Noah-Fagan-portfolio-oct-14-6.jpg'
import design4 from './Noah-Fagan-portfolio-oct-14-7.jpg'

class OurDesigns extends Component {
  render () {
    return (
      <Well>

Our Designs

        <Carousel>
          <Carousel.Item>

          </Carousel.Item>
          <Carousel.Item>

          </Carousel.Item>
          <Carousel.Item>

          </Carousel.Item>
          <Carousel.Item>

          </Carousel.Item>
        </Carousel>
      </Well>
    )
  }
}

export default OurDesigns
<commit_msg>Update our designs section text<commit_after>import React, { Component } from 'react'
import { Carousel, Well } from 'react-bootstrap'

import design1 from './Noah-Fagan-portfolio-oct-14-4.jpg'
import design2 from './Noah-Fagan-portfolio-oct-14-5.jpg'
import design3 from './Noah-Fagan-portfolio-oct-14-6.jpg'
import design4 from './Noah-Fagan-portfolio-oct-14-7.jpg'

class OurDesigns extends Component {
  render () {
    return (
      <Well>

Our Designs

          Wouldn’t it be cool if we could show you floor plans of your ideal home? We’re working on it, but until then why not check out some of our standard designs.

        <Carousel>
          <Carousel.Item>

          </Carousel.Item>
          <Carousel.Item>

          </Carousel.Item>
          <Carousel.Item>

          </Carousel.Item>
          <Carousel.Item>

          </Carousel.Item>
        </Carousel>
      </Well>
    )
  }
}

export default OurDesigns
<|endoftext|>


<commit_before>/*!
 * Bootstrap's Gruntfile
 * http://getbootstrap.com
 * Copyright 2013-2014 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */

module.exports = function (grunt) {
  'use strict';

  // Force use of Unix newlines
  grunt.util.linefeed = '\n';

  RegExp.quote = function (string) {
    return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
  };

  var fs = require('fs');
  var path = require('path');
  var BsLessdocParser = require('./grunt/bs-lessdoc-parser.js');
  var getLessVarsData = function () {
    var filePath = path.join(__dirname, 'less/variables.less');
    var fileContent = fs.readFileSync(filePath, { encoding: 'utf8' });
    var parser = new BsLessdocParser(fileContent);
    return { sections: parser.parseFile() };
  };
  var generateRawFiles = require('./grunt/bs-raw-files-generator.js');
  // var generateCommonJSModule = require('./grunt/bs-commonjs-generator.js');
  var configBridge = grunt.file.readJSON('./grunt/configBridge.json', { encoding: 'utf8' });

  Object.keys(configBridge.paths).forEach(function (key) {
    configBridge.paths[key].forEach(function (val, i, arr) {
      arr[i] = path.join('./docs/assets', val);
    });
  });

  // Project configuration.
  grunt.initConfig({

    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*!\n' +
            ' * TODC Bootstrap v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
            ' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
            ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
            ' */\n',
    jqueryCheck: configBridge.config.jqueryCheck.join('\n'),
    jqueryVersionCheck: configBridge.config.jqueryVersionCheck.join('\n'),

    // Bootstrap variables
    bootstrapDir: 'bootstrap',
    bootstrapGit: 'https://github.com/twbs/bootstrap.git',
    bootstrapVersion: 'v3.3.1',

    // Task configuration.
    clean: {
      dist: 'dist',
      docs: 'docs/dist'
    },

    jshint: {
      options: {
        jshintrc: 'js/.jshintrc'
      },
      grunt: {
        options: {
          jshintrc: 'grunt/.jshintrc'
        },
        src: ['Gruntfile.js', 'grunt/*.js']
      },
      assets: {
        src: ['docs/assets/js/src/*.js', 'docs/assets/js/*.js', '!docs/assets/js/*.min.js']
      }
    },

    jscs: {
      options: {
        config: 'js/.jscsrc'
      },
      grunt: {
        src: '<%= jshint.grunt.src %>'
      },
      assets: {
        options: {
          requireCamelCaseOrUpperCaseIdentifiers: null
        },
        src: '<%= jshint.assets.src %>'
      }
    },

    uglify: {
      options: {
        preserveComments: 'some'
      },
      core: {
      },
      customize: {
      },
      docsJs: {
        src: configBridge.paths.docsJs,
        dest: 'docs/assets/js/docs.min.js'
      }
    },

    less: {
      compileCore: {
        options: {
          strictMath: true,
          sourceMap: true,
          outputSourceFiles: true,
          sourceMapURL: '<%= pkg.name %>.css.map',
          sourceMapFilename: 'dist/css/<%= pkg.name %>.css.map'
        },
        src: 'less/todc-bootstrap.less',
        dest: 'dist/css/<%= pkg.name %>.css'
      }
    },

    autoprefixer: {
      options: {
        browsers: configBridge.config.autoprefixerBrowsers
      },
      core: {
        options: {
          map: true
        },
        src: 'dist/css/<%= pkg.name %>.css'
      },
      docs: {
        src: 'docs/assets/css/src/docs.css'
      },
      examples: {
        expand: true,
        cwd: 'docs/examples/',
        src: '**/*.css',
        dest: 'docs/examples/'
      }
    },

    csslint: {
      options: {
        csslintrc: 'less/.csslintrc'
      },
      dist: [
        'dist/css/todc-bootstrap.css'
      ],
      examples: [
        'docs/examples/**/*.css'
      ],
      docs: {
        options: {
          ids: false,
          'overqualified-elements': false
        },
        src: 'docs/assets/css/src/docs.css'
      }
    },

    cssmin: {
      options: {
        compatibility: 'ie8',
        keepSpecialComments: '*',
        noAdvanced: true

      },
      minifyCore: {
        src: 'dist/css/<%= pkg.name %>.css',
        dest: 'dist/css/<%= pkg.name %>.min.css'
      },
      docs: {
        src: [
          'docs/assets/css/src/docs.css',
          'docs/assets/css/src/pygments-manni.css',
          'docs/assets/css/src/select2.css'
        ],
        dest: 'docs/assets/css/docs.min.css'
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= banner %>'
      },
      files: {
        src: 'dist/css/*.css'
      }
    },

    csscomb: {
      options: {
        config: 'less/.csscomb.json'
      },
      dist: {
        expand: true,
        cwd: 'dist/css/',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/css/'
      },
      examples: {
        expand: true,
        cwd: 'docs/examples/',
        src: '**/*.css',
        dest: 'docs/examples/'
      },
      docs: {
        src: 'docs/assets/css/src/docs.css',
        dest: 'docs/assets/css/src/docs.css'
      }
    },

    copy: {
      bootstrap: {
        expand: true,
        flatten: false,
        cwd: '<%= bootstrapDir %>/dist',
        src: '*/*',
        dest: 'dist'
      },
      images: {
        src: 'img/*',
        dest: 'dist/'
      },
      docs: {
        src: 'dist/*/*',
        dest: 'docs/'
      }
    },

    compress: {
      main: {
        options: {
          archive: 'dist/<%= pkg.name %>-<%= pkg.version %>-dist.zip',
          mode: 'zip',
          pretty: true
        },
        expand: true,
        cwd: 'dist',
        src: '**',
        dest: 'todc-bootstrap/'
      }
    },

    jekyll: {
      options: {
        config: '_config.yml'
      },
      docs: {},
      github: {
        options: {
          raw: 'github: true'
        }
      }
    },

    jade: {
      options: {
        pretty: true,
        data: getLessVarsData
      },
      customizerVars: {
        src: 'docs/_jade/customizer-variables.jade',
        dest: 'docs/_includes/customizer-variables.html'
      },
      customizerNav: {
        src: 'docs/_jade/customizer-nav.jade',
        dest: 'docs/_includes/nav/customize.html'
      }
    },

    validation: {
      options: {
        charset: 'utf-8',
        doctype: 'HTML5',
        failHard: true,
        reset: true,
        relaxerror: [
          'Element img is missing required attribute src.',
          'Attribute autocomplete not allowed on element input at this point.',
          'Attribute autocomplete not allowed on element button at this point.',
          'Bad value separator for attribute role on element li.'
        ]
      },
      files: {
        src: '_gh_pages/**/*.html'
      }
    },

    watch: {
      less: {
        files: 'less/**/*.less',
        tasks: 'less'
      }
    },

    // checkout-bootstrap task
    shell: {
      gitclone: {
        command: 'git clone <%= bootstrapGit %> <%= bootstrapDir %>'
      },
      gitcheckout: {
        command: 'git checkout tags/<%= bootstrapVersion %>',
        options: {
          execOptions: {
            cwd: '<%= bootstrapDir %>'
          }
        }
      }
    },

    sed: {
      versionNumber: {
        pattern: (function () {
          var old = grunt.option('oldver');
          return old ? RegExp.quote(old) : old;
        })(),
        replacement: grunt.option('newver'),
        recursive: true
      }
    }
  });

  // These plugins provide necessary tasks.
  require('load-grunt-tasks')(grunt, { scope: 'devDependencies' });
  require('time-grunt')(grunt);

  // Clone bootstrap and checkout the appropriate tag task.
  grunt.registerTask('checkout-bootstrap', 'shell');

  // Docs HTML validation task
  grunt.registerTask('validate-html', ['jekyll:docs', 'validation']);

  var runSubset = function (subset) {
    return !process.env.TWBS_TEST || process.env.TWBS_TEST === subset;
  };
  var isUndefOrNonZero = function (val) {
    return val === undefined || val !== '0';
  };

  // Test task.
  var testSubtasks = [];
  // Skip core tests if running a different subset of the test suite
  if (runSubset('core')) {
     testSubtasks = testSubtasks.concat(['dist-css', 'dist-js', 'csslint:dist', 'test-js', 'docs']);
  }
  // Skip HTML validation if running a different subset of the test suite
  if (runSubset('validate-html') &&
      // Skip HTML5 validator on Travis when [skip validator] is in the commit message
      isUndefOrNonZero(process.env.TWBS_DO_VALIDATOR)) {
    testSubtasks.push('validate-html');
  }
  grunt.registerTask('test', testSubtasks);
  grunt.registerTask('test-js', ['jshint:grunt', 'jscs:grunt']);

  // JS distribution task.
  grunt.registerTask('dist-js', 'uglify:core');

  // CSS distribution task.
  grunt.registerTask('less-compile', ['less:compileCore']);
  grunt.registerTask('dist-css', ['less-compile', 'autoprefixer:core', 'usebanner', 'csscomb:dist', 'cssmin:minifyCore']);

  // Full distribution task.
  grunt.registerTask('dist', ['clean:dist', 'dist-css', 'copy:bootstrap', 'copy:images', 'dist-js']);

  // Default task.
  grunt.registerTask('default', ['clean:dist', 'copy:bootstrap', 'copy:images', 'test']);

  // Version numbering task.
  // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
  // This can be overzealous, so its changes should always be manually reviewed!
  grunt.registerTask('change-version-number', 'sed');

  // task for building customizer
  grunt.registerTask('build-customizer', ['build-customizer-html', 'build-raw-files']);
  grunt.registerTask('build-customizer-html', 'jade');
  grunt.registerTask('build-raw-files', 'Add scripts/less files to customizer.', function () {
    var banner = grunt.template.process('<%= banner %>');
    generateRawFiles(grunt, banner);
  });

  // Docs task.
  grunt.registerTask('docs-css', ['autoprefixer:docs', 'autoprefixer:examples', 'csscomb:docs', 'csscomb:examples', 'cssmin:docs']);
  grunt.registerTask('lint-docs-css', ['csslint:docs', 'csslint:examples']);
  grunt.registerTask('docs-js', ['uglify:docsJs']);
  grunt.registerTask('lint-docs-js', ['jshint:assets', 'jscs:assets']);
  grunt.registerTask('docs', ['docs-css', 'lint-docs-css', 'docs-js', 'lint-docs-js', 'clean:docs', 'copy:docs']);

  grunt.registerTask('docs-github', ['jekyll:github']);
};
<commit_msg>Add grunt-contrib-compress.<commit_after>/*!
 * Bootstrap's Gruntfile
 * http://getbootstrap.com
 * Copyright 2013-2014 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */

module.exports = function (grunt) {
  'use strict';

  // Force use of Unix newlines
  grunt.util.linefeed = '\n';

  RegExp.quote = function (string) {
    return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
  };

  var fs = require('fs');
  var path = require('path');
  var BsLessdocParser = require('./grunt/bs-lessdoc-parser.js');
  var getLessVarsData = function () {
    var filePath = path.join(__dirname, 'less/variables.less');
    var fileContent = fs.readFileSync(filePath, { encoding: 'utf8' });
    var parser = new BsLessdocParser(fileContent);
    return { sections: parser.parseFile() };
  };
  var generateRawFiles = require('./grunt/bs-raw-files-generator.js');
  // var generateCommonJSModule = require('./grunt/bs-commonjs-generator.js');
  var configBridge = grunt.file.readJSON('./grunt/configBridge.json', { encoding: 'utf8' });

  Object.keys(configBridge.paths).forEach(function (key) {
    configBridge.paths[key].forEach(function (val, i, arr) {
      arr[i] = path.join('./docs/assets', val);
    });
  });

  // Project configuration.
  grunt.initConfig({

    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*!\n' +
            ' * TODC Bootstrap v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
            ' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
            ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
            ' */\n',
    jqueryCheck: configBridge.config.jqueryCheck.join('\n'),
    jqueryVersionCheck: configBridge.config.jqueryVersionCheck.join('\n'),

    // Bootstrap variables
    bootstrapDir: 'bootstrap',
    bootstrapGit: 'https://github.com/twbs/bootstrap.git',
    bootstrapVersion: 'v3.3.1',

    // Task configuration.
    clean: {
      dist: 'dist',
      docs: 'docs/dist'
    },

    jshint: {
      options: {
        jshintrc: 'js/.jshintrc'
      },
      grunt: {
        options: {
          jshintrc: 'grunt/.jshintrc'
        },
        src: ['Gruntfile.js', 'grunt/*.js']
      },
      assets: {
        src: ['docs/assets/js/src/*.js', 'docs/assets/js/*.js', '!docs/assets/js/*.min.js']
      }
    },

    jscs: {
      options: {
        config: 'js/.jscsrc'
      },
      grunt: {
        src: '<%= jshint.grunt.src %>'
      },
      assets: {
        options: {
          requireCamelCaseOrUpperCaseIdentifiers: null
        },
        src: '<%= jshint.assets.src %>'
      }
    },

    uglify: {
      options: {
        preserveComments: 'some'
      },
      core: {
      },
      customize: {
      },
      docsJs: {
        src: configBridge.paths.docsJs,
        dest: 'docs/assets/js/docs.min.js'
      }
    },

    less: {
      compileCore: {
        options: {
          strictMath: true,
          sourceMap: true,
          outputSourceFiles: true,
          sourceMapURL: '<%= pkg.name %>.css.map',
          sourceMapFilename: 'dist/css/<%= pkg.name %>.css.map'
        },
        src: 'less/todc-bootstrap.less',
        dest: 'dist/css/<%= pkg.name %>.css'
      }
    },

    autoprefixer: {
      options: {
        browsers: configBridge.config.autoprefixerBrowsers
      },
      core: {
        options: {
          map: true
        },
        src: 'dist/css/<%= pkg.name %>.css'
      },
      docs: {
        src: 'docs/assets/css/src/docs.css'
      },
      examples: {
        expand: true,
        cwd: 'docs/examples/',
        src: '**/*.css',
        dest: 'docs/examples/'
      }
    },

    csslint: {
      options: {
        csslintrc: 'less/.csslintrc'
      },
      dist: [
        'dist/css/todc-bootstrap.css'
      ],
      examples: [
        'docs/examples/**/*.css'
      ],
      docs: {
        options: {
          ids: false,
          'overqualified-elements': false
        },
        src: 'docs/assets/css/src/docs.css'
      }
    },

    cssmin: {
      options: {
        compatibility: 'ie8',
        keepSpecialComments: '*',
        noAdvanced: true

      },
      minifyCore: {
        src: 'dist/css/<%= pkg.name %>.css',
        dest: 'dist/css/<%= pkg.name %>.min.css'
      },
      docs: {
        src: [
          'docs/assets/css/src/docs.css',
          'docs/assets/css/src/pygments-manni.css',
          'docs/assets/css/src/select2.css'
        ],
        dest: 'docs/assets/css/docs.min.css'
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= banner %>'
      },
      files: {
        src: 'dist/css/*.css'
      }
    },

    csscomb: {
      options: {
        config: 'less/.csscomb.json'
      },
      dist: {
        expand: true,
        cwd: 'dist/css/',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/css/'
      },
      examples: {
        expand: true,
        cwd: 'docs/examples/',
        src: '**/*.css',
        dest: 'docs/examples/'
      },
      docs: {
        src: 'docs/assets/css/src/docs.css',
        dest: 'docs/assets/css/src/docs.css'
      }
    },

    copy: {
      bootstrap: {
        expand: true,
        flatten: false,
        cwd: '<%= bootstrapDir %>/dist',
        src: '*/*',
        dest: 'dist'
      },
      images: {
        src: 'img/*',
        dest: 'dist/'
      },
      docs: {
        src: 'dist/*/*',
        dest: 'docs/'
      }
    },

    jekyll: {
      options: {
        config: '_config.yml'
      },
      docs: {},
      github: {
        options: {
          raw: 'github: true'
        }
      }
    },

    jade: {
      options: {
        pretty: true,
        data: getLessVarsData
      },
      customizerVars: {
        src: 'docs/_jade/customizer-variables.jade',
        dest: 'docs/_includes/customizer-variables.html'
      },
      customizerNav: {
        src: 'docs/_jade/customizer-nav.jade',
        dest: 'docs/_includes/nav/customize.html'
      }
    },

    validation: {
      options: {
        charset: 'utf-8',
        doctype: 'HTML5',
        failHard: true,
        reset: true,
        relaxerror: [
          'Element img is missing required attribute src.',
          'Attribute autocomplete not allowed on element input at this point.',
          'Attribute autocomplete not allowed on element button at this point.',
          'Bad value separator for attribute role on element li.'
        ]
      },
      files: {
        src: '_gh_pages/**/*.html'
      }
    },

    watch: {
      less: {
        files: 'less/**/*.less',
        tasks: 'less'
      }
    },

    // checkout-bootstrap task
    shell: {
      gitclone: {
        command: 'git clone <%= bootstrapGit %> <%= bootstrapDir %>'
      },
      gitcheckout: {
        command: 'git checkout tags/<%= bootstrapVersion %>',
        options: {
          execOptions: {
            cwd: '<%= bootstrapDir %>'
          }
        }
      }
    },

    sed: {
      versionNumber: {
        pattern: (function () {
          var old = grunt.option('oldver');
          return old ? RegExp.quote(old) : old;
        })(),
        replacement: grunt.option('newver'),
        recursive: true
      }
    },

    compress: {
      main: {
        options: {
          archive: '<%= pkg.name %>-<%= pkg.version %>-dist.zip',
          mode: 'zip',
          level: 9,
          pretty: true
        },
        files: [
          {
            expand: true,
            cwd: 'dist/',
            src: ['**'],
            dest: '<%= pkg.name %>-<%= pkg.version %>-dist'
          }
        ]
      }
    }

  });

  // These plugins provide necessary tasks.
  require('load-grunt-tasks')(grunt, { scope: 'devDependencies' });
  require('time-grunt')(grunt);

  // Clone bootstrap and checkout the appropriate tag task.
  grunt.registerTask('checkout-bootstrap', 'shell');

  // Docs HTML validation task
  grunt.registerTask('validate-html', ['jekyll:docs', 'validation']);

  var runSubset = function (subset) {
    return !process.env.TWBS_TEST || process.env.TWBS_TEST === subset;
  };
  var isUndefOrNonZero = function (val) {
    return val === undefined || val !== '0';
  };

  // Test task.
  var testSubtasks = [];
  // Skip core tests if running a different subset of the test suite
  if (runSubset('core')) {
     testSubtasks = testSubtasks.concat(['dist-css', 'dist-js', 'csslint:dist', 'test-js', 'docs']);
  }
  // Skip HTML validation if running a different subset of the test suite
  if (runSubset('validate-html') &&
      // Skip HTML5 validator on Travis when [skip validator] is in the commit message
      isUndefOrNonZero(process.env.TWBS_DO_VALIDATOR)) {
    testSubtasks.push('validate-html');
  }
  grunt.registerTask('test', testSubtasks);
  grunt.registerTask('test-js', ['jshint:grunt', 'jscs:grunt']);

  // JS distribution task.
  grunt.registerTask('dist-js', 'uglify:core');

  // CSS distribution task.
  grunt.registerTask('less-compile', ['less:compileCore']);
  grunt.registerTask('dist-css', ['less-compile', 'autoprefixer:core', 'usebanner', 'csscomb:dist', 'cssmin:minifyCore']);

  // Full distribution task.
  grunt.registerTask('dist', ['clean:dist', 'dist-css', 'copy:bootstrap', 'copy:images', 'dist-js']);

  // Default task.
  grunt.registerTask('default', ['clean:dist', 'copy:bootstrap', 'copy:images', 'test']);

  // Version numbering task.
  // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
  // This can be overzealous, so its changes should always be manually reviewed!
  grunt.registerTask('change-version-number', 'sed');

  // task for building customizer
  grunt.registerTask('build-customizer', ['build-customizer-html', 'build-raw-files']);
  grunt.registerTask('build-customizer-html', 'jade');
  grunt.registerTask('build-raw-files', 'Add scripts/less files to customizer.', function () {
    var banner = grunt.template.process('<%= banner %>');
    generateRawFiles(grunt, banner);
  });

  // Docs task.
  grunt.registerTask('docs-css', ['autoprefixer:docs', 'autoprefixer:examples', 'csscomb:docs', 'csscomb:examples', 'cssmin:docs']);
  grunt.registerTask('lint-docs-css', ['csslint:docs', 'csslint:examples']);
  grunt.registerTask('docs-js', ['uglify:docsJs']);
  grunt.registerTask('lint-docs-js', ['jshint:assets', 'jscs:assets']);
  grunt.registerTask('docs', ['docs-css', 'lint-docs-css', 'docs-js', 'lint-docs-js', 'clean:docs', 'copy:docs']);

  grunt.registerTask('prep-release', ['jekyll:github', 'compress']);
};
<|endoftext|>