<commit_before>// Generated on 2013-07-26 using generator-webapp 0.2.6
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

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

module.exports = function (grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

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

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            coffee: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.coffee'],
                tasks: ['coffee:test']
            },
            compass: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server']
            },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        connect: {
            options: {
                port: 9000,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, yeomanConfig.dist)
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.app %>/scripts/{,*/}*.js',
                '!<%= yeoman.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://localhost:<%= connect.options.port %>/index.html']
                }
            }
        },
        coffee: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/scripts',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/scripts',
                    ext: '.js'
                }]
            },
            test: {
                files: [{
                    expand: true,
                    cwd: 'test/spec',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/spec',
                    ext: '.js'
                }]
            }
        },
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%= yeoman.app %>/images',
                javascriptsDir: '<%= yeoman.app %>/scripts',
                fontsDir: '<%= yeoman.app %>/styles/fonts',
                importPath: '<%= yeoman.app %>/bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false
            },
            dist: {},
            server: {
                options: {
                    debugInfo: true
                }
            }
        },
        // not used since Uglify task does concat,
        // but still available if needed
        /*concat: {
            dist: {}
        },*/
        // not enabled since usemin task does concat and uglify
        // check index.html to edit your build targets
        // enable this task if you prefer defining your build targets here
        /*uglify: {
            dist: {}
        },*/
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                        '<%= yeoman.dist %>/styles/fonts/*'
                    ]
                }
            }
        },
        useminPrepare: {
            options: {
                dest: '<%= yeoman.dist %>'
            },
            html: '<%= yeoman.app %>/index.html'
        },
        usemin: {
            options: {
                dirs: ['<%= yeoman.dist %>']
            },
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            // This task is pre-configured if you do not wish to use Usemin
            // blocks for your CSS. By default, the Usemin block from your
            // `index.html` will take care of minification, e.g.
            //
            //     <!-- build:css({.tmp,app}) styles/main.css -->
            //
            // dist: {
            //     files: {
            //         '<%= yeoman.dist %>/styles/main.css': [
            //             '.tmp/styles/{,*/}*.css',
            //             '<%= yeoman.app %>/styles/{,*/}*.css'
            //         ]
            //     }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: '*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.{webp,gif}',
                        'styles/fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*'
                    ]
                }]
            }
        },
        concurrent: {
            server: [
                'compass',
                'coffee:dist'
            ],
            test: [
                'coffee'
            ],
            dist: [
                'coffee',
                'compass',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        }
    });

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'connect:livereload',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'connect:test',
        'mocha'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'concat',
        'cssmin',
        'uglify',
        'copy:dist',
        'rev',
        'usemin'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
<commit_msg>Commented out Compass-related tasks.<commit_after>// Generated on 2013-07-26 using generator-webapp 0.2.6
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

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

module.exports = function (grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

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

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            coffee: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.coffee'],
                tasks: ['coffee:test']
            },
            // compass: {
            //     files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
            //     tasks: ['compass:server']
            // },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        connect: {
            options: {
                port: 9000,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, yeomanConfig.dist)
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.app %>/scripts/{,*/}*.js',
                '!<%= yeoman.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://localhost:<%= connect.options.port %>/index.html']
                }
            }
        },
        coffee: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/scripts',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/scripts',
                    ext: '.js'
                }]
            },
            test: {
                files: [{
                    expand: true,
                    cwd: 'test/spec',
                    src: '{,*/}*.coffee',
                    dest: '.tmp/spec',
                    ext: '.js'
                }]
            }
        },
        // compass: {
        //     options: {
        //         sassDir: '<%= yeoman.app %>/styles',
        //         cssDir: '.tmp/styles',
        //         generatedImagesDir: '.tmp/images/generated',
        //         imagesDir: '<%= yeoman.app %>/images',
        //         javascriptsDir: '<%= yeoman.app %>/scripts',
        //         fontsDir: '<%= yeoman.app %>/styles/fonts',
        //         importPath: '<%= yeoman.app %>/bower_components',
        //         httpImagesPath: '/images',
        //         httpGeneratedImagesPath: '/images/generated',
        //         httpFontsPath: '/styles/fonts',
        //         relativeAssets: false
        //     },
        //     dist: {},
        //     server: {
        //         options: {
        //             debugInfo: true
        //         }
        //     }
        // },
        // not used since Uglify task does concat,
        // but still available if needed
        /*concat: {
            dist: {}
        },*/
        // not enabled since usemin task does concat and uglify
        // check index.html to edit your build targets
        // enable this task if you prefer defining your build targets here
        /*uglify: {
            dist: {}
        },*/
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                        '<%= yeoman.dist %>/styles/fonts/*'
                    ]
                }
            }
        },
        useminPrepare: {
            options: {
                dest: '<%= yeoman.dist %>'
            },
            html: '<%= yeoman.app %>/index.html'
        },
        usemin: {
            options: {
                dirs: ['<%= yeoman.dist %>']
            },
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            // This task is pre-configured if you do not wish to use Usemin
            // blocks for your CSS. By default, the Usemin block from your
            // `index.html` will take care of minification, e.g.
            //
            //     <!-- build:css({.tmp,app}) styles/main.css -->
            //
            // dist: {
            //     files: {
            //         '<%= yeoman.dist %>/styles/main.css': [
            //             '.tmp/styles/{,*/}*.css',
            //             '<%= yeoman.app %>/styles/{,*/}*.css'
            //         ]
            //     }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: '*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.{webp,gif}',
                        'styles/fonts/*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*'
                    ]
                }]
            }
        },
        concurrent: {
            server: [
                // 'compass',
                'coffee:dist'
            ],
            test: [
                'coffee'
            ],
            dist: [
                'coffee',
                // 'compass',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        }
    });

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'connect:livereload',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'connect:test',
        'mocha'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'concat',
        'cssmin',
        'uglify',
        'copy:dist',
        'rev',
        'usemin'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
<|endoftext|>


<commit_before>(function(window, document) {
'use strict';

// Public API
window.containerQueries = {
	reprocess: reprocess,
	reparse: reparse,
	reevaluate: reevaluate,
};

// Reprocess now
setTimeout(reprocess);

window.addEventListener('DOMContentLoaded', reprocess);
window.addEventListener('load', reprocess);
window.addEventListener('resize', reevaluate);

var SELECTOR_REGEXP = /:container\(\s*(?:min|max)-(?:width|height)\s*:\s*[^)]+\s*\)/gi;
var SELECTOR_ESCAPED_REGEXP = /\.\\:container\\\(\s*((?:min|max)-(?:width|height))\s*\\:\s*([^)]+?)\s*\\\)/gi;
var ESCAPE_REGEXP = /[:()]/g;
var SPACE_REGEXP = / /g;
var LENGTH_REGEXP = /^-?(?:\d*\.)?\d+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc)$/i;
var ATTR_REGEXP = /\[.+?\]/g;
var PSEUDO_NOT_REGEXP = /:not\(/g;
var ID_REGEXP = /#[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var CLASS_REGEXP = /\.[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var PSEUDO_ELEMENT_REGEXP = /::[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var PSEUDO_CLASS_REGEXP = /:[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var ELEMENT_REGEXP = /[a-z-]+/gi;

var queries;
var containerCache;
var processed = false;
var parsed = false;

function reprocess() {
	preprocess(function() {
		processed = true;
		reparse();
	});
}
function reparse() {
	if (!processed) {
		return reprocess();
	}
	parseRules();
	parsed = true;
	reevaluate();
}
function reevaluate() {
	if (!parsed) {
		return reparse();
	}
	updateClasses();
}

function preprocess(callback) {
	var sheets = document.styleSheets;
	if (!sheets.length) {
		callback();
		return;
	}
	var done = 0;
	for (var i = 0, length = sheets.length; i < length; i++) {
		preprocessSheet(sheets[i], function() {
			done++;
			if (done === length) {
				callback();
			}
		});
	}
}

function preprocessSheet(sheet, callback) {
	if (sheet.disabled) {
		callback();
		return;
	}
	var tag = sheet.ownerNode && sheet.ownerNode.tagName;
	if (tag === 'LINK') {
		loadExternal(sheet.ownerNode.href, function(cssText) {
			// TODO: fix relative URLs, see https://github.com/LeaVerou/prefixfree/blob/765c6a1/prefixfree.js#L46
			preprocessStyle(sheet.ownerNode, cssText, callback);
		});
	}
	else if (tag === 'STYLE') {
		preprocessStyle(sheet.ownerNode, sheet.ownerNode.innerHTML, callback);
	}
	else {
		callback();
	}
}

function loadExternal(href, callback) {
	var xhr = new window.XMLHttpRequest();
	xhr.open('GET', href);
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}
		callback(xhr.status === 200 ? xhr.responseText : '');
	};
	xhr.send();
}

function preprocessStyle(node, cssText, callback) {
	var found = false;
	cssText = cssText.replace(SELECTOR_REGEXP, function(selector) {
		found = true;
		return '.' + selector.replace(SPACE_REGEXP, '').replace(ESCAPE_REGEXP, '\\$&');
	});
	if (!found) {
		callback();
		return;
	}
	var style = document.createElement('style');
	style.textContent = cssText;
	style.media = node.media;
	node.parentNode.insertBefore(style, node);
	node.disabled = true;
	callback();
}

function parseRules() {
	queries = {};
	var sheets = document.styleSheets;
	var rules;
	for (var i = 0; i < sheets.length; i++) {
		if (sheets[i].disabled) {
			continue;
		}
		try {
			rules = sheets[i].cssRules;
		}
		catch(e) {
			continue;
		}
		for (var j = 0; j < rules.length; j++) {
			parseRule(rules[j]);
		}
	}
}

function parseRule(rule) {
	if (rule.cssRules) {
		for (var i = 0; i < rule.cssRules.length; i++) {
			parseRule(rule.cssRules[i]);
		}
		return;
	}
	if (rule.type !== 1) {
		return;
	}
	splitSelectors(rule.selectorText).forEach(function(selector) {
		if (selector.search(SELECTOR_ESCAPED_REGEXP) !== -1) {
			selector.replace(SELECTOR_ESCAPED_REGEXP, function(match, type, value, offset) {
				var precedingSelector = selector.substr(0, offset);
				if (!precedingSelector.substr(-1).trim()) {
					precedingSelector += '*';
				}
				queries[precedingSelector + match.toLowerCase()] = {
					selector: precedingSelector,
					prop: type.split('-')[1].toLowerCase(),
					type: type.split('-')[0].toLowerCase(),
					value: value,
					className: match.toLowerCase().substr(1).replace(/\\(.)/g, '$1'),
				};
			})
		}
	});
}

function splitSelectors(selectors) {
	// TODO: Fix complex selectors like fo\,o[attr="val,u\"e"]
	return selectors.split(/\s*,\s*/);
}

function updateClasses() {
	containerCache = new Map();
	eachQuery(function(query) {
		var elements = document.querySelectorAll(query.selector);
		for (var i = 0; i < elements.length; i++) {
			updateClass(elements[i], query);
		}
	});
}

function updateClass(element, query) {
	var container = getContainer(element.parentNode, query.prop);
	var size = getSize(container, query.prop);
	var value = parseFloat(query.value);
	if (
		(query.type === 'min' && size >= value)
		|| (query.type === 'max' && size <= value)
	) {
		element.classList.add(query.className);
	}
	else {
		element.classList.remove(query.className);
	}
}

function getContainer(element, prop) {

	var cache;
	if (containerCache.has(element)) {
		cache = containerCache.get(element);
		if (cache.container[prop]) {
			return cache.container[prop];
		}
	}
	else {
		cache = {
			container: {},
		};
		containerCache.set(element, cache);
	}

	if (element === document.documentElement) {
		cache.container[prop] = element;
	}

	// Skip inline elements
	else if (window.getComputedStyle(element).display === 'inline') {
		cache.container[prop] = getContainer(element.parentNode, prop);
	}

	else if (isFixedSize(element, prop)) {
		cache.container[prop] = element;
	}

	else {
		var parentContainer = getContainer(element.parentNode, prop);
		var chain = [];
		for (var node = element; node !== parentContainer; node = node.parentNode) {
			// Skip inline elements
			if (window.getComputedStyle(node).display !== 'inline') {
				chain.unshift(node);
			}
		}
		for (var i = 0; i < chain.length; i++) {
			if (isIntrinsicSize(chain[i], prop)) {
				break;
			}
		}
		if (i) {
			cache.container[prop] = chain[i - 1];
		}
		else {
			cache.container[prop] = parentContainer;
		}
	}

	return cache.container[prop];

}

function isFixedSize(element, prop) {
	var originalStyle = getOriginalStyle(element, [prop]);
	if (originalStyle[prop] && originalStyle[prop].search(LENGTH_REGEXP) !== -1) {
		return true;
	}
}

function isIntrinsicSize(element, prop) {

	var computedStyle = window.getComputedStyle(element);

	if (computedStyle.display === 'none') {
		return false;
	}

	if (computedStyle.display === 'inline') {
		return true;
	}

	// Non-floating non-absolute block elements (only width)
	if (
		prop === 'width'
		&& ['block', 'list-item', 'flex', 'grid'].indexOf(computedStyle.display) !== -1
		&& computedStyle.float === 'none'
		&& computedStyle.position !== 'absolute'
		&& computedStyle.position !== 'fixed'
	) {
		return false;
	}

	var originalStyle = getOriginalStyle(element, [prop]);

	// Fixed size
	if (originalStyle[prop] && originalStyle[prop].search(LENGTH_REGEXP) !== -1) {
		return false;
	}

	// Percentage size
	if (originalStyle[prop] && originalStyle[prop].substr(-1) === '%') {
		return false;
	}

	// Elements without a defined size
	return true;

}

// TODO: Return the size of the content-box instead of the border-box
function getSize(element, prop) {
	if (prop === 'width') {
		return element.offsetWidth;
	}
	else if (prop === 'height') {
		return element.offsetHeight;
	}
	return 0;
}

function getOriginalStyle(element, props) {

	var matchedRules = [];
	var sheets = document.styleSheets;
	var rules;
	var result = {};
	var i, j;

	for (i = 0; i < sheets.length; i++) {
		if (sheets[i].disabled) {
			continue;
		}
		try {
			rules = sheets[i].cssRules;
		}
		catch(e) {
			continue;
		}
		matchedRules = matchedRules.concat(filterRulesByElementAndProps(rules, element, props));
	}

	matchedRules = sortRulesBySpecificity(matchedRules);

	// Add style attribute
	matchedRules.unshift({
		rule: {
			style: element.style,
		},
	});

	for (i = 0; i < props.length; i++) {
		for (j = 0; j < matchedRules.length; j++) {
			if (
				matchedRules[j].rule.style.getPropertyValue(props[i])
				&& matchedRules[j].rule.style.getPropertyPriority(props[i]) === 'important'
			) {
				result[props[i]] = matchedRules[j].rule.style.getPropertyValue(props[i]);
				break;
			}
		}
	}

	for (i = 0; i < props.length; i++) {
		// Skip if an !important rule already matched
		if (result[props[i]]) {
			continue;
		}
		for (j = 0; j < matchedRules.length; j++) {
			if (
				matchedRules[j].rule.style.getPropertyValue(props[i])
				&& matchedRules[j].rule.style.getPropertyPriority(props[i]) !== 'important'
			) {
				result[props[i]] = matchedRules[j].rule.style.getPropertyValue(props[i]);
				break;
			}
		}
	}

	return result;

}

function filterRulesByElementAndProps(rules, element, props) {
	var matchedRules = [];
	for (var i = 0; i < rules.length; i++) {
		if (rules[i].cssRules) {
			matchedRules = matchedRules.concat(filterRulesByElementAndProps(rules[i].cssRules, element, props));
		}
		else if (rules[i].type === 1) { // Style rule
			if (
				styleHasProperty(rules[i].style, props)
				&& (
					!rules[i].parentRule
					|| rules[i].parentRule.type !== 4 // @media rule
					|| window.matchMedia(rules[i].parentRule.media).matches
				)
				&& element.matches(rules[i].selectorText)
			) {
				splitSelectors(rules[i].selectorText).forEach(function(selector) {
					if (element.matches(selector)) {
						matchedRules.push({
							selector: selector,
							rule: rules[i],
						});
					}
				});
			}
		}
	}
	return matchedRules;
}

function styleHasProperty(style, props) {
	for (var i = 0; i < style.length; i++) {
		if (props.indexOf(style.item(i)) !== -1) {
			return true;
		}
	}
	return false;
}

function sortRulesBySpecificity(rules) {
	return rules.map(function(rule, i) {
		return [rule, i];
	}).sort(function(a, b) {
		return (getSpecificity(b[0].selector) - getSpecificity(a[0].selector)) || b[1] - a[1];
	}).map(function(rule) {
		return rule[0];
	});
}

function getSpecificity(selector) {
	// [style, id, class, type]
	var scores = [0, 0, 0, 0];
	selector.replace(SELECTOR_ESCAPED_REGEXP, function() {
		scores[2]++;
		return '';
	});
	selector.replace(ATTR_REGEXP, function() {
		scores[2]++;
		return '';
	});
	selector.replace(PSEUDO_NOT_REGEXP, '');
	selector.replace(ID_REGEXP, function() {
		scores[1]++;
		return '';
	});
	selector.replace(CLASS_REGEXP, function() {
		scores[2]++;
		return '';
	});
	selector.replace(PSEUDO_ELEMENT_REGEXP, function() {
		scores[3]++;
		return '';
	});
	selector.replace(PSEUDO_CLASS_REGEXP, function() {
		scores[2]++;
		return '';
	});
	selector.replace(ELEMENT_REGEXP, function() {
		scores[3]++;
		return '';
	});
	return (
		(scores[0] * 1000 * 1000 * 1000)
		+ (scores[1] * 1000 * 1000)
		+ (scores[2] * 1000)
		+ scores[3]
	);
}

function eachQuery(callback) {
	Object.keys(queries).forEach(function(key) {
		callback(queries[key], key);
	});
}

})(window, document);
<commit_msg>Enhance getSpecificity<commit_after>(function(window, document) {
'use strict';

// Public API
window.containerQueries = {
	reprocess: reprocess,
	reparse: reparse,
	reevaluate: reevaluate,
};

// Reprocess now
setTimeout(reprocess);

window.addEventListener('DOMContentLoaded', reprocess);
window.addEventListener('load', reprocess);
window.addEventListener('resize', reevaluate);

var SELECTOR_REGEXP = /:container\(\s*(?:min|max)-(?:width|height)\s*:\s*[^)]+\s*\)/gi;
var SELECTOR_ESCAPED_REGEXP = /\.\\:container\\\(\s*((?:min|max)-(?:width|height))\s*\\:\s*([^)]+?)\s*\\\)/gi;
var ESCAPE_REGEXP = /[:()]/g;
var SPACE_REGEXP = / /g;
var LENGTH_REGEXP = /^-?(?:\d*\.)?\d+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc)$/i;
var ATTR_REGEXP = /\[.+?\]/g;
var PSEUDO_NOT_REGEXP = /:not\(/g;
var ID_REGEXP = /#[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var CLASS_REGEXP = /\.[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var PSEUDO_ELEMENT_REGEXP = /::[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var PSEUDO_CLASS_REGEXP = /:[^\[\]\\!"#$%&'()*+,./:;<=>?@^`{|}~-]+/g;
var ELEMENT_REGEXP = /[a-z-]+/gi;

var queries;
var containerCache;
var processed = false;
var parsed = false;

function reprocess() {
	preprocess(function() {
		processed = true;
		reparse();
	});
}
function reparse() {
	if (!processed) {
		return reprocess();
	}
	parseRules();
	parsed = true;
	reevaluate();
}
function reevaluate() {
	if (!parsed) {
		return reparse();
	}
	updateClasses();
}

function preprocess(callback) {
	var sheets = document.styleSheets;
	if (!sheets.length) {
		callback();
		return;
	}
	var done = 0;
	for (var i = 0, length = sheets.length; i < length; i++) {
		preprocessSheet(sheets[i], function() {
			done++;
			if (done === length) {
				callback();
			}
		});
	}
}

function preprocessSheet(sheet, callback) {
	if (sheet.disabled) {
		callback();
		return;
	}
	var tag = sheet.ownerNode && sheet.ownerNode.tagName;
	if (tag === 'LINK') {
		loadExternal(sheet.ownerNode.href, function(cssText) {
			// TODO: fix relative URLs, see https://github.com/LeaVerou/prefixfree/blob/765c6a1/prefixfree.js#L46
			preprocessStyle(sheet.ownerNode, cssText, callback);
		});
	}
	else if (tag === 'STYLE') {
		preprocessStyle(sheet.ownerNode, sheet.ownerNode.innerHTML, callback);
	}
	else {
		callback();
	}
}

function loadExternal(href, callback) {
	var xhr = new window.XMLHttpRequest();
	xhr.open('GET', href);
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}
		callback(xhr.status === 200 ? xhr.responseText : '');
	};
	xhr.send();
}

function preprocessStyle(node, cssText, callback) {
	var found = false;
	cssText = cssText.replace(SELECTOR_REGEXP, function(selector) {
		found = true;
		return '.' + selector.replace(SPACE_REGEXP, '').replace(ESCAPE_REGEXP, '\\$&');
	});
	if (!found) {
		callback();
		return;
	}
	var style = document.createElement('style');
	style.textContent = cssText;
	style.media = node.media;
	node.parentNode.insertBefore(style, node);
	node.disabled = true;
	callback();
}

function parseRules() {
	queries = {};
	var sheets = document.styleSheets;
	var rules;
	for (var i = 0; i < sheets.length; i++) {
		if (sheets[i].disabled) {
			continue;
		}
		try {
			rules = sheets[i].cssRules;
		}
		catch(e) {
			continue;
		}
		for (var j = 0; j < rules.length; j++) {
			parseRule(rules[j]);
		}
	}
}

function parseRule(rule) {
	if (rule.cssRules) {
		for (var i = 0; i < rule.cssRules.length; i++) {
			parseRule(rule.cssRules[i]);
		}
		return;
	}
	if (rule.type !== 1) {
		return;
	}
	splitSelectors(rule.selectorText).forEach(function(selector) {
		if (selector.search(SELECTOR_ESCAPED_REGEXP) !== -1) {
			selector.replace(SELECTOR_ESCAPED_REGEXP, function(match, type, value, offset) {
				var precedingSelector = selector.substr(0, offset);
				if (!precedingSelector.substr(-1).trim()) {
					precedingSelector += '*';
				}
				queries[precedingSelector + match.toLowerCase()] = {
					selector: precedingSelector,
					prop: type.split('-')[1].toLowerCase(),
					type: type.split('-')[0].toLowerCase(),
					value: value,
					className: match.toLowerCase().substr(1).replace(/\\(.)/g, '$1'),
				};
			})
		}
	});
}

function splitSelectors(selectors) {
	// TODO: Fix complex selectors like fo\,o[attr="val,u\"e"]
	return selectors.split(/\s*,\s*/);
}

function updateClasses() {
	containerCache = new Map();
	eachQuery(function(query) {
		var elements = document.querySelectorAll(query.selector);
		for (var i = 0; i < elements.length; i++) {
			updateClass(elements[i], query);
		}
	});
}

function updateClass(element, query) {
	var container = getContainer(element.parentNode, query.prop);
	var size = getSize(container, query.prop);
	var value = parseFloat(query.value);
	if (
		(query.type === 'min' && size >= value)
		|| (query.type === 'max' && size <= value)
	) {
		element.classList.add(query.className);
	}
	else {
		element.classList.remove(query.className);
	}
}

function getContainer(element, prop) {

	var cache;
	if (containerCache.has(element)) {
		cache = containerCache.get(element);
		if (cache.container[prop]) {
			return cache.container[prop];
		}
	}
	else {
		cache = {
			container: {},
		};
		containerCache.set(element, cache);
	}

	if (element === document.documentElement) {
		cache.container[prop] = element;
	}

	// Skip inline elements
	else if (window.getComputedStyle(element).display === 'inline') {
		cache.container[prop] = getContainer(element.parentNode, prop);
	}

	else if (isFixedSize(element, prop)) {
		cache.container[prop] = element;
	}

	else {
		var parentContainer = getContainer(element.parentNode, prop);
		var chain = [];
		for (var node = element; node !== parentContainer; node = node.parentNode) {
			// Skip inline elements
			if (window.getComputedStyle(node).display !== 'inline') {
				chain.unshift(node);
			}
		}
		for (var i = 0; i < chain.length; i++) {
			if (isIntrinsicSize(chain[i], prop)) {
				break;
			}
		}
		if (i) {
			cache.container[prop] = chain[i - 1];
		}
		else {
			cache.container[prop] = parentContainer;
		}
	}

	return cache.container[prop];

}

function isFixedSize(element, prop) {
	var originalStyle = getOriginalStyle(element, [prop]);
	if (originalStyle[prop] && originalStyle[prop].search(LENGTH_REGEXP) !== -1) {
		return true;
	}
}

function isIntrinsicSize(element, prop) {

	var computedStyle = window.getComputedStyle(element);

	if (computedStyle.display === 'none') {
		return false;
	}

	if (computedStyle.display === 'inline') {
		return true;
	}

	// Non-floating non-absolute block elements (only width)
	if (
		prop === 'width'
		&& ['block', 'list-item', 'flex', 'grid'].indexOf(computedStyle.display) !== -1
		&& computedStyle.float === 'none'
		&& computedStyle.position !== 'absolute'
		&& computedStyle.position !== 'fixed'
	) {
		return false;
	}

	var originalStyle = getOriginalStyle(element, [prop]);

	// Fixed size
	if (originalStyle[prop] && originalStyle[prop].search(LENGTH_REGEXP) !== -1) {
		return false;
	}

	// Percentage size
	if (originalStyle[prop] && originalStyle[prop].substr(-1) === '%') {
		return false;
	}

	// Elements without a defined size
	return true;

}

// TODO: Return the size of the content-box instead of the border-box
function getSize(element, prop) {
	if (prop === 'width') {
		return element.offsetWidth;
	}
	else if (prop === 'height') {
		return element.offsetHeight;
	}
	return 0;
}

function getOriginalStyle(element, props) {

	var matchedRules = [];
	var sheets = document.styleSheets;
	var rules;
	var result = {};
	var i, j;

	for (i = 0; i < sheets.length; i++) {
		if (sheets[i].disabled) {
			continue;
		}
		try {
			rules = sheets[i].cssRules;
		}
		catch(e) {
			continue;
		}
		matchedRules = matchedRules.concat(filterRulesByElementAndProps(rules, element, props));
	}

	matchedRules = sortRulesBySpecificity(matchedRules);

	// Add style attribute
	matchedRules.unshift({
		rule: {
			style: element.style,
		},
	});

	for (i = 0; i < props.length; i++) {
		for (j = 0; j < matchedRules.length; j++) {
			if (
				matchedRules[j].rule.style.getPropertyValue(props[i])
				&& matchedRules[j].rule.style.getPropertyPriority(props[i]) === 'important'
			) {
				result[props[i]] = matchedRules[j].rule.style.getPropertyValue(props[i]);
				break;
			}
		}
	}

	for (i = 0; i < props.length; i++) {
		// Skip if an !important rule already matched
		if (result[props[i]]) {
			continue;
		}
		for (j = 0; j < matchedRules.length; j++) {
			if (
				matchedRules[j].rule.style.getPropertyValue(props[i])
				&& matchedRules[j].rule.style.getPropertyPriority(props[i]) !== 'important'
			) {
				result[props[i]] = matchedRules[j].rule.style.getPropertyValue(props[i]);
				break;
			}
		}
	}

	return result;

}

function filterRulesByElementAndProps(rules, element, props) {
	var matchedRules = [];
	for (var i = 0; i < rules.length; i++) {
		if (rules[i].cssRules) {
			matchedRules = matchedRules.concat(filterRulesByElementAndProps(rules[i].cssRules, element, props));
		}
		else if (rules[i].type === 1) { // Style rule
			if (
				styleHasProperty(rules[i].style, props)
				&& (
					!rules[i].parentRule
					|| rules[i].parentRule.type !== 4 // @media rule
					|| window.matchMedia(rules[i].parentRule.media).matches
				)
				&& element.matches(rules[i].selectorText)
			) {
				splitSelectors(rules[i].selectorText).forEach(function(selector) {
					if (element.matches(selector)) {
						matchedRules.push({
							selector: selector,
							rule: rules[i],
						});
					}
				});
			}
		}
	}
	return matchedRules;
}

function styleHasProperty(style, props) {
	for (var i = 0; i < style.length; i++) {
		if (props.indexOf(style.item(i)) !== -1) {
			return true;
		}
	}
	return false;
}

function sortRulesBySpecificity(rules) {
	return rules.map(function(rule, i) {
		return [rule, i];
	}).sort(function(a, b) {
		return (getSpecificity(b[0].selector) - getSpecificity(a[0].selector)) || b[1] - a[1];
	}).map(function(rule) {
		return rule[0];
	});
}

function getSpecificity(selector) {
	var scores = {
		id: 0,
		class: 0,
		type: 0,
	};
	selector.replace(SELECTOR_ESCAPED_REGEXP, function() {
		scores.class++;
		return '';
	});
	selector.replace(ATTR_REGEXP, function() {
		scores.class++;
		return '';
	});
	selector.replace(PSEUDO_NOT_REGEXP, '');
	selector.replace(ID_REGEXP, function() {
		scores.id++;
		return '';
	});
	selector.replace(CLASS_REGEXP, function() {
		scores.class++;
		return '';
	});
	selector.replace(PSEUDO_ELEMENT_REGEXP, function() {
		scores.type++;
		return '';
	});
	selector.replace(PSEUDO_CLASS_REGEXP, function() {
		scores.class++;
		return '';
	});
	selector.replace(ELEMENT_REGEXP, function() {
		scores.type++;
		return '';
	});
	return (
		(scores.id * 256 * 256)
		+ (scores.class * 256)
		+ scores.type
	);
}

function eachQuery(callback) {
	Object.keys(queries).forEach(function(key) {
		callback(queries[key], key);
	});
}

})(window, document);
<|endoftext|>


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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        indent: 2,
        latedef: true,
        newcap: true,
        noarg: true,
        quotmark: true,
        undef: true,
        unused: true,
        strict: true,
        trailing: true,
        boss: true,
        eqnull: true,
        browser: true
      },
      grunt: {
        src: ['Gruntfile.js'],
        options: {
          node: true
        }
      },
      src: {
        src: ['selector-set.js'],
        options: {
          globals: {
            'define': false
          }
        }
      },
      test: {
        options: {
          globals: {
            'SelectorSet': false,
            'module': false,
            'test': false,
            'ok': false,
            'equal': false
          }
        },
        src: ['test/unit/*.js']
      },
      fuzz: {
        options: {
          globals: {
            'SelectorSet': false,
            'sessionStorage': false,
            'QUnit': false,
            'ok': false,
            'equal': false
          }
        },
        src: ['test/fuzz.js']
      },
      perf: {
        options: {
          globals: {
            'Benchmark': false,
            'd3': false,
            'SelectorSet': false,
            'ExemplarSelectorSet': false
          }
        },
        src: ['test/perf.js']
      }
    },
    qunit: {
      all: ['test/test-exemplar.html', 'test/test.html'],
      fuzz: ['test/test-fuzz.html']
    },
    watch: {
      grunt: {
        files: ['<%= jshint.grunt.src %>'],
        tasks: ['jshint:grunt']
      },
      src: {
        files: ['<%= jshint.src.src %>'],
        tasks: ['jshint:src', 'qunit']
      },
      test: {
        files: ['<%= jshint.test.src %>', 'test/*.html'],
        tasks: ['jshint:test', 'qunit']
      },
      perf: {
        files: ['<%= jshint.perf.src %>', 'perf/*.html'],
        tasks: ['jshint:perf']
      }
    }
  });

  grunt.registerTask('benchmark', 'Run benchmarks.', function() {
    var phantomjs = require('grunt-lib-phantomjs').init(grunt);

    phantomjs.on('benchmark.cycle', function(bench) {
      // grunt.log.subhead(bench.name);
      grunt.log.writeln(bench.stats.mean * 1000 * 1000);
    });

    phantomjs.on('benchmark.complete', function() {
      phantomjs.halt();
    });

    var done = this.async();
    phantomjs.spawn('test/benchmark.html', {
      options: {
        timeout: 5000
      },
      done: function(err) {
        done(err);
      }
    });
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('test', ['jshint', 'qunit:all']);
  grunt.registerTask('default', ['jshint']);

};
<commit_msg>Add fuzz task<commit_after>module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        indent: 2,
        latedef: true,
        newcap: true,
        noarg: true,
        quotmark: true,
        undef: true,
        unused: true,
        strict: true,
        trailing: true,
        boss: true,
        eqnull: true,
        browser: true
      },
      grunt: {
        src: ['Gruntfile.js'],
        options: {
          node: true
        }
      },
      src: {
        src: ['selector-set.js'],
        options: {
          globals: {
            'define': false
          }
        }
      },
      test: {
        options: {
          globals: {
            'SelectorSet': false,
            'module': false,
            'test': false,
            'ok': false,
            'equal': false
          }
        },
        src: ['test/unit/*.js']
      },
      fuzz: {
        options: {
          globals: {
            'SelectorSet': false,
            'sessionStorage': false,
            'QUnit': false,
            'ok': false,
            'equal': false
          }
        },
        src: ['test/fuzz.js']
      },
      perf: {
        options: {
          globals: {
            'Benchmark': false,
            'd3': false,
            'SelectorSet': false,
            'ExemplarSelectorSet': false
          }
        },
        src: ['test/perf.js']
      }
    },
    qunit: {
      all: ['test/test-exemplar.html', 'test/test.html'],
      fuzz: ['test/test-fuzz.html']
    },
    watch: {
      grunt: {
        files: ['<%= jshint.grunt.src %>'],
        tasks: ['jshint:grunt']
      },
      src: {
        files: ['<%= jshint.src.src %>'],
        tasks: ['jshint:src', 'qunit']
      },
      test: {
        files: ['<%= jshint.test.src %>', 'test/*.html'],
        tasks: ['jshint:test', 'qunit']
      },
      perf: {
        files: ['<%= jshint.perf.src %>', 'perf/*.html'],
        tasks: ['jshint:perf']
      }
    }
  });

  grunt.registerTask('benchmark', 'Run benchmarks.', function() {
    var phantomjs = require('grunt-lib-phantomjs').init(grunt);

    phantomjs.on('benchmark.cycle', function(bench) {
      // grunt.log.subhead(bench.name);
      grunt.log.writeln(bench.stats.mean * 1000 * 1000);
    });

    phantomjs.on('benchmark.complete', function() {
      phantomjs.halt();
    });

    var done = this.async();
    phantomjs.spawn('test/benchmark.html', {
      options: {
        timeout: 5000
      },
      done: function(err) {
        done(err);
      }
    });
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('test', ['jshint', 'qunit:all']);
  grunt.registerTask('fuzz', ['jshint:fuzz', 'qunit:fuzz']);
  grunt.registerTask('default', ['jshint']);

};
<|endoftext|>


<commit_before>/*jslint node: true, nomen: true, white: true, unparam: true*/
/*!
 * Sitegear3
 * Copyright(c) 2014 Ben New, Sitegear.org
 * MIT Licensed
 */

(function () {
	"use strict";
	module.exports = function (grunt) {
		grunt.loadNpmTasks('grunt-jslint');
		grunt.loadNpmTasks('grunt-jasmine-node');
		grunt.loadNpmTasks('grunt-contrib-watch');
		grunt.initConfig({
			pkg: grunt.file.readJSON('package.json'),
			jslint: {
				root: {
					src: [
						'index.js',
						'Gruntfile.js'
					],
					options: {
						log: 'build/log/jslint/jslint.root.log'
					}
				},
				lib: {
					src: [
						'lib/**/*.js'
					],
					options: {
						log: 'build/log/jslint/jslint.src.log'
					}
				},
				tests: {
					src: [
						'tests/**/*.js'
					],
					options: {
						log: 'build/log/jslint/jslint.tests.log'
					}
				}
			},
			jasmine_node: {
				projectRoot: '.',
				jUnit: {
					report: true,
					savePath: 'build/log/jasmine/'
				},
				forceExit: false
			},
			watch: {
				root: {
					files: [
						'index.js',
						'Gruntfile.js'
					],
					tasks: [
						'qa'
					]
				},
				lib: {
					files: [
						'lib/**/*.js'
					],
					tasks: [
						'qa'
					]
				},
				tests: {
					files: [
						'tests/**/*.js'
					],
					tasks: [
						'qa'
					]
				}
			}
		});
		grunt.registerTask('qa', ['jslint', 'jasmine_node']);
		grunt.registerTask('default', ['qa']);
		grunt.event.on('watch', function(action, filepath, target) {
		  grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
		});
	};
}());
<commit_msg>Don't lint setupTests.js<commit_after>/*jslint node: true, nomen: true, white: true, unparam: true*/
/*!
 * Sitegear3
 * Copyright(c) 2014 Ben New, Sitegear.org
 * MIT Licensed
 */

(function () {
	"use strict";
	module.exports = function (grunt) {
		grunt.loadNpmTasks('grunt-jslint');
		grunt.loadNpmTasks('grunt-jasmine-node');
		grunt.loadNpmTasks('grunt-contrib-watch');
		grunt.initConfig({
			pkg: grunt.file.readJSON('package.json'),
			jslint: {
				root: {
					src: [
						'index.js',
						'Gruntfile.js'
					],
					options: {
						log: 'build/log/jslint/jslint.root.log'
					}
				},
				lib: {
					src: [
						'lib/**/*.js'
					],
					options: {
						log: 'build/log/jslint/jslint.src.log'
					}
				},
				tests: {
					src: [
						'tests/**/*.js'
					],
					exclude: [
						'tests/unit/setupTests.js'
					],
					options: {
						log: 'build/log/jslint/jslint.tests.log'
					}
				}
			},
			jasmine_node: {
				projectRoot: '.',
				jUnit: {
					report: true,
					savePath: 'build/log/jasmine/'
				},
				forceExit: false
			},
			watch: {
				root: {
					files: [
						'index.js',
						'Gruntfile.js'
					],
					tasks: [
						'qa'
					]
				},
				lib: {
					files: [
						'lib/**/*.js'
					],
					tasks: [
						'qa'
					]
				},
				tests: {
					files: [
						'tests/**/*.js'
					],
					tasks: [
						'qa'
					]
				}
			}
		});
		grunt.registerTask('qa', ['jslint', 'jasmine_node']);
		grunt.registerTask('default', ['qa']);
		grunt.event.on('watch', function(action, filepath, target) {
			grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
		});
	};
}());
<|endoftext|>


<commit_before>// grunt-contrib-livereload Middleware
'use strict';
var path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;

var folderMount = function folderMount(connect, point) {
    return connect.static(path.resolve(point));
};

// Configuration
module.exports = function(grunt) {
    grunt.initConfig({
        pkg: '<json:package.json>',

        jshint: {
            all: ['scripts/plugins.js', 'scripts/main.js']
        },

        htmllint: {
            all: ['*.html']
        },

        clean: {
            deploy: ['dist']
        },

        connect: {
            livereload: {
                options: {
                    port: 9001,
                    middleware: function(connect, options) {
                        return [lrSnippet, folderMount(connect, '.')];
                    }
                }
            }
        },

        modernizr: {
            'devFile' : 'scripts/vendor/modernizr-2.6.2.min.js',
            'outputFile' : 'dist/scripts/vendor/modernizr-2.6.2.min.js',
            'extra' : {
                'shiv' : false,
                'printshiv' : true,
                'load' : false,
                'mq' : true,
                'cssclasses' : true
            },
            'extensibility' : {
                'addtest' : false,
                'prefixed' : false,
                'teststyles' : false,
                'testprops' : false,
                'testallprops' : false,
                'hasevents' : false,
                'prefixes' : false,
                'domprefixes' : false
            },
            'uglify' : true,
            'tests' : [],
            // parseFiles = true: crawl all *.js, *.css, *.scss files;
            // override by defining "files" array
            'parseFiles' : true,
            'files' : ['scss/**/*.scss', 'scripts/**/*.js'],
            'matchCommunityTests' : false,
            'customTests' : [],
            'excludeFiles' : ['grunt.js','package.json']
        },

        concat: {
            dev: {
                src: ['scripts/plugins.js', 'scripts/main.js'],
                dest: 'scripts/master.js'
            }
        },

        uglify: {
            deploy: {
                src: 'scripts/master.js',
                dest: 'dist/scripts/master.js'
            },
            plugins: {
                files: [
                    {
                        expand: true,
                        cwd: '.',
                        src: ['scripts/plugins/*.js'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        compass: {
            dev: {
                options: {
                    sassDir: 'scss',
                    cssDir: 'styles',
                    imagesDir: 'img',
                    outputStyle: 'nested',
                    noLineComments: true,
                    force: true,
                    debugInfo: false
                }
            },
            deploy: {
                options: {
                    sassDir: 'scss',
                    cssDir: 'dist/styles',
                    imagesDir: 'img',
                    outputStyle: 'compressed',
                    noLineComments: true,
                    force: true,
                    debugInfo: false
                }
            }
        },

        imagemin: {
            deploy: {
                options: {
                    optimizationLevel: 1,
                    progressive: false
                },
                files: [
                    {
                        expand: true,
                        cwd: '.',
                        src: ['img/**/*.png', 'img/**/*.jpg'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        copy: {
            deploy: {
                files: [
                    {
                        src: ['*.html',
                              '.htaccess',
                              'robots.txt',
                              'scripts/vendor/jquery-1.8.3.min.js',
                              'scripts/vendor/boxsizing.htc'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        regarde: {
            html: {
                files: '*.html',
                tasks: ['concat:dev', 'compass:dev', 'livereload']
            },
            js: {
                files: ['scripts/plugins.js', 'scripts/main.js'],
                tasks: ['concat:dev', 'compass:dev', 'livereload']
            },
            scss: {
                files: 'scss/**/*.scss',
                tasks: ['concat:dev', 'compass:dev', 'livereload']
            }
        },

        hashres: {
            options: {
                encoding: 'utf-8',
                fileNameFormat: '${hash}.${ext}',
                renameFiles: true
            },
            deploy: {
                src: [
                    'dist/scripts/master.js',
                    'dist/styles/master.css',
                    'dist/styles/oldie.css'],
                dest: 'dist/*.html',

            }
        }
    });
    // Load required tasks
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-livereload');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-hashres');
    grunt.loadNpmTasks('grunt-html');
    grunt.loadNpmTasks('grunt-modernizr');
    grunt.loadNpmTasks('grunt-regarde');
    // Default
    grunt.registerTask('default', ['livereload-start', 'connect', 'regarde']);
    // Development
    grunt.registerTask('check', ['htmllint', 'jshint']);
    // Deployment
    grunt.registerTask('deploy', ['clean:deploy', 'copy:deploy', 'concat:dev', 'compass:deploy', 'uglify', 'imagemin:deploy', 'modernizr', 'hashres:deploy']);
};
<commit_msg>Missed jQuery 1.9.1 in copy task. Oops.<commit_after>// grunt-contrib-livereload Middleware
'use strict';
var path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;

var folderMount = function folderMount(connect, point) {
    return connect.static(path.resolve(point));
};

// Configuration
module.exports = function(grunt) {
    grunt.initConfig({
        pkg: '<json:package.json>',

        jshint: {
            all: ['scripts/plugins.js', 'scripts/main.js']
        },

        htmllint: {
            all: ['*.html']
        },

        clean: {
            deploy: ['dist']
        },

        connect: {
            livereload: {
                options: {
                    port: 9001,
                    middleware: function(connect, options) {
                        return [lrSnippet, folderMount(connect, '.')];
                    }
                }
            }
        },

        modernizr: {
            'devFile' : 'scripts/vendor/modernizr-2.6.2.min.js',
            'outputFile' : 'dist/scripts/vendor/modernizr-2.6.2.min.js',
            'extra' : {
                'shiv' : false,
                'printshiv' : true,
                'load' : false,
                'mq' : true,
                'cssclasses' : true
            },
            'extensibility' : {
                'addtest' : false,
                'prefixed' : false,
                'teststyles' : false,
                'testprops' : false,
                'testallprops' : false,
                'hasevents' : false,
                'prefixes' : false,
                'domprefixes' : false
            },
            'uglify' : true,
            'tests' : [],
            // parseFiles = true: crawl all *.js, *.css, *.scss files;
            // override by defining "files" array
            'parseFiles' : true,
            'files' : ['scss/**/*.scss', 'scripts/**/*.js'],
            'matchCommunityTests' : false,
            'customTests' : [],
            'excludeFiles' : ['grunt.js','package.json']
        },

        concat: {
            dev: {
                src: ['scripts/plugins.js', 'scripts/main.js'],
                dest: 'scripts/master.js'
            }
        },

        uglify: {
            deploy: {
                src: 'scripts/master.js',
                dest: 'dist/scripts/master.js'
            },
            plugins: {
                files: [
                    {
                        expand: true,
                        cwd: '.',
                        src: ['scripts/plugins/*.js'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        compass: {
            dev: {
                options: {
                    sassDir: 'scss',
                    cssDir: 'styles',
                    imagesDir: 'img',
                    outputStyle: 'nested',
                    noLineComments: true,
                    force: true,
                    debugInfo: false
                }
            },
            deploy: {
                options: {
                    sassDir: 'scss',
                    cssDir: 'dist/styles',
                    imagesDir: 'img',
                    outputStyle: 'compressed',
                    noLineComments: true,
                    force: true,
                    debugInfo: false
                }
            }
        },

        imagemin: {
            deploy: {
                options: {
                    optimizationLevel: 1,
                    progressive: false
                },
                files: [
                    {
                        expand: true,
                        cwd: '.',
                        src: ['img/**/*.png', 'img/**/*.jpg'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        copy: {
            deploy: {
                files: [
                    {
                        src: ['*.html',
                              '.htaccess',
                              'robots.txt',
                              'scripts/vendor/jquery-1.9.1.min.js',
                              'scripts/vendor/boxsizing.htc'],
                        dest: 'dist/'
                    }
                ]
            }
        },

        regarde: {
            html: {
                files: '*.html',
                tasks: ['concat:dev', 'compass:dev', 'livereload']
            },
            js: {
                files: ['scripts/plugins.js', 'scripts/main.js'],
                tasks: ['concat:dev', 'compass:dev', 'livereload']
            },
            scss: {
                files: 'scss/**/*.scss',
                tasks: ['concat:dev', 'compass:dev', 'livereload']
            }
        },

        hashres: {
            options: {
                encoding: 'utf-8',
                fileNameFormat: '${hash}.${ext}',
                renameFiles: true
            },
            deploy: {
                src: [
                    'dist/scripts/master.js',
                    'dist/styles/master.css',
                    'dist/styles/oldie.css'],
                dest: 'dist/*.html',

            }
        }
    });
    // Load required tasks
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-livereload');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-hashres');
    grunt.loadNpmTasks('grunt-html');
    grunt.loadNpmTasks('grunt-modernizr');
    grunt.loadNpmTasks('grunt-regarde');
    // Default
    grunt.registerTask('default', ['livereload-start', 'connect', 'regarde']);
    // Development
    grunt.registerTask('check', ['htmllint', 'jshint']);
    // Deployment
    grunt.registerTask('deploy', ['clean:deploy', 'copy:deploy', 'concat:dev', 'compass:deploy', 'uglify', 'imagemin:deploy', 'modernizr', 'hashres:deploy']);
};
<|endoftext|>


<commit_before>"use strict";
/*

    Many of these tasks are configured using variables defined in `package.json`.  Check that file for the actual
    settings.

*/

module.exports = function (grunt) {
    var pkg = grunt.file.readJSON("package.json");
    grunt.initConfig({
        pkg: pkg,
        jshint: {
            src: ["./**/*.js"],
            buildScripts: ["Gruntfile.js"],
            options: {
                jshintrc: true
            }
        },
        jsonlint: {
            src: ["tests/**/*.json"]
        },
        clean: [ "<%= pkg.config.srcDir %>" ],
        gitclone: {
            clone_couchdb_lucene: {
                options: {
                    cwd:        "<%= pkg.config.buildDir %>",
                    repository: "<%= pkg.config.url %>"
                }
            }
        },
        gitcheckout: {
            checkout_couchdb_lucene_hash: {
                options: {
                    cwd:    "<%= pkg.config.srcDir %>",
                    branch: "<%= pkg.config.hash %>"
                }
            }
        },
        exec: {
            couchdb_maven_build: {
                cwd: "<%= pkg.config.srcDir %>",
                cmd: "mvn -Dmaven.test.skip=true"
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-jsonlint");
    grunt.loadNpmTasks("grunt-shell");
    grunt.loadNpmTasks("grunt-gpii");
    grunt.loadNpmTasks("grunt-git");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-exec");

    grunt.task.registerTask("build_couchdb_lucene", "Builds couchdb-lucene if needed.  Remove build/couchdb-lucene to force a fresh build.", function(){
        if (grunt.file.exists(pkg.config.zipPath)) {
            grunt.log.writeln("couchdb-lucene has already been built, skipping...");
        }
        else {
            grunt.log.writeln("Building couchdb-lucene...");
            grunt.task.run("clean", "gitclone", "gitcheckout", "exec");
        }
    });
};
<commit_msg>GPII-1241:  Fixed maven command syntax to work on Windows.<commit_after>"use strict";
/*

    Many of these tasks are configured using variables defined in `package.json`.  Check that file for the actual
    settings.

*/

module.exports = function (grunt) {
    var pkg = grunt.file.readJSON("package.json");
    grunt.initConfig({
        pkg: pkg,
        jshint: {
            src: ["./**/*.js"],
            buildScripts: ["Gruntfile.js"],
            options: {
                jshintrc: true
            }
        },
        jsonlint: {
            src: ["tests/**/*.json"]
        },
        clean: [ "<%= pkg.config.srcDir %>" ],
        gitclone: {
            clone_couchdb_lucene: {
                options: {
                    cwd:        "<%= pkg.config.buildDir %>",
                    repository: "<%= pkg.config.url %>"
                }
            }
        },
        gitcheckout: {
            checkout_couchdb_lucene_hash: {
                options: {
                    cwd:    "<%= pkg.config.srcDir %>",
                    branch: "<%= pkg.config.hash %>"
                }
            }
        },
        exec: {
            couchdb_maven_build: {
                cwd: "<%= pkg.config.srcDir %>",
                cmd: "mvn -D maven.test.skip=true"
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-jsonlint");
    grunt.loadNpmTasks("grunt-shell");
    grunt.loadNpmTasks("grunt-gpii");
    grunt.loadNpmTasks("grunt-git");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-exec");

    grunt.task.registerTask("build_couchdb_lucene", "Builds couchdb-lucene if needed.  Remove build/couchdb-lucene to force a fresh build.", function(){
        if (grunt.file.exists(pkg.config.zipPath)) {
            grunt.log.writeln("couchdb-lucene has already been built, skipping...");
        }
        else {
            grunt.log.writeln("Building couchdb-lucene...");
            grunt.task.run("clean", "gitclone", "gitcheckout", "exec");
        }
    });
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        curl: {
            'extlib/qunit.js': 'http://code.jquery.com/qunit/qunit-1.14.0.js',
            'extlib/qunit.css': 'http://code.jquery.com/qunit/qunit-1.14.0.css'
        },
        markdown: {
            all: {
                files: [
                    {
                        expand: true,
                        src: 'README.md',
                        dest: '',
                        ext: '.html'
                    }
                ]
            }
        },
        jsdoc: {
            dist: {
                src: [
                    'lib/*.js',
                    '!<%= concat.dist.dest %>',
                    '!lib/polyfill.js'
                ],
                dest: 'doc',
                options: {
                    lenient: true
                }
            }
        },
        clean: {
            dev: [
                'node_modules/',
                'npm-debug.log',
                'extlib/*',
                '!extlib/.exists',
            ],
            doc: [
                'README.html',
                'doc/*',
                '!doc/generator.bat'
            ],
            chart: [
                'chart/*',
                '!chart/.exists'
            ],
            dist: [
                '<%= concat.dist.dest %>',
                '*.zip'
            ]
        },
        concat: {
            options: {
                stripBanners: true,
                process: function(source, path) {
                    return source.replace(
                        // Remove script mode syntax and append origin.
                        /(^|\r?\n)\s*('use strict'|"use strict");?\s*/,
                        [
                            '// Source: ' + path,
                            '',
                            ''
                        ].join(grunt.util.linefeed)
                    );
                },
                banner: [
                    '/**',
                    ' * @fileOverview <%= pkg.description %>.',
                    ' *     This module added {@code <%= pkg.name %>} ' +
                        'symbol to the global namespace.',
                    ' * @version <%= pkg.version %> (Released at ' +
                        '<%= grunt.template.today("isoDateTime") %>' +
                        '<%= grunt.template.today("o") %>)',
                    ' * @author <%= pkg.author.email %> ' +
                        '(<%= pkg.author.name %>)',
                    ' * @license <%= pkg.licenses[0].type %> ' +
                        '(See LICENSE file)',
                    ' */',
                    '',
                    "'use strict'; // Script mode syntax (Whole-library)",
                    '',
                    ''
                ].join(grunt.util.linefeed)
            },
            dist: {
                src: [
                    // Note: Don't specify 'lib/*.js'! It is order-sensitive.
                    'lib/main.js', // It has script mode and global namespace.
                    'lib/inscription.js',
                    'lib/factory.js',
                    'lib/formatter.js',
                    'lib/exception.js',
                    'lib/array.js',
                    'lib/pseudo-interface.js',
                    'lib/configuration.js',
                    'lib/stream.js',
                    'lib/date.js',
                    'lib/game.js',
                    'lib/agent.js',
                    'lib/tokenizer.js',
                    'lib/selector.js',
                    'lib/projector.js',
                    'lib/relation.js',
                    'lib/table.js',
                    'lib/chart.js',
                    'lib/template.js',
                    'lib/visualizer.js'
                ],
                dest: 'lib/kclv.js',
                nonull: true
            }
        },
        compress: {
            dist: {
                options: {
                    archive: '<%= pkg.name %>-<%= pkg.version %>.zip'
                },
                files: [
                    {
                        src: [
                            'README.html',
                            'LICENSE',
                            'configuration.json',
                            'visualizer.wsf',
                            'chart/**',
                            '<%= concat.dist.dest %>',
                            'lib/polyfill.js',
                            'template/**'
                        ]
                    }
                ]
            }
        },
        jshint: {
            self: [
                'Gruntfile.js',
            ],
            test: [
                'test/*.js',
                'test/.jshintrc',
                'test/.csshintrc'
            ],
            dist: [
                // 'configuration.json',
                'lib/*.js',
                '!<%= concat.dist.dest %>',
                '!lib/polyfill.js'
            ],
            options: {
                jshintrc: 'test/.jshintrc'
            }
        },
        csslint: {
            dist: {
                src: [
                    'template/chart.css'
                ],
                options: {
                    csslintrc: 'test/.csslintrc'
                }
            }
        },
        qunit: {
            files: [
                'test/harness.html'
            ]
        }
    });

    grunt.loadNpmTasks('grunt-curl');
    grunt.registerTask(
        'build',
        [
            'curl'
        ]
    );

    grunt.loadNpmTasks('grunt-markdown');
    grunt.loadNpmTasks('grunt-jsdoc');
    grunt.registerTask(
        'doc',
        [
            'markdown',
            'jsdoc'
        ]
    );

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-compress');
    grunt.registerTask(
        'dist',
        [
            'clean:dist',
            'clean:chart',
            'clean:doc',
            'markdown',
            'concat',
            'compress:dist'
        ]
    );

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-csslint');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.registerTask(
        'test',
        [
            'csslint',
            'jshint',
            'concat',
            'qunit'
        ]
    );
};
<commit_msg>Remove trashes before generating documentation<commit_after>'use strict';

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        curl: {
            'extlib/qunit.js': 'http://code.jquery.com/qunit/qunit-1.14.0.js',
            'extlib/qunit.css': 'http://code.jquery.com/qunit/qunit-1.14.0.css'
        },
        markdown: {
            all: {
                files: [
                    {
                        expand: true,
                        src: 'README.md',
                        dest: '',
                        ext: '.html'
                    }
                ]
            }
        },
        jsdoc: {
            dist: {
                src: [
                    'lib/*.js',
                    '!<%= concat.dist.dest %>',
                    '!lib/polyfill.js'
                ],
                dest: 'doc',
                options: {
                    lenient: true
                }
            }
        },
        clean: {
            dev: [
                'node_modules/',
                'npm-debug.log',
                'extlib/*',
                '!extlib/.exists',
            ],
            doc: [
                'README.html',
                'doc/*',
                '!doc/generator.bat'
            ],
            chart: [
                'chart/*',
                '!chart/.exists'
            ],
            dist: [
                '<%= concat.dist.dest %>',
                '*.zip'
            ]
        },
        concat: {
            options: {
                stripBanners: true,
                process: function(source, path) {
                    return source.replace(
                        // Remove script mode syntax and append origin.
                        /(^|\r?\n)\s*('use strict'|"use strict");?\s*/,
                        [
                            '// Source: ' + path,
                            '',
                            ''
                        ].join(grunt.util.linefeed)
                    );
                },
                banner: [
                    '/**',
                    ' * @fileOverview <%= pkg.description %>.',
                    ' *     This module added {@code <%= pkg.name %>} ' +
                        'symbol to the global namespace.',
                    ' * @version <%= pkg.version %> (Released at ' +
                        '<%= grunt.template.today("isoDateTime") %>' +
                        '<%= grunt.template.today("o") %>)',
                    ' * @author <%= pkg.author.email %> ' +
                        '(<%= pkg.author.name %>)',
                    ' * @license <%= pkg.licenses[0].type %> ' +
                        '(See LICENSE file)',
                    ' */',
                    '',
                    "'use strict'; // Script mode syntax (Whole-library)",
                    '',
                    ''
                ].join(grunt.util.linefeed)
            },
            dist: {
                src: [
                    // Note: Don't specify 'lib/*.js'! It is order-sensitive.
                    'lib/main.js', // It has script mode and global namespace.
                    'lib/inscription.js',
                    'lib/factory.js',
                    'lib/formatter.js',
                    'lib/exception.js',
                    'lib/array.js',
                    'lib/pseudo-interface.js',
                    'lib/configuration.js',
                    'lib/stream.js',
                    'lib/date.js',
                    'lib/game.js',
                    'lib/agent.js',
                    'lib/tokenizer.js',
                    'lib/selector.js',
                    'lib/projector.js',
                    'lib/relation.js',
                    'lib/table.js',
                    'lib/chart.js',
                    'lib/template.js',
                    'lib/visualizer.js'
                ],
                dest: 'lib/kclv.js',
                nonull: true
            }
        },
        compress: {
            dist: {
                options: {
                    archive: '<%= pkg.name %>-<%= pkg.version %>.zip'
                },
                files: [
                    {
                        src: [
                            'README.html',
                            'LICENSE',
                            'configuration.json',
                            'visualizer.wsf',
                            'chart/**',
                            '<%= concat.dist.dest %>',
                            'lib/polyfill.js',
                            'template/**'
                        ]
                    }
                ]
            }
        },
        jshint: {
            self: [
                'Gruntfile.js',
            ],
            test: [
                'test/*.js',
                'test/.jshintrc',
                'test/.csshintrc'
            ],
            dist: [
                // 'configuration.json',
                'lib/*.js',
                '!<%= concat.dist.dest %>',
                '!lib/polyfill.js'
            ],
            options: {
                jshintrc: 'test/.jshintrc'
            }
        },
        csslint: {
            dist: {
                src: [
                    'template/chart.css'
                ],
                options: {
                    csslintrc: 'test/.csslintrc'
                }
            }
        },
        qunit: {
            files: [
                'test/harness.html'
            ]
        }
    });

    grunt.loadNpmTasks('grunt-curl');
    grunt.registerTask(
        'build',
        [
            'curl'
        ]
    );

    grunt.loadNpmTasks('grunt-markdown');
    grunt.loadNpmTasks('grunt-jsdoc');
    grunt.registerTask(
        'doc',
        [
            'clean:doc',
            'markdown',
            'jsdoc'
        ]
    );

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-compress');
    grunt.registerTask(
        'dist',
        [
            'clean:dist',
            'clean:chart',
            'clean:doc',
            'markdown',
            'concat',
            'compress:dist'
        ]
    );

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-csslint');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.registerTask(
        'test',
        [
            'csslint',
            'jshint',
            'concat',
            'qunit'
        ]
    );
};
<|endoftext|>


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

  // Define the browsers to test with Sauce Labs
  var platforms = {
    'Windows 8.1': {
      chrome: ['38', '39'],
      firefox: ['33', '34'],
      'internet explorer': ['11']
    },
    'Windows 7': {
      chrome: ['38', '39'],
      firefox: ['33', '34'],
      'internet explorer': ['9', '10', '11']
    },
    'OS X 10.8': {
      iPhone: ['5.1'],
      safari: ['6']
    },
    'OS X 10.9': {
      iPhone: ['8.1'],
      iPad: ['8.1'],
      safari: ['7']
    },
    'OS X 10.10': {
      safari: ['8']
    },
    Linux: {
      chrome: ['38', '39'],
      firefox: ['33', '34'],
      android: ['4.0', '4.4']
    }
  };

  var sauceBrowsers = [];

  for (var platform in platforms) {
    var browsers = platforms[platform];
    for (var browser in browsers) {
      var versions = browsers[browser];
      for (var i = 0; i < versions.length; i++) {
        sauceBrowsers.push([platform, browser, versions[i]]);
      }
    }
  }

  // Define more options
  var qunitTestsUrl = 'http://127.0.0.1:9999/test/index.html?hidepassed';

  // Project configuration.
  grunt.initConfig({

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

    jsonlint: {
      all: {
        src: [
          'package.json',
          '.jshintrc',
          'src/.jshintrc',
          'test/tests/.jshintrc'
        ]
      }
    },

    jshint: {
      all: {
        src: [
          'Gruntfile.js',
          'build/**/*.js',
          'src/**/*.js',
          'test/tests/**/*.js'
        ],
        options: {
          jshintrc: true
        }
      }
    },

    connect: {
      temp: {
        options: {
          port: 9999
        }
      },
      local: {
        options: {
          port: 9999,
          open: qunitTestsUrl,
          keepalive: true
        }
      }
    },

    'saucelabs-qunit': {
      full: {
        options: {
          browsers: sauceBrowsers,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          tags: ['master', 'full'],
          testname: 'Firebolt QUnit full test',
          urls: [qunitTestsUrl]
        }
      },
      basic: {
        options: {
          browsers: [sauceBrowsers[1]],
          concurrency: 1,
          tags: ['master', 'basic'],
          testname: 'Firebolt QUnit basic test',
          urls: [qunitTestsUrl]
        }
      },
      custom: {
        options: {
          browsers: [ ['OS X 10.8', 'iPhone', '6.0'] ],
          concurrency: 1,
          tags: ['master', 'custom'],
          testname: 'Firebolt QUnit custom test',
          urls: [qunitTestsUrl]
        }
      }
    },

    copy: {
      all: {
        src: 'src/firebolt.js',
        dest: 'dist/firebolt.js'
      }
    },

    uglify: {
      options: {
        banner: '/*! Firebolt v<%= pkg.version %> | (c)2014 Nathan Woltman | fireboltjs.com/license */',
        sourceMap: true,
        sourceMapName: 'dist/firebolt.min.map'
      },
      build: {
        src: 'dist/firebolt.js',
        dest: 'dist/firebolt.min.js'
      }
    },

    compare_size: {
      files: [
        'dist/firebolt.js',
        'dist/firebolt.min.js'
      ],
      options: {
        cache: 'build/.sizecache.json',
        compress: {
          gz: function(contents) {
            return require('gzip-js').zip(contents, {}).length;
          }
        }
      }
    }

  });

  // Load the Grunt plugins
  require('load-grunt-tasks')(grunt);

  // Load custom build tasks
  grunt.loadTasks('build');

  // --- Register tasks ---
  grunt.registerTask('lint', ['jsonlint', 'jshint']);
  grunt.registerTask('dev', ['lint', 'connect:local']);
  grunt.registerTask('build:clean', ['tasks.cleandist']);
  grunt.registerTask('build:basic', ['copy', 'uglify']);
  grunt.registerTask('build', ['lint', 'build:clean', 'build:basic', 'compare_size']);
  grunt.registerTask('release', ['build', 'tasks.release']);

  // Only connect to Sauce if the user has Sauce credentials
  if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
    grunt.registerTask('test', ['lint', 'connect:temp', 'saucelabs-qunit:basic']);
    grunt.registerTask('fulltest', ['lint', 'connect:temp', 'saucelabs-qunit:full']);
    grunt.registerTask('customtest', ['connect:temp', 'saucelabs-qunit:custom']);
  } else {
    grunt.registerTask('test', ['lint', 'connect:local']); // Same as dev
    grunt.registerTask('fulltest', ['tasks.nofulltest']);
  }

  // Default: do a release build and run all tests
  grunt.registerTask('default', ['release', 'connect:temp', 'saucelabs-qunit:full']);
};
<commit_msg>grunt: Reduce the number of duplicate browser tests<commit_after>module.exports = function(grunt) {
  'use strict';

  // Define the browsers to test with Sauce Labs
  var platforms = {
    'Windows 7': {
      chrome: ['38', '39'],
      firefox: ['33', '34'],
      'internet explorer': ['9', '10', '11']
    },
    'OS X 10.8': {
      iPhone: ['5.1'],
      safari: ['6']
    },
    'OS X 10.9': {
      iPhone: ['8.1'],
      safari: ['7']
    },
    'OS X 10.10': {
      safari: ['8']
    },
    Linux: {
      android: ['4.0', '4.4']
    }
  };

  var sauceBrowsers = [];

  for (var platform in platforms) {
    var browsers = platforms[platform];
    for (var browser in browsers) {
      var versions = browsers[browser];
      for (var i = 0; i < versions.length; i++) {
        sauceBrowsers.push([platform, browser, versions[i]]);
      }
    }
  }

  // Define more options
  var qunitTestsUrl = 'http://127.0.0.1:9999/test/index.html?hidepassed';

  // Project configuration.
  grunt.initConfig({

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

    jsonlint: {
      all: {
        src: [
          'package.json',
          '.jshintrc',
          'src/.jshintrc',
          'test/tests/.jshintrc'
        ]
      }
    },

    jshint: {
      all: {
        src: [
          'Gruntfile.js',
          'build/**/*.js',
          'src/**/*.js',
          'test/tests/**/*.js'
        ],
        options: {
          jshintrc: true
        }
      }
    },

    connect: {
      temp: {
        options: {
          port: 9999
        }
      },
      local: {
        options: {
          port: 9999,
          open: qunitTestsUrl,
          keepalive: true
        }
      }
    },

    'saucelabs-qunit': {
      full: {
        options: {
          browsers: sauceBrowsers,
          build: process.env.TRAVIS_JOB_ID,
          concurrency: 3,
          tags: ['master', 'full'],
          testname: 'Firebolt QUnit full test',
          urls: [qunitTestsUrl]
        }
      },
      basic: {
        options: {
          browsers: [sauceBrowsers[1]],
          concurrency: 1,
          tags: ['master', 'basic'],
          testname: 'Firebolt QUnit basic test',
          urls: [qunitTestsUrl]
        }
      },
      custom: {
        options: {
          browsers: [ ['OS X 10.8', 'iPhone', '6.0'] ],
          concurrency: 1,
          tags: ['master', 'custom'],
          testname: 'Firebolt QUnit custom test',
          urls: [qunitTestsUrl]
        }
      }
    },

    copy: {
      all: {
        src: 'src/firebolt.js',
        dest: 'dist/firebolt.js'
      }
    },

    uglify: {
      options: {
        banner: '/*! Firebolt v<%= pkg.version %> | (c)2014 Nathan Woltman | fireboltjs.com/license */',
        sourceMap: true,
        sourceMapName: 'dist/firebolt.min.map'
      },
      build: {
        src: 'dist/firebolt.js',
        dest: 'dist/firebolt.min.js'
      }
    },

    compare_size: {
      files: [
        'dist/firebolt.js',
        'dist/firebolt.min.js'
      ],
      options: {
        cache: 'build/.sizecache.json',
        compress: {
          gz: function(contents) {
            return require('gzip-js').zip(contents, {}).length;
          }
        }
      }
    }

  });

  // Load the Grunt plugins
  require('load-grunt-tasks')(grunt);

  // Load custom build tasks
  grunt.loadTasks('build');

  // --- Register tasks ---
  grunt.registerTask('lint', ['jsonlint', 'jshint']);
  grunt.registerTask('dev', ['lint', 'connect:local']);
  grunt.registerTask('build:clean', ['tasks.cleandist']);
  grunt.registerTask('build:basic', ['copy', 'uglify']);
  grunt.registerTask('build', ['lint', 'build:clean', 'build:basic', 'compare_size']);
  grunt.registerTask('release', ['build', 'tasks.release']);

  // Only connect to Sauce if the user has Sauce credentials
  if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
    grunt.registerTask('test', ['lint', 'connect:temp', 'saucelabs-qunit:basic']);
    grunt.registerTask('fulltest', ['lint', 'connect:temp', 'saucelabs-qunit:full']);
    grunt.registerTask('customtest', ['connect:temp', 'saucelabs-qunit:custom']);
  } else {
    grunt.registerTask('test', ['lint', 'connect:local']); // Same as dev
    grunt.registerTask('fulltest', ['tasks.nofulltest']);
  }

  // Default: do a release build and run all tests
  grunt.registerTask('default', ['release', 'connect:temp', 'saucelabs-qunit:full']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  require("bit-imports/tasks/grunt")(grunt);
  require("load-grunt-tasks")(grunt);

  var taskConfig = require("config-grunt-tasks")(grunt, "./build-tasks");
  taskConfig.pkg = require("./package.json");

  grunt.initConfig(taskConfig);

  grunt.registerTask("build", ["jshint:all", "browserify:build", "uglify:build"]);
  grunt.registerTask("test", ["connect:test", "mocha:test"]);
  grunt.registerTask("serve", ["concurrent:build"]);
  grunt.registerTask("build-docs", ["jsdoc:build"]);
  grunt.registerTask("serve-docs", ["build-docs", "concurrent:docs"]);
  grunt.registerTask("build-site", ["clean:site", "build", "jsdoc", "bitimports:site", "copy:siteignore", "copy:site", "copy:sitedocs"]);
  grunt.registerTask("publish-site", ["build-site", "buildcontrol:pages"]);
  grunt.registerTask("serve-site", ["build-site", "concurrent:site"]);
};
<commit_msg>Reverted gruntfile dependency for bit-imports grunt task. This will be updated when a version is published<commit_after>module.exports = function(grunt) {
  require("bit-imports/tasks/bitimports")(grunt);
  require("load-grunt-tasks")(grunt);

  var taskConfig = require("config-grunt-tasks")(grunt, "./build-tasks");
  taskConfig.pkg = require("./package.json");

  grunt.initConfig(taskConfig);

  grunt.registerTask("build", ["jshint:all", "browserify:build", "uglify:build"]);
  grunt.registerTask("test", ["connect:test", "mocha:test"]);
  grunt.registerTask("serve", ["concurrent:build"]);
  grunt.registerTask("build-docs", ["jsdoc:build"]);
  grunt.registerTask("serve-docs", ["build-docs", "concurrent:docs"]);
  grunt.registerTask("build-site", ["clean:site", "build", "jsdoc", "bitimports:site", "copy:siteignore", "copy:site", "copy:sitedocs"]);
  grunt.registerTask("publish-site", ["build-site", "buildcontrol:pages"]);
  grunt.registerTask("serve-site", ["build-site", "concurrent:site"]);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  var pkg = require("./package.json");
  global.jasmineVersion = pkg.version;

  grunt.initConfig({
    pkg: pkg,
    jshint: require('./grunt/config/jshint.js'),
    concat: require('./grunt/config/concat.js'),
    compass: require('./grunt/config/compass.js'),
    compress: require('./grunt/config/compress.js')
  });

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

  grunt.loadTasks('grunt/tasks');

  grunt.registerTask('default', ['jshint:all']);

  var version = require('./grunt/tasks/version.js');

  grunt.registerTask('build:copyVersionToGem',
    "Propagates the version from package.json to version.rb",
    version.copyToGem);

  grunt.registerTask('buildDistribution',
    'Builds and lints jasmine.js, jasmine-html.js, jasmine.css',
    [
      'compass',
      'jshint:beforeConcat',
      'concat',
      'jshint:afterConcat',
      'build:copyVersionToGem'
    ]
  );

  grunt.registerTask("execSpecsInNode",
    "Run Jasmine core specs in Node.js",
    function() {
      var done = this.async(),
          Jasmine = require('jasmine'),
          jasmineCore = require('./lib/jasmine-core.js'),
          jasmine = new Jasmine({jasmineCore: jasmineCore});

      jasmine.loadConfigFile('./spec/support/jasmine.json');
      jasmine.configureDefaultReporter({
        onComplete: function(passed) {
          done(passed);
        }
      });

      jasmine.execute();
    }
  );

  grunt.registerTask("execSpecsInNode:performance",
    "Run Jasmine performance specs in Node.js",
    function() {
      require("shelljs").exec("node_modules/.bin/jasmine JASMINE_CONFIG_PATH=spec/support/jasmine-performance.json");
    }
  );
};
<commit_msg>Don't use deprecated `onComplete` syntax for jasmine-npm<commit_after>module.exports = function(grunt) {
  var pkg = require("./package.json");
  global.jasmineVersion = pkg.version;

  grunt.initConfig({
    pkg: pkg,
    jshint: require('./grunt/config/jshint.js'),
    concat: require('./grunt/config/concat.js'),
    compass: require('./grunt/config/compass.js'),
    compress: require('./grunt/config/compress.js')
  });

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

  grunt.loadTasks('grunt/tasks');

  grunt.registerTask('default', ['jshint:all']);

  var version = require('./grunt/tasks/version.js');

  grunt.registerTask('build:copyVersionToGem',
    "Propagates the version from package.json to version.rb",
    version.copyToGem);

  grunt.registerTask('buildDistribution',
    'Builds and lints jasmine.js, jasmine-html.js, jasmine.css',
    [
      'compass',
      'jshint:beforeConcat',
      'concat',
      'jshint:afterConcat',
      'build:copyVersionToGem'
    ]
  );

  grunt.registerTask("execSpecsInNode",
    "Run Jasmine core specs in Node.js",
    function() {
      var done = this.async(),
          Jasmine = require('jasmine'),
          jasmineCore = require('./lib/jasmine-core.js'),
          jasmine = new Jasmine({jasmineCore: jasmineCore});

      jasmine.loadConfigFile('./spec/support/jasmine.json');
      jasmine.onComplete(function(passed) {
        done(passed);
      });

      jasmine.execute();
    }
  );

  grunt.registerTask("execSpecsInNode:performance",
    "Run Jasmine performance specs in Node.js",
    function() {
      require("shelljs").exec("node_modules/.bin/jasmine JASMINE_CONFIG_PATH=spec/support/jasmine-performance.json");
    }
  );
};
<|endoftext|>