<commit_before>// Generated on 2015-06-21 using generator-angular 0.11.1
'use strict';

// # 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 grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'karma']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect().use(
                                '/app/styles',
                                connect.static('./app/styles')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/{,*/}*',
                        '!<%= yeoman.dist %>/.git{,*/}*'
                    ]
                }]
            },
            server: '.tmp'
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            server: {
                options: {
                    map: true,
                },
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath: /\.\.\//
            },
            test: {
                devDependencies: true,
                src: '<%= karma.unit.configFile %>',
                ignorePath: /\.\.\//,
                fileTypes: {
                    js: {
                        block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
                        detect: {
                            js: /'(.*\.js)'/gi
                        },
                        replace: {
                            js: '\'{{filePath}}\','
                        }
                    }
                }
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

        // Performs rewrites based on filerev and the useminPrepare configuration
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: [
                    '<%= yeoman.dist %>',
                    '<%= yeoman.dist %>/images',
                    '<%= yeoman.dist %>/styles'
                ]
            }
        },

        // The following *-min tasks will produce minified files in the dist folder
        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: ['*.html', 'views/{,*/}*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/concat/scripts',
                    src: '*.js',
                    dest: '.tmp/concat/scripts'
                }]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        '*.html',
                        'views/{,*/}*.html',
                        'images/{,*/}*.{webp}',
                        'styles/fonts/{,*/}*.*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: ['generated/*']
                }, {
                    expand: true,
                    cwd: 'locales',
                    dest: 'dist/locales/',
                    src: '{,*/}*.json'
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            },
            locales: {
                expand: true,
                cwd: 'locales',
                dest: '.tmp/locales/',
                src: '{,*/}*.json'
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        },

        i18n: {
            dist: {
                options: {
                    baseDir: 'dist',
                    outputDir: 'dist'
                }
            },
            options: {
                selector: '[translate]',
                locales: ['en', 'nl'],
                locale: 'en',
                localesPath: 'locales'
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function(target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

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

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function(target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

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

    grunt.registerTask('build', [
        'clean:dist',
        'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin',
        'i18n:dist'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);
};
<commit_msg>fixed issue with selector<commit_after>// Generated on 2015-06-21 using generator-angular 0.11.1
'use strict';

// # 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 grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths for the application
    var appConfig = {
        app: require('./bower.json').appPath || 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        yeoman: appConfig,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['wiredep']
            },
            js: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
                tasks: ['newer:jshint:all'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            jsTest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test', 'karma']
            },
            styles: {
                files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect().use(
                                '/app/styles',
                                connect.static('./app/styles')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: {
                src: [
                    'Gruntfile.js',
                    '<%= yeoman.app %>/scripts/{,*/}*.js'
                ]
            },
            test: {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src: ['test/spec/{,*/}*.js']
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/{,*/}*',
                        '!<%= yeoman.dist %>/.git{,*/}*'
                    ]
                }]
            },
            server: '.tmp'
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            server: {
                options: {
                    map: true,
                },
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the app
        wiredep: {
            app: {
                src: ['<%= yeoman.app %>/index.html'],
                ignorePath: /\.\.\//
            },
            test: {
                devDependencies: true,
                src: '<%= karma.unit.configFile %>',
                ignorePath: /\.\.\//,
                fileTypes: {
                    js: {
                        block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
                        detect: {
                            js: /'(.*\.js)'/gi
                        },
                        replace: {
                            js: '\'{{filePath}}\','
                        }
                    }
                }
            }
        },

        // Renames files for browser caching purposes
        filerev: {
            dist: {
                src: [
                    '<%= yeoman.dist %>/scripts/{,*/}*.js',
                    '<%= yeoman.dist %>/styles/{,*/}*.css',
                    '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                    '<%= yeoman.dist %>/styles/fonts/*'
                ]
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            js: ['concat', 'uglifyjs'],
                            css: ['cssmin']
                        },
                        post: {}
                    }
                }
            }
        },

        // Performs rewrites based on filerev and the useminPrepare configuration
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: [
                    '<%= yeoman.dist %>',
                    '<%= yeoman.dist %>/images',
                    '<%= yeoman.dist %>/styles'
                ]
            }
        },

        // The following *-min tasks will produce minified files in the dist folder
        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/styles/main.css': [
        //         '.tmp/styles/{,*/}*.css'
        //       ]
        //     }
        //   }
        // },
        // uglify: {
        //   dist: {
        //     files: {
        //       '<%= yeoman.dist %>/scripts/scripts.js': [
        //         '<%= yeoman.dist %>/scripts/scripts.js'
        //       ]
        //     }
        //   }
        // },
        // concat: {
        //   dist: {}
        // },

        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg,gif}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseWhitespace: true,
                    conservativeCollapse: true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA: true,
                    removeOptionalTags: true
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.dist %>',
                    src: ['*.html', 'views/{,*/}*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },

        // ng-annotate tries to make the code safe for minification automatically
        // by using the Angular long form for dependency injection.
        ngAnnotate: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/concat/scripts',
                    src: '*.js',
                    dest: '.tmp/concat/scripts'
                }]
            }
        },

        // Replace Google CDN references
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        '*.html',
                        'views/{,*/}*.html',
                        'images/{,*/}*.{webp}',
                        'styles/fonts/{,*/}*.*'
                    ]
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: ['generated/*']
                }, {
                    expand: true,
                    cwd: 'locales',
                    dest: 'dist/locales/',
                    src: '{,*/}*.json'
                }]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            },
            locales: {
                expand: true,
                cwd: 'locales',
                dest: '.tmp/locales/',
                src: '{,*/}*.json'
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        },

        // Test settings
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        },

        i18n: {
            dist: {
                options: {
                    baseDir: 'dist',
                    outputDir: 'dist'
                }
            },
            options: {
                selector: ['translate'],
                locales: ['en', 'nl'],
                locale: 'en',
                localesPath: 'locales'
            }
        }
    });

    grunt.registerTask('serve', 'Compile then start a connect web server', function(target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

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

    grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function(target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

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

    grunt.registerTask('build', [
        'clean:dist',
        'wiredep',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngAnnotate',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'filerev',
        'usemin',
        'htmlmin',
        'i18n:dist'
    ]);

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


<commit_before>'use strict';

const through = require('through2');
const PluginError = require('plugin-error');
const fancyLog = require('fancy-log');
const colors = require('ansi-colors');
const File = require('vinyl');
const path = require('path');
const fs = require('fs');
const stripBomBuf = require('strip-bom-buf');
const escapeStringRegexp = require('escape-string-regexp');

/**
 * Constants
 */
const PLUGIN_NAME = 'gulp-inject-partials';
const DEFAULT_START = '<!-- partial:{{path}} -->';
const DEFAULT_END = '<!-- partial -->';
const FILE_PATH_REGEX = "((\/|\\.\/)?((\\.\\.\/)+)?((\\w|\\-)(\\.(\\w|\\-))?)+((\/((\\w|\\-)(\\.(\\w|\\-))?)+)+)?)";
const PATH_REGEX = /\\{\\{path\\}\\}/; // ugly I know
const LEADING_WHITESPACE_REGEXP = /^\s*/;

module.exports = function(opt) {
	opt = opt || {};

	opt.start = defaults(opt, 'start', DEFAULT_START);
	opt.end = defaults(opt, 'end', DEFAULT_END);
	opt.removeTags = bool(opt, 'removeTags', false);
	opt.quiet = bool(opt, 'quiet', false);
	opt.prefix = defaults(opt, 'prefix', '');
	opt.ignoreError = bool(opt, 'ignoreError', false);

  /**
   * Handle injection of files
   * @param target
   * @param encoding
   * @param cb
   * @returns {*}
   */
  function handleStream(target, encoding, cb){
		if (target.isNull()) {
			return cb(null, target);
		}

		if (target.isStream()) {
			return cb(error(target.path + ': Streams not supported for target templates!'));
		}

		try {
			const tagsRegExp = getRegExpTags(opt, null);
			target.contents = processContent(target, opt, tagsRegExp, [target.path]);
			this.push(target);
			return cb();
		} catch(err) {
			this.emit('error', err);
			return cb();
		}
	}

	return through.obj(handleStream);
};

/**
 * Parse content and create new template
 * with all injections made
 *
 * @param {Object} target
 * @param {Object} opt
 * @param {Object} tagsRegExp
 * @param {Array} listOfFiles
 * @returns {Buffer}
 */
function processContent(target, opt, tagsRegExp, listOfFiles){
	let targetContent = String(target.contents);
	const targetPath = target.path;
	const files = extractFilePaths(targetContent, targetPath, opt, tagsRegExp);

	// recursively process files
	files.forEach(function(fileData){
		if (listOfFiles.indexOf(fileData.file.path) !== -1) {
			throw error("Circular definition found. File: " + fileData.file.path + " referenced in a child file.");
		}
		listOfFiles.push(fileData.file.path);
		const content = processContent(fileData.file, opt, tagsRegExp, listOfFiles);
		listOfFiles.pop();

		targetContent = inject(targetContent, String(content), opt, fileData.tags);
	});
	if (listOfFiles.length === 1 && !opt.quiet && files.length) {
		log(
			colors.cyan(files.length.toString()) +
      ' partials injected into ' +
      colors.magenta(targetPath) +
      '.');
	}
	return new Buffer(targetContent);
}

/**
 * Inject tags into target content between given
 * start and end tags
 *
 * @param {String} targetContent
 * @param {String} sourceContent
 * @param {Object} opt
 * @param {Object} tagsRegExp
 * @returns {String}
 */
function inject(targetContent, sourceContent, opt, tagsRegExp){
	const startTag = tagsRegExp.start;
  const endTag = tagsRegExp.end;
  let startMatch;
	let endMatch;

	while ((startMatch = startTag.exec(targetContent)) !== null) {
		// Take care of content length change
		endTag.lastIndex = startTag.lastIndex;
		endMatch = endTag.exec(targetContent);
		if (!endMatch) {
			throw error('Missing end tag for start tag: ' + startMatch[0]);
		}
		const toInject = [sourceContent];
		// content part before start tag
		let newContent = targetContent.slice(0, startMatch.index);

		if (opt.removeTags) {
			// Take care of content length change
			startTag.lastIndex -= startMatch[0].length;
		} else {
			// <startMatch> + partial body + <endMatch>
			toInject.unshift(startMatch[0]);
			toInject.push(endMatch[0]);
		}
		const previousInnerContent = targetContent.substring(startTag.lastIndex, endMatch.index);
		const indent = getLeadingWhitespace(previousInnerContent);
		// add new content
		newContent += toInject.join(indent);
		// append rest of target file
		newContent += targetContent.slice(endTag.lastIndex);
		// replace old content with new
		targetContent = newContent;
	}
	startTag.lastIndex = 0;
	endTag.lastIndex = 0;
	return targetContent;
}

/**
 * Prepare regular expressions for parsing template
 * Replace {{path}} with regular expression for matching relative path
 * or with exact file path
 *
 * @param {Object} opt
 * @param {String} fileUrl
 * @returns {Object}
 */
function getRegExpTags(opt, fileUrl) {
	function parseTag(tag, replacement) {
		return new RegExp(escapeStringRegexp(tag).replace(PATH_REGEX, replacement || FILE_PATH_REGEX), 'g');
	}

	if (fileUrl) {
		return {
			start: parseTag(opt.start, fileUrl),
			end: parseTag(opt.end, fileUrl)
		}
	}
	return {
		start: parseTag(opt.start),
		startex: parseTag(opt.start, "(.+)"),
		end: parseTag(opt.end)
	}
}

/**
 * Parse content and get all partials to be injected
 * @param {String} content
 * @param {String} targetPath
 * @param {Object} opt
 * @param {Object} tagsRegExp
 * @returns {Array}
 */
function extractFilePaths(content, targetPath, opt, tagsRegExp) {
	const files = [];

	const tagMatches = content.match(tagsRegExp.start);
	if (tagMatches) {
		tagMatches.forEach(function(tagMatch){
			const fileUrl = tagsRegExp.startex.exec(tagMatch)[1];
			const filePath = setFullPath(targetPath, opt.prefix + fileUrl);
			try {
				const fileContent = stripBomBuf(fs.readFileSync(filePath));
				files.push({
					file: new File({
						path: filePath,
						cwd: __dirname,
						base: path.resolve(__dirname, 'expected', path.dirname(filePath)),
						contents: fileContent
					}),
					tags: getRegExpTags(opt, fileUrl)
				});
			} catch (e) {
			  if (opt.ignoreError) {
          log(colors.red(filePath + ' not found.'));
        } else {
          throw error(filePath + ' not found.');
        }
			}
			// reset the regex
			tagsRegExp.startex.lastIndex = 0;
		});
	}
	return files;
}

/////////////////////////////////////
// HELPER FUNCTIONS
/////////////////////////////////////
/**
 * @param str
 * @returns {*}
 */
function getLeadingWhitespace(str) {
	return str.match(LEADING_WHITESPACE_REGEXP)[0];
}

/**
 * @param options
 * @param prop
 * @param defaultValue
 * @returns {*}
 */
function defaults(options, prop, defaultValue) {
	return options[prop] || defaultValue;
}

/**
 * @param options
 * @param prop
 * @param defaultVal
 * @returns {boolean}
 */
function bool(options, prop, defaultVal) {
	return typeof options[prop] === 'undefined' ? defaultVal : Boolean(options[prop]);
}

/**
 * @param message
 * @returns {*}
 */
function error(message) {
	return new PluginError(PLUGIN_NAME, message);
}

/**
 * @param message
 */
function log(message) {
	fancyLog(colors.magenta(PLUGIN_NAME), message);
}

/**
 * @param targetPath
 * @param file
 */
function setFullPath(targetPath, file) {
	const base = path.dirname(targetPath);

	return path.resolve(base, file);
}
<commit_msg>chore: code style update<commit_after>'use strict';

const through = require('through2');
const PluginError = require('plugin-error');
const fancyLog = require('fancy-log');
const colors = require('ansi-colors');
const File = require('vinyl');
const path = require('path');
const fs = require('fs');
const stripBomBuf = require('strip-bom-buf');
const escapeStringRegexp = require('escape-string-regexp');

/**
 * Constants
 */
const PLUGIN_NAME = 'gulp-inject-partials';
const DEFAULT_START = '<!-- partial:{{path}} -->';
const DEFAULT_END = '<!-- partial -->';
const FILE_PATH_REGEX = "((\/|\\.\/)?((\\.\\.\/)+)?((\\w|\\-)(\\.(\\w|\\-))?)+((\/((\\w|\\-)(\\.(\\w|\\-))?)+)+)?)";
const PATH_REGEX = /\\{\\{path\\}\\}/; // ugly I know
const LEADING_WHITESPACE_REGEXP = /^\s*/;

module.exports = function (opt) {
	opt = opt || {};

	opt.start = defaults(opt, 'start', DEFAULT_START);
	opt.end = defaults(opt, 'end', DEFAULT_END);
	opt.removeTags = bool(opt, 'removeTags', false);
	opt.quiet = bool(opt, 'quiet', false);
	opt.prefix = defaults(opt, 'prefix', '');
	opt.ignoreError = bool(opt, 'ignoreError', false);

  /**
   * Handle injection of files
   * @param target
   * @param encoding
   * @param cb
   * @returns {*}
   */
	function handleStream(target, encoding, cb) {
		if (target.isNull()) {
			return cb(null, target);
		}

		if (target.isStream()) {
			return cb(error(target.path + ': Streams not supported for target templates!'));
		}

		try {
			const tagsRegExp = getRegExpTags(opt, null);
			target.contents = processContent(target, opt, tagsRegExp, [target.path]);
			this.push(target);
			return cb();
		} catch (err) {
			this.emit('error', err);
			return cb();
		}
	}

	return through.obj(handleStream);
};

/**
 * Parse content and create new template
 * with all injections made
 *
 * @param {Object} target
 * @param {Object} opt
 * @param {Object} tagsRegExp
 * @param {Array} listOfFiles
 * @returns {Buffer}
 */
function processContent(target, opt, tagsRegExp, listOfFiles) {
	let targetContent = String(target.contents);
	const targetPath = target.path;
	const files = extractFilePaths(targetContent, targetPath, opt, tagsRegExp);

	// recursively process files
	files.forEach(function (fileData) {
		if (listOfFiles.indexOf(fileData.file.path) !== -1) {
			throw error("Circular definition found. File: " + fileData.file.path + " referenced in a child file.");
		}
		listOfFiles.push(fileData.file.path);
		const content = processContent(fileData.file, opt, tagsRegExp, listOfFiles);
		listOfFiles.pop();

		targetContent = inject(targetContent, String(content), opt, fileData.tags);
	});
	if (listOfFiles.length === 1 && !opt.quiet && files.length) {
		log(
			colors.cyan(files.length.toString()) +
			' partials injected into ' +
			colors.magenta(targetPath) +
			'.');
	}
	return new Buffer.from(targetContent);
}

/**
 * Inject tags into target content between given
 * start and end tags
 *
 * @param {String} targetContent
 * @param {String} sourceContent
 * @param {Object} opt
 * @param {Object} tagsRegExp
 * @returns {String}
 */
function inject(targetContent, sourceContent, opt, tagsRegExp) {
	const startTag = tagsRegExp.start;
	const endTag = tagsRegExp.end;
	let startMatch;
	let endMatch;

	while ((startMatch = startTag.exec(targetContent)) !== null) {
		// Take care of content length change
		endTag.lastIndex = startTag.lastIndex;
		endMatch = endTag.exec(targetContent);
		if (!endMatch) {
			throw error('Missing end tag for start tag: ' + startMatch[0]);
		}
		const toInject = [sourceContent];
		// content part before start tag
		let newContent = targetContent.slice(0, startMatch.index);

		if (opt.removeTags) {
			// Take care of content length change
			startTag.lastIndex -= startMatch[0].length;
		} else {
			// <startMatch> + partial body + <endMatch>
			toInject.unshift(startMatch[0]);
			toInject.push(endMatch[0]);
		}
		const previousInnerContent = targetContent.substring(startTag.lastIndex, endMatch.index);
		const indent = getLeadingWhitespace(previousInnerContent);
		// add new content
		newContent += toInject.join(indent);
		// append rest of target file
		newContent += targetContent.slice(endTag.lastIndex);
		// replace old content with new
		targetContent = newContent;
	}
	startTag.lastIndex = 0;
	endTag.lastIndex = 0;
	return targetContent;
}

/**
 * Prepare regular expressions for parsing template
 * Replace {{path}} with regular expression for matching relative path
 * or with exact file path
 *
 * @param {Object} opt
 * @param {String} fileUrl
 * @returns {Object}
 */
function getRegExpTags(opt, fileUrl) {
	function parseTag(tag, replacement) {
		return new RegExp(escapeStringRegexp(tag).replace(PATH_REGEX, replacement || FILE_PATH_REGEX), 'g');
	}

	if (fileUrl) {
		return {
			start: parseTag(opt.start, fileUrl),
			end: parseTag(opt.end, fileUrl)
		}
	}
	return {
		start: parseTag(opt.start),
		startex: parseTag(opt.start, "(.+)"),
		end: parseTag(opt.end)
	}
}

/**
 * Parse content and get all partials to be injected
 * @param {String} content
 * @param {String} targetPath
 * @param {Object} opt
 * @param {Object} tagsRegExp
 * @returns {Array}
 */
function extractFilePaths(content, targetPath, opt, tagsRegExp) {
	const files = [];

	const tagMatches = content.match(tagsRegExp.start);
	if (tagMatches) {
		tagMatches.forEach(function (tagMatch) {
			const fileUrl = tagsRegExp.startex.exec(tagMatch)[1];
			const filePath = setFullPath(targetPath, opt.prefix + fileUrl);
			try {
				const fileContent = stripBomBuf(fs.readFileSync(filePath));
				files.push({
					file: new File({
						path: filePath,
						cwd: __dirname,
						base: path.resolve(__dirname, 'expected', path.dirname(filePath)),
						contents: fileContent
					}),
					tags: getRegExpTags(opt, fileUrl)
				});
			} catch (e) {
				if (opt.ignoreError) {
					log(colors.red(filePath + ' not found.'));
				} else {
					throw error(filePath + ' not found.');
				}
			}
			// reset the regex
			tagsRegExp.startex.lastIndex = 0;
		});
	}
	return files;
}

/////////////////////////////////////
// HELPER FUNCTIONS
/////////////////////////////////////
/**
 * @param str
 * @returns {*}
 */
function getLeadingWhitespace(str) {
	return str.match(LEADING_WHITESPACE_REGEXP)[0];
}

/**
 * @param options
 * @param prop
 * @param defaultValue
 * @returns {*}
 */
function defaults(options, prop, defaultValue) {
	return options[prop] || defaultValue;
}

/**
 * @param options
 * @param prop
 * @param defaultVal
 * @returns {boolean}
 */
function bool(options, prop, defaultVal) {
	return typeof options[prop] === 'undefined' ? defaultVal : Boolean(options[prop]);
}

/**
 * @param message
 * @returns {*}
 */
function error(message) {
	return new PluginError(PLUGIN_NAME, message);
}

/**
 * @param message
 */
function log(message) {
	fancyLog(colors.magenta(PLUGIN_NAME), message);
}

/**
 * @param targetPath
 * @param file
 */
function setFullPath(targetPath, file) {
	const base = path.dirname(targetPath);

	return path.resolve(base, file);
}
<|endoftext|>


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

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      app: {
        src: ['src/client/app/js/*.js'],
        dest: 'dist/client/app/js/app.js'
      },
      lib: {
        src: ['src/client/app/bower_components/angular/angular.js',
              'src/client/app/bower_components/angular-route/angular-route.js',
              'src/client/app/bower_components/angular-cookies/angular-cookies.js',
              'src/client/app/bower_components/angular-resource/angular-resource.js',
              'src/client/app/bower_components/autofill-event/src/autofill-event.js'],
        dest: 'dist/client/app/js/lib.js'
      }
    },
    uglify: {
      app: {
        files: {'dist/client/app/js/app.min.js': ['dist/client/app/js/app.js']}
      },
      lib: {
        files: {'dist/client/app/js/lib.min.js': ['dist/client/app/js/lib.js']}
      }
    },
    copy: {
      app: {
        files: [
          { expand: true, src: 'src/client/app/*', dest: 'dist/client/app/', filter: 'isFile', flatten: true },
          { expand: true, cwd: 'src/client/app/', src: 'partials/*', dest: 'dist/client/app/' }
        ]
      }
    },
    sass: {
      dev: {
        options: {
          includePaths: ['bower_components/foundation/scss']
        },
        files: {
          'dist/client/app/css/app.css': 'src/client/app/sass/app.sass',
          'dist/client/app/css/theme.css': 'src/client/app/sass/theme.sass'
        }
      },
      deploy: {
        options: {
          includePaths: ['bower_components/foundation/scss'],
          outputStyle: 'compressed'
        },
        files: {
          'dist/client/app/css/app.min.css': 'src/client/app/sass/app.sass',
          'dist/client/app/css/theme.min.css': 'src/client/app/sass/theme.sass'
        }
      }
    }
  });

  // Load the plugin that provides the "concat" task.
  grunt.loadNpmTasks('grunt-contrib-concat');
  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');
  // Load the plugin that provides the "copy" task.
  grunt.loadNpmTasks('grunt-contrib-copy');
  // Load the plugin that provides the "sass" task.
  grunt.loadNpmTasks('grunt-sass');

  // Default task(s).
  grunt.registerTask('default', ['concat', 'uglify', 'copy', 'sass']);

};
<commit_msg>Add all the CSS minifying directives for the dependencies. That way the HTML will only need to contain a single minified directive for all dependencies.<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      app: {
        src: ['src/client/app/js/*.js'],
        dest: 'dist/client/app/js/app.js'
      },
      lib: {
        src: ['src/client/app/bower_components/angular/angular.js',
              'src/client/app/bower_components/angular-route/angular-route.js',
              'src/client/app/bower_components/angular-cookies/angular-cookies.js',
              'src/client/app/bower_components/angular-resource/angular-resource.js',
              'src/client/app/bower_components/autofill-event/src/autofill-event.js'],
        dest: 'dist/client/app/js/lib.js'
      }
    },
    uglify: {
      app: {
        files: {'dist/client/app/js/app.min.js': ['dist/client/app/js/app.js']}
      },
      lib: {
        files: {'dist/client/app/js/lib.min.js': ['dist/client/app/js/lib.js']}
      }
    },
    copy: {
      app: {
        files: [
          { expand: true, src: 'src/client/app/*', dest: 'dist/client/app/', filter: 'isFile', flatten: true },
          { expand: true, cwd: 'src/client/app/', src: 'partials/*', dest: 'dist/client/app/' }
        ]
      }
    },
    sass: {
      dev: {
        options: {
          includePaths: ['bower_components/foundation/scss']
        },
        files: {
          'dist/client/app/css/app.css': 'src/client/app/sass/app.sass',
          'dist/client/app/css/theme.css': 'src/client/app/sass/theme.sass'
        }
      },
      deploy: {
        options: {
          includePaths: ['bower_components/foundation/scss'],
          outputStyle: 'compressed'
        },
        files: {
          'dist/client/app/css/app.min.css': 'src/client/app/sass/app.sass',
          'dist/client/app/css/theme.min.css': 'src/client/app/sass/theme.sass'
        }
      }
    },
    cssmin: {
      combine: {
        files: {
          'dist/client/app/css/stylesheets.css': [
            'src/client/app/bower_components/html5-boilerplate/css/normalize.css',
            'src/client/app/bower_components/html5-boilerplate/css/main.css',
            'src/client/app/bower_components/bootstrap/dist/css/bootstrap.css',
            'src/client/app/bower_components/bootstrap/dist/css/bootstrap-theme.css',
          ]
        }
      },
      minify: {
        expand: true,
        cwd: 'dist/client/app/css',
        src: ['*.css', '!*.min.css'],
        dest: 'dist/client/app/css',
        ext: '.min.css'
      }
    }
  });

  // Load the plugin that provides the "concat" task.
  grunt.loadNpmTasks('grunt-contrib-concat');
  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');
  // Load the plugin that provides the "copy" task.
  grunt.loadNpmTasks('grunt-contrib-copy');
  // Load the plugin that provides the "sass" task.
  grunt.loadNpmTasks('grunt-sass');
  // Load the plugin that provides the "cssmin" task.
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  // Default task(s).
  grunt.registerTask('default', ['concat', 'uglify', 'copy', 'sass', 'cssmin']);

};
<|endoftext|>


<commit_before>
module.exports = function(grunt) {
  grunt.initConfig({
    jshint: {
      options : {
        jshintrc : '.jshintrc'
      },
      all : ['tests/*.js', 'Gruntfile.js']
    },
    watch: {
      scripts: {
        files: ['tests/generation/template.js'],
        tasks: ['run'],
        options: {
          spawn: false,
        },
      },
    },
    batch_git_clone: {
      TodoMVC: {
        options: {
          configFile:"Git2Clone.json",
          npmInstall:true,
          bowerInstall:true,
          overWrite:true
        },
      },
    },
    run: {
      master: {
        cmd: 'tests/generation/generate.sh'
      },
      masterClean: {
        cmd: 'tests/generation/generate-clean.sh'
      },
      tag130: {
        cmd: 'tests/generation/generate-1.3.0.sh'
      },
      tag130Clean: {
        cmd: 'tests/generation/template-1.3.0-clean.sh'
      },
      checkout130:{
        cmd: 'tests/generation/checkout.sh',
        args: [
          '--130'
        ]
      },
      checkoutMaster:{
        cmd: 'tests/generation/checkout.sh',
        args: [
          '--master'
        ]
      },
    },
    clean: {
      tests: ["tests/test_*.js", "!tests/basicTest.js", "!tests/advancedTest.js"],
      cleaners: ["tests/clean_*.js"],
      results: ["tests/results"],
    },
    casper: {
      options: {
        test: true,
        parallel : false,
        concurrency : 1,
        'log-level' : 'error',
        'fail-fast' : false,
        concise : false,
        engine : 'phantomjs'
      },
      cleanFramework: {
        src: ['tests/clean_*.js'],
      },
      basicTest: {
        src: ['tests/basicTest.js']
      },
      basicTest_sljs: {
        options: {
          engine : 'slimerjs'
        },
        src: ['tests/basicTest.js']
      },
      advancedTest: {
        src: ['tests/test_*.js'],
        //https://github.com/iamchrismiller/grunt-casper/issues/68
        //dest : function(input) {
        //  var str = input.replace('tests/', '');
        //  return 'tests/results/'+str.replace(/\.js$/,'phs.xml');
        //}
      },
      advancedTest_sljs: {
        options: {
          engine : 'slimerjs'
        },
        src: ['tests/test_*.js'],
        //https://github.com/iamchrismiller/grunt-casper/issues/68
        //dest : function(input) {
        //  var str = input.replace('tests/', '');
        //  return 'tests/results/'+str.replace(/\.js$/,'sljs.xml');
        //}
      },
    },
    availabletasks: {
      tasks: {
        options: {
            filter: 'exclude',
            tasks: ['casper', 'batch_git_clone', 'clean', 'default', 'jshint', 'run', 'stop', 'verify', 'wait', 'watch', 'availabletasks']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-batch-git-clone');
  grunt.loadNpmTasks('grunt-run');
  grunt.loadNpmTasks('grunt-casper');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-available-tasks');

  //Setup
  grunt.registerTask('default', ['availabletasks']);
  grunt.registerTask('setup', 'Setup TodoMVC App. and generate Tests [master]',['batch_git_clone', 'run:checkoutMaster']);
  grunt.registerTask('generate-master', 'Generate Tests for master branch', ['clean:tests', 'clean:results', 'run:checkoutMaster', 'run:master']);
  grunt.registerTask('generate-130', 'Generate Tests for 1.3.0 tag', ['clean:tests', 'clean:results', 'run:checkout130', 'run:tag130']);
  grunt.registerTask('generate-clean', 'Generate todos cleaner', ['run:masterClean']);
  grunt.registerTask('generate-130-clean', 'Generate todos cleaner', ['run:tag130Clean']);
  //Clean
  grunt.registerTask('clean-all', 'Delete all tests and results', ['casper:cleanFramework', 'clean:tests', 'clean:cleaners', 'clean:results']);
  grunt.registerTask('clean-tests', 'Delete all tests',['clean:tests']);
  grunt.registerTask('clean-results', 'Delete all results',['clean:results']);
  grunt.registerTask('clean-todo', 'Delete all todos', ['casper:cleanFramework']);
  //Test
  //grunt.registerTask('test-basic-phjs', 'Launch basic test with PhantomJS',['casper:basicTest']);
  //grunt.registerTask('test-basic-sljs', 'Launch basic test with SlimerJS',['casper:basicTest_sljs']);
  grunt.registerTask('test-advanced-phjs', 'Launch all test with PhantomJS',['casper:advancedTest']);
  grunt.registerTask('test-advanced-sljs', 'Launch all test with SlimerJS',['casper:advancedTest_sljs']);
  //Other
  grunt.registerTask('verify', ['jshint']);
};
<commit_msg>Fix Gruntfile<commit_after>
module.exports = function(grunt) {
  grunt.initConfig({
    jshint: {
      options : {
        jshintrc : '.jshintrc'
      },
      all : ['tests/*.js', 'Gruntfile.js']
    },
    watch: {
      scripts: {
        files: ['tests/generation/template.js'],
        tasks: ['run'],
        options: {
          spawn: false,
        },
      },
    },
    batch_git_clone: {
      TodoMVC: {
        options: {
          configFile:"Git2Clone.json",
          npmInstall:true,
          bowerInstall:true,
          overWrite:true
        },
      },
    },
    run: {
      master: {
        cmd: 'tests/generation/generate.sh'
      },
      masterClean: {
        cmd: 'tests/generation/generate-clean.sh'
      },
      tag130: {
        cmd: 'tests/generation/generate-1.3.0.sh'
      },
      tag130Clean: {
        cmd: 'tests/generation/template-1.3.0-clean.sh'
      },
      checkout130:{
        cmd: 'tests/generation/checkout.sh',
        args: [
          '--130'
        ]
      },
      checkoutMaster:{
        cmd: 'tests/generation/checkout.sh',
        args: [
          '--master'
        ]
      },
    },
    clean: {
      tests: ["tests/test_*.js", "!tests/basicTest.js", "!tests/advancedTest.js"],
      cleaners: ["tests/clean_*.js"],
      results: ["tests/results"],
    },
    casper: {
      options: {
        test: true,
        parallel : false,
        concurrency : 1,
        'log-level' : 'error',
        'fail-fast' : false,
        concise : false,
        engine : 'phantomjs'
      },
      cleanFramework: {
        src: ['tests/clean_*.js'],
      },
      basicTest: {
        src: ['tests/basicTest.js']
      },
      basicTest_sljs: {
        options: {
          engine : 'slimerjs'
        },
        src: ['tests/basicTest.js']
      },
      advancedTest: {
        src: ['tests/test_*.js'],
        //https://github.com/iamchrismiller/grunt-casper/issues/68
        //dest : function(input) {
        //  var str = input.replace('tests/', '');
        //  return 'tests/results/'+str.replace(/\.js$/,'phs.xml');
        //}
      },
      advancedTest_sljs: {
        options: {
          engine : 'slimerjs'
        },
        src: ['tests/test_*.js'],
        //https://github.com/iamchrismiller/grunt-casper/issues/68
        //dest : function(input) {
        //  var str = input.replace('tests/', '');
        //  return 'tests/results/'+str.replace(/\.js$/,'sljs.xml');
        //}
      },
    },
    availabletasks: {
      tasks: {
        options: {
            filter: 'exclude',
            tasks: ['casper', 'batch_git_clone', 'clean', 'default', 'jshint', 'run', 'stop', 'verify', 'wait', 'watch', 'availabletasks']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-batch-git-clone');
  grunt.loadNpmTasks('grunt-run');
  grunt.loadNpmTasks('grunt-casper');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-available-tasks');

  //Setup
  grunt.registerTask('default', ['availabletasks']);
  grunt.registerTask('setup', 'Setup TodoMVC App. and generate Tests [master]',['batch_git_clone', 'run:checkoutMaster']);
  grunt.registerTask('generate-master', 'Generate Tests for master branch', ['clean:tests', 'clean:results', 'run:checkoutMaster', 'run:master']);
  grunt.registerTask('generate-130', 'Generate Tests for 1.3.0 tag', ['clean:tests', 'clean:results', 'run:checkout130', 'run:tag130']);
  grunt.registerTask('generate-clean', 'Generate todos cleaner', ['run:masterClean']);
  grunt.registerTask('generate-130-clean', 'Generate todos cleaner', ['run:tag130Clean']);
  //Clean
  grunt.registerTask('clean-all', 'Delete all tests and results', ['clean:tests', 'clean:cleaners', 'clean:results']);
  grunt.registerTask('clean-tests', 'Delete all tests',['clean:tests']);
  grunt.registerTask('clean-results', 'Delete all results',['clean:results']);
  grunt.registerTask('clean-todo', 'Delete all todos', ['casper:cleanFramework']);
  //Test
  //grunt.registerTask('test-basic-phjs', 'Launch basic test with PhantomJS',['casper:basicTest']);
  //grunt.registerTask('test-basic-sljs', 'Launch basic test with SlimerJS',['casper:basicTest_sljs']);
  grunt.registerTask('test-advanced-phjs', 'Launch all test with PhantomJS',['casper:advancedTest']);
  grunt.registerTask('test-advanced-sljs', 'Launch all test with SlimerJS',['casper:advancedTest_sljs']);
  //Other
  grunt.registerTask('verify', ['jshint']);
};
<|endoftext|>


<commit_before>/* global window */

'use strict';

var React = require('react');
var assign = require('object-assign');
var omit = require('lodash.omit');
var mediaQuery = require('./mediaQuery');
var toQuery = require('./toQuery');
var matchMedia = typeof window !== 'undefined' ? window.matchMedia : null;

var defaultTypes = {
  component: React.PropTypes.func,
  query: React.PropTypes.string
};
var mediaKeys = Object.keys(mediaQuery.all);
var excludedQueryKeys = Object.keys(defaultTypes);
var excludedPropKeys = excludedQueryKeys.concat(mediaKeys);

var mq = React.createClass({
  displayName: 'MediaQuery',
  propTypes: types,

  getDefaultProps: function(){
    return {
      component: React.DOM.div
    };
  },

  getInitialState: function(){
    return {
      matches: false
    };
  },

  componentWillMount: function(){
    this.updateQuery(this.props);
  },

  componentWillReceiveProps: function(props){
    this.updateQuery(props);
  },

  updateQuery: function(props){
    if (props.query) {
      this.query = props.query;
    } else {
      this.query = toQuery(omit(props, excludedQueryKeys));
    }

    if (!this.query) {
      throw new Error('Invalid or missing MediaQuery!');
    }
    this._mql = matchMedia(this.query);
    this._mql.addListener(this.updateMatches);
    this.updateMatches();
  },

  componentWillUnmount: function(){
    this._mql.removeListener(this.updateMatches);
  },

  updateMatches: function(){
    if (this._mql.matches === this.state.matches) {
      return;
    }
    this.setState({
      matches: this._mql.matches
    });
  },

  render: function(){
    if (this.state.matches === false) {
      return null;
    }
    var props = omit(this.props, excludedPropKeys);
    return this.props.component(props, this.props.children);
  }
});

module.exports = mq;
<commit_msg>remove propTypes: types<commit_after>/* global window */

'use strict';

var React = require('react');
var assign = require('object-assign');
var omit = require('lodash.omit');
var mediaQuery = require('./mediaQuery');
var toQuery = require('./toQuery');
var matchMedia = typeof window !== 'undefined' ? window.matchMedia : null;

var defaultTypes = {
  component: React.PropTypes.func,
  query: React.PropTypes.string
};
var mediaKeys = Object.keys(mediaQuery.all);
var excludedQueryKeys = Object.keys(defaultTypes);
var excludedPropKeys = excludedQueryKeys.concat(mediaKeys);

var mq = React.createClass({
  displayName: 'MediaQuery'

  getDefaultProps: function(){
    return {
      component: React.DOM.div
    };
  },

  getInitialState: function(){
    return {
      matches: false
    };
  },

  componentWillMount: function(){
    this.updateQuery(this.props);
  },

  componentWillReceiveProps: function(props){
    this.updateQuery(props);
  },

  updateQuery: function(props){
    if (props.query) {
      this.query = props.query;
    } else {
      this.query = toQuery(omit(props, excludedQueryKeys));
    }

    if (!this.query) {
      throw new Error('Invalid or missing MediaQuery!');
    }
    this._mql = matchMedia(this.query);
    this._mql.addListener(this.updateMatches);
    this.updateMatches();
  },

  componentWillUnmount: function(){
    this._mql.removeListener(this.updateMatches);
  },

  updateMatches: function(){
    if (this._mql.matches === this.state.matches) {
      return;
    }
    this.setState({
      matches: this._mql.matches
    });
  },

  render: function(){
    if (this.state.matches === false) {
      return null;
    }
    var props = omit(this.props, excludedPropKeys);
    return this.props.component(props, this.props.children);
  }
});

module.exports = mq;
<|endoftext|>


<commit_before>/**
 * Follow RSS feeds and publish new articles to channels.
 */

"use strict";

let EventEmitter = require("events");
let FeedParser = require("feedparser");
let request = require("request");
let urllib = require("url");
let util = require("util");
let proxy = require("../core/proxy");

exports.configure = function(connection) {
  let feeds = new FeedManager(connection, connection.config.modules.feeds);
  feeds.watch();
  return feeds;
};

class FeedManager {
  constructor(connection, config) {
    this.connection = connection;
    this.config = config;
    this.events = new EventEmitter;
    this.queue = [];
    this.timers = {
      refresh: null,
      publish: null,
    };
    this.feeds = this.config.sources || [];
  }

  watch() {
    if (this.isWatching) {
      console.error("FeedManager is already running.");
      return false;
    }
    this.refresh();
    this.timers.refresh = setInterval(proxy(this.refresh, this), this.refreshInterval * 1000);
    this.timers.publish = setInterval(proxy(this.publishNext, this), this.publishInterval * 1000);
  }

  stop() {
    if (this.isWatching) {
      clearInterval(this.timers.refresh);
      clearInterval(this.timers.publish);

      this.timers = {
        refresh: null,
        publish: null,
      };
    }
  }

  refresh() {
    return new Promise((resolve, reject) => {
      let now = new Date;

      this.feeds.forEach(feed => {
        if (now - feed.updated >= this.refreshInterval) {
          feed.refresh();
        }
      });
    }, error => {
      console.error("feeds:", error.stack);
    });
  }

  enqueue(article) {
    this.queue.push(article);
  }

  publishNext() {
    if (this.queue.length) {
      let article = this.queue.shift();
      let message = this.formatArticle(article);
      this.connection.amsg(message);
    }
  }

  stripQueryVariables(url) {
    let data = urllib.parse(url, true);
    delete data.search;
    Object.keys(data.query).forEach(key => {
      if (Number.isNaN(data.query[key])) {
        delete data.query[key];
      }
    });
    return urllib.format(data);
  }

  formatArticle(article) {
    let link = this.stripQueryVariables(article.link);
    return util.format("[%s] %s - %s",
      article.source.toUpperCase().replace(/\W/, ""),
      article.title,
      link);
  }

  get isWatching() {
    return this.timers.refresh != null;
  }

  get refreshInterval() {
    return this.config.refresh;
  }

  get publishInterval() {
    return this.config.publish;
  }

  get feeds() {
    return this._feeds;
  }

  set feeds(sources) {
    this._feeds = [];
    sources.forEach(source => {
      let feed = new Feed(source);
      this._feeds.push(feed);

      feed.on("article", item => {
        this.enqueue(item);
      });
    });
  }
}

class Feed {
  constructor(config) {
    this.config = config;
    this.events = new EventEmitter;
    this.updated = new Date;
    this.updated.setMinutes(this.updated.getMinutes() - 5);
    this.cache = new Map;
  }

  refresh() {
    process.nextTick(() => {
      let req = request(this.url);
      let parser = new FeedParser({feedurl: this.url});
      let updated = this.updated - 1000 * 60 * 30;
      this.updated = new Date;

      req.on("error", error => {
        console.error("feed.refresh:", error.stack);
      })

      req.on("response", res => {
        if (res.statusCode != 200) {
          return console.error("feed.refresh: invalid status code", res.statusCode);
        }
        req.pipe(parser);
      });

      parser.on("error", error => {
        console.error("feed.parser:", error.stack);
      })

      parser.on("readable", () => {
        let item;
        while (item = parser.read()) {
          let cache_key = item.title.substring(0, 30).toLowerCase();
          if (updated < item.pubDate && !this.cache.has(cache_key)) {
            this.events.emit("article", {
              source: this.name,
              title: item.title,
              date: item.pubDate,
              link: item.link,
            });
            this.cache.set(cache_key, new Date);
          }
        }
      });

      let cache_expiry = new Date;
      cache_expiry.setHours(cache_expiry.getHours() - 1);

      this.cache.forEach((expires, key) => {
        if (expires < cache_expiry) {
          this.cache.delete(key);
        }
      });
    });
  }

  on() {
    this.events.on.apply(this.events, arguments);
  }

  get name() {
    return this.config.name;
  }

  get url() {
    return this.config.url;
  }
}
<commit_msg>Another fucking fix<commit_after>/**
 * Follow RSS feeds and publish new articles to channels.
 */

"use strict";

let EventEmitter = require("events");
let FeedParser = require("feedparser");
let request = require("request");
let urllib = require("url");
let util = require("util");
let proxy = require("../core/proxy");

exports.configure = function(connection) {
  let feeds = new FeedManager(connection, connection.config.modules.feeds);
  feeds.watch();
  return feeds;
};

class FeedManager {
  constructor(connection, config) {
    this.connection = connection;
    this.config = config;
    this.events = new EventEmitter;
    this.queue = [];
    this.timers = {
      refresh: null,
      publish: null,
    };
    this.feeds = this.config.sources || [];
  }

  watch() {
    if (this.isWatching) {
      console.error("FeedManager is already running.");
      return false;
    }
    this.refresh();
    this.timers.refresh = setInterval(proxy(this.refresh, this), this.refreshInterval * 1000);
    this.timers.publish = setInterval(proxy(this.publishNext, this), this.publishInterval * 1000);
  }

  stop() {
    if (this.isWatching) {
      clearInterval(this.timers.refresh);
      clearInterval(this.timers.publish);

      this.timers = {
        refresh: null,
        publish: null,
      };
    }
  }

  refresh() {
    return new Promise((resolve, reject) => {
      let now = new Date;

      this.feeds.forEach(feed => {
        if (now - feed.updated >= this.refreshInterval) {
          feed.refresh();
        }
      });
    }, error => {
      console.error("feeds:", error.stack);
    });
  }

  enqueue(article) {
    this.queue.push(article);
  }

  publishNext() {
    if (this.queue.length) {
      let article = this.queue.shift();
      let message = this.formatArticle(article);
      this.connection.amsg(message);
    }
  }

  stripQueryVariables(url) {
    let data = urllib.parse(url, true);
    delete data.search;
    Object.keys(data.query).forEach(key => {
      if (isNaN(data.query[key])) {
        delete data.query[key];
      }
    });
    return urllib.format(data);
  }

  formatArticle(article) {
    let link = this.stripQueryVariables(article.link);
    return util.format("[%s] %s - %s",
      article.source.toUpperCase().replace(/\W/, ""),
      article.title,
      link);
  }

  get isWatching() {
    return this.timers.refresh != null;
  }

  get refreshInterval() {
    return this.config.refresh;
  }

  get publishInterval() {
    return this.config.publish;
  }

  get feeds() {
    return this._feeds;
  }

  set feeds(sources) {
    this._feeds = [];
    sources.forEach(source => {
      let feed = new Feed(source);
      this._feeds.push(feed);

      feed.on("article", item => {
        this.enqueue(item);
      });
    });
  }
}

class Feed {
  constructor(config) {
    this.config = config;
    this.events = new EventEmitter;
    this.updated = new Date;
    this.updated.setMinutes(this.updated.getMinutes() - 5);
    this.cache = new Map;
  }

  refresh() {
    process.nextTick(() => {
      let req = request(this.url);
      let parser = new FeedParser({feedurl: this.url});
      let updated = this.updated - 1000 * 60 * 30;
      this.updated = new Date;

      req.on("error", error => {
        console.error("feed.refresh:", error.stack);
      })

      req.on("response", res => {
        if (res.statusCode != 200) {
          return console.error("feed.refresh: invalid status code", res.statusCode);
        }
        req.pipe(parser);
      });

      parser.on("error", error => {
        console.error("feed.parser:", error.stack);
      })

      parser.on("readable", () => {
        let item;
        while (item = parser.read()) {
          let cache_key = item.title.substring(0, 30).toLowerCase();
          if (updated < item.pubDate && !this.cache.has(cache_key)) {
            this.events.emit("article", {
              source: this.name,
              title: item.title,
              date: item.pubDate,
              link: item.link,
            });
            this.cache.set(cache_key, new Date);
          }
        }
      });

      let cache_expiry = new Date;
      cache_expiry.setHours(cache_expiry.getHours() - 1);

      this.cache.forEach((expires, key) => {
        if (expires < cache_expiry) {
          this.cache.delete(key);
        }
      });
    });
  }

  on() {
    this.events.on.apply(this.events, arguments);
  }

  get name() {
    return this.config.name;
  }

  get url() {
    return this.config.url;
  }
}
<|endoftext|>


<commit_before>'use strict';
var pkgjson = require('./package.json');

var config = {
  pkg: pkgjson,
  dist: 'src/lib',
  bower:{
    directory : 'bower_components'
  }
}

module.exports = function (grunt) {

  // Configuration
  grunt.initConfig({
    config: config,
    pkg: config.pkg,
    bower: config.bower,
    concat: {
      options: {
        banner: '/*! <%= pkg.name %> lib concat files - v<%= pkg.version %> -' +
          '<%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      js: {
          src: [
            '<%= bower.directory %>/jquery/dist/jquery.min.js',
            '<%= bower.directory %>/underscore/underscore-min.js'
          ],
          dest: '<%= config.dist %>/js/lib.min.js',
      },
      css: {
          src: [
            '<%= bower.directory %>/bootstrap/dist/css/bootstrap.min.css',
            '<%= bower.directory %>/font-awesome/css/font-awesome.min.css'
          ],
          dest: '<%= config.dist %>/css/lib.min.css',
      }
    },
    copy: {
      fonts: {
       files: [{
         expand: true,
         cwd: '<%= bower.directory %>/bootstrap/dist',
         src: ['fonts/*'],
         dest: '<%= config.dist %>'
       },
       {
         expand: true,
         cwd: '<%= bower.directory %>/font-awesome',
         src: ['fonts/*'],
         dest: '<%= config.dist %>'
       }]
      },
      map : {
       files: [{
         expand: true,
         cwd: '<%= bower.directory %>/underscore',
         src: ['*.map'],
         dest: '<%= config.dist %>/js'
       }]
      }
    },
    watch: {
        jshint: {
            files: ['src/js/**/*.js'],
            tasks: ['jshint']
        },
        reload: {
            files: ['src/**/*.*'],
            options: {
                livereload: true
            }
        }
    },
    jshint: {
        all: ['src/js/**/*.js']
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> lib - v<%= pkg.version %> -' +
          '<%= grunt.template.today("yyyy-mm-dd") %> */'
      },
      build: {
        files: {
          '<%= config.dist %>/js/lib.min.js': [
            '<%= bower.directory %>/jquery/dist/jquery.js',
            '<%= bower.directory %>/underscore/underscore.js'
          ]
        }
      }
    }
  });

  //grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  grunt.registerTask('default', [
    'concat',
    'copy',
    'jshint',
    'watch',
    //'uglify'
  ]);

  grunt.registerTask('head', [
    'copy'
  ]);
};
<commit_msg>fix indent<commit_after>'use strict';
var pkgjson = require('./package.json');

var config = {
    pkg: pkgjson,
    dist: 'src/lib',
    bower:{
        directory : 'bower_components'
    }
}

module.exports = function (grunt) {

    // Configuration
    grunt.initConfig({
        config: config,
        pkg: config.pkg,
        bower: config.bower,
        concat: {
            options: {
                banner: '/*! <%= pkg.name %> lib concat files - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
            },
            js: {
                src: [
                '<%= bower.directory %>/jquery/dist/jquery.min.js',
                '<%= bower.directory %>/underscore/underscore-min.js'
                ],
                dest: '<%= config.dist %>/js/lib.min.js'
            },
            css: {
                src: [
                    '<%= bower.directory %>/bootstrap/dist/css/bootstrap.min.css',
                    '<%= bower.directory %>/font-awesome/css/font-awesome.min.css'
                ],
                dest: '<%= config.dist %>/css/lib.min.css'
            }
        },
        copy: {
            fonts: {
                files: [{
                    expand: true,
                    cwd: '<%= bower.directory %>/bootstrap/dist',
                    src: ['fonts/*'],
                    dest: '<%= config.dist %>'
                },
                {
                    expand: true,
                    cwd: '<%= bower.directory %>/font-awesome',
                    src: ['fonts/*'],
                    dest: '<%= config.dist %>'
                }]
            },
            map : {
                files: [{
                    expand: true,
                    cwd: '<%= bower.directory %>/underscore',
                    src: ['*.map'],
                    dest: '<%= config.dist %>/js'
                }]
            }
        },
        watch: {
            jshint: {
                files: ['src/js/**/*.js'],
                tasks: ['jshint']
            },
            reload: {
                files: ['src/**/*.*'],
                options: {
                    livereload: true
                }
            }
        },
        jshint: {
            all: ['src/js/**/*.js']
        },
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> lib - v<%= pkg.version %> -' + '<%= grunt.template.today("yyyy-mm-dd") %> */'
            },
            build: {
                files: {
                    '<%= config.dist %>/js/lib.min.js': [
                        '<%= bower.directory %>/jquery/dist/jquery.js',
                        '<%= bower.directory %>/underscore/underscore.js'
                    ]
                }
            }
        }
    });

    //grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-jshint');

    grunt.registerTask('default', [
        'concat',
        'copy',
        'jshint',
        'watch',
        //'uglify'
    ]);

    grunt.registerTask('head', [
        'copy'
    ]);
};
<|endoftext|>


<commit_before>/**
 * @param {Type}
 * @return {Type}
 */
import $ from 'jquery';
import {$window} from './selectors';

class FullScreener{
  constructor(){
    this.els = $("[data-fullscreener]");
    this.listners();
    this.setSizes();
  }

  setSizes(){
    let height = window.innerHeight;
    let width = window.innerWidth;
    this.els.map((index, el) =>{
      let _height = height;
      let _width = width;
      let _cur = $(el);
      // RATIOS for Video
      if(_cur.hasClass('fullscreen--ratioed')){
        if(window.innerWidth/window.innerHeight >= 1.777){
          _width = window.innerWidth;
          _height = parseInt(window.innerWidth*9/16);
        } else{
          _width = parseInt(window.innerHeight*16/9);
          _height = window.innerHeight
        }
      }

      // RATIOS for Offsets
      if(_cur.data().fullscreenoffset != null){
        let _offsetEls = _cur.data().fullscreenoffset.split(',');
        _offsetEls.map((index, _offsetEl)=>{
          _offsetEl = $(_offsetEl);
          let _offHeight = _offsetEl.height();
          if(_offsetEl.length && _offHeight < _height)
            _height -= _offHeight
        })
      }

      // if _cur.data().fullscreendisablemobile?
      //   if window.innerWidth <= Chabuad.MQ.medium
      //     _height = ''
      //     _width = ''
      //

      if(_cur.data().fullscreenminheight != null){
        let _minheightEl = _cur.find(_cur.data().fullscreenminheight);
        if(_minheightEl.length){
          _minheight = _minheightEl.height();
          _minheight += _minheight*0.45;
        }
        _cur.css('minHeight',_minheight);
      }

      let _setValues = {
        height: _height,
        width: _width
      }
      _cur.css(_setValues).attr(_setValues);

    })
  }
  refresh(){
    this.els = $("[data-fullscreener]");
    this.setSizes();
  }
  listners(){
    $window.on('resize',()=> this.setSizes());
    $window.on('FULLSCREENER:REFRESH',()=>this.refresh())
  }
}

let instance = new FullScreener()
export default instance;

<commit_msg>offset map<commit_after>/**
 * @param {Type}
 * @return {Type}
 */
import $ from 'jquery';
import {$window} from './selectors';

class FullScreener{
  constructor(){
    this.els = $("[data-fullscreener]");
    this.listners();
    this.setSizes();
  }

  setSizes(){
    let height = window.innerHeight;
    let width = window.innerWidth;
    this.els.map((index, el) =>{
      let _height = height;
      let _width = width;
      let _cur = $(el);
      // RATIOS for Video
      if(_cur.hasClass('fullscreen--ratioed')){
        if(window.innerWidth/window.innerHeight >= 1.777){
          _width = window.innerWidth;
          _height = parseInt(window.innerWidth*9/16);
        } else{
          _width = parseInt(window.innerHeight*16/9);
          _height = window.innerHeight
        }
      }

      // RATIOS for Offsets
      if(_cur.data().fullscreenoffset != null){
        let _offsetEls = _cur.data().fullscreenoffset.split(',');
        _offsetEls.map((_offsetEl,index)=>{
          _offsetEl = $(_offsetEl);
          let _offHeight = _offsetEl.height();
          if(_offsetEl.length && _offHeight < _height)
            _height -= _offHeight
        })
      }

      // if _cur.data().fullscreendisablemobile?
      //   if window.innerWidth <= Chabuad.MQ.medium
      //     _height = ''
      //     _width = ''
      //

      if(_cur.data().fullscreenminheight != null){
        let _minheightEl = _cur.find(_cur.data().fullscreenminheight);
        if(_minheightEl.length){
          _minheight = _minheightEl.height();
          _minheight += _minheight*0.45;
        }
        _cur.css('minHeight',_minheight);
      }

      let _setValues = {
        height: _height,
        width: _width
      }
      _cur.css(_setValues).attr(_setValues);

    })
  }
  refresh(){
    this.els = $("[data-fullscreener]");
    this.setSizes();
  }
  listners(){
    $window.on('resize',()=> this.setSizes());
    $window.on('FULLSCREENER:REFRESH',()=>this.refresh())
  }
}

let instance = new FullScreener()
export default instance;

<|endoftext|>


<commit_before>/*global module, process, require*/

"use strict";

var request = require("request");

module.exports = function(grunt) {
    var browsers = [
        {platform: "linux", browserName: "chrome", version: "36"},
        // {platform: "linux", browserName: "chrome", version: "35"},
        {platform: "linux", browserName: "firefox", version: "31"},
        // {platform: "linux", browserName: "firefox", version: "30"},
        // {platform: "linux", browserName: "firefox", version: "29"},
        {platform: "WIN8.1", browserName: "firefox", version: "31"},
        {platform: "WIN8.1", browserName: "chrome", version: "36"},
        {platform: "WIN8.1", browserName: "internet explorer", version: "11"},
        {platform: "WIN8", browserName: "internet explorer", version: "10"},
        // {platform: "WIN7", browserName: "internet explorer", version: "9"},
        {platform: "WIN7", browserName: "internet explorer", version: "10"},
        // {platform: "VISTA", browserName: "internet explorer", version: "9"},
        // {platform: "OS X 10.8", browserName: "safari", version: "6"},
        // {platform: "OS X 10.8", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "safari", version: "7"},
        // {platform: "OS X 10.9", browserName: "firefox", version: "28"},
        // {platform: "OS X 10.9", browserName: "firefox", version: "29"},
        {platform: "OS X 10.9", browserName: "firefox", version: "30"},
        {platform: "OS X 10.9", browserName: "iphone", version: "7.1"},
        {platform: "linux", browserName: "android", version: "4.3"},
        {platform: "linux", browserName: "android", version: "4.4"}
        ];

        grunt.initConfig({
            connect: {
                server: {
                    options: {
                        base: "",
                        port: 9999
                    }
                }
            },
            "saucelabs-jasmine": {
                all: {
                    options: {
                        urls: ["http://127.0.0.1:9999/jasmine/SpecRunner.html"],
                        tunnelTimeout: 30,
                        build: process.env.TRAVIS_JOB_ID,
                        concurrency: 3,
                        browsers: browsers,
                        capabilities: {
                            browserName: "chrome",
                            "chromeOptions":{
                                args: ["--test-type"]
                            }
                        },
                        testname: "js-sgp4lib Unit tests",
                        tags: ["master"],
                        sauceConfig: {
                            "video-upload-on-pass": false,
                            "idle-timeout": 600,
                            "max-duration": 1800,
                            "command-timeout": 600
                        },
                        onTestComplete: function(result, cb){
                         // returning undefined doesn't alter the test result
                         //   but returning true or false does.
                         //   See: https://github.com/axemclion/grunt-saucelabs

                        var user = process.env.SAUCE_USERNAME;
                        var pass = process.env.SAUCE_ACCESS_KEY;
                        request.put({
                            url: ["https://saucelabs.com/rest/v1", user, "jobs", result.job_id].join("/"),
                            auth: { user: user, pass: pass },
                            json: { passed: !result.passed }
                        }, function (error, response, body) {
                          if (error) {
                            cb(error);
                        } else if (response.statusCode !== 200) {
                            cb(new Error("Unexpected response status:" + response.statusCode));
                        } else {
                            cb(null, !result.passed);
                        }
                        body=body; // Shuts up JSHint
                    });
                        // if (result.passed === false) {
                        //     cb(null, true);
                        // } else {
                        //    cb(null,undefined);
                        // }
                    }
                }
            }
        },
        watch: {}
    });

    // Loading dependencies
    for (var key in grunt.file.readJSON("package.json").devDependencies) {
        if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
    }

    grunt.registerTask("dev", ["connect", "watch"]);
    grunt.registerTask("test", ["connect", "saucelabs-jasmine"]);
};
<commit_msg>Update test names for new repo name.<commit_after>/*global module, process, require*/

"use strict";

var request = require("request");

module.exports = function(grunt) {
    var browsers = [
        {platform: "linux", browserName: "chrome", version: "36"},
        // {platform: "linux", browserName: "chrome", version: "35"},
        {platform: "linux", browserName: "firefox", version: "31"},
        // {platform: "linux", browserName: "firefox", version: "30"},
        // {platform: "linux", browserName: "firefox", version: "29"},
        {platform: "WIN8.1", browserName: "firefox", version: "31"},
        {platform: "WIN8.1", browserName: "chrome", version: "36"},
        {platform: "WIN8.1", browserName: "internet explorer", version: "11"},
        {platform: "WIN8", browserName: "internet explorer", version: "10"},
        // {platform: "WIN7", browserName: "internet explorer", version: "9"},
        {platform: "WIN7", browserName: "internet explorer", version: "10"},
        // {platform: "VISTA", browserName: "internet explorer", version: "9"},
        // {platform: "OS X 10.8", browserName: "safari", version: "6"},
        // {platform: "OS X 10.8", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "safari", version: "7"},
        // {platform: "OS X 10.9", browserName: "firefox", version: "28"},
        // {platform: "OS X 10.9", browserName: "firefox", version: "29"},
        {platform: "OS X 10.9", browserName: "firefox", version: "30"},
        {platform: "OS X 10.9", browserName: "iphone", version: "7.1"},
        {platform: "linux", browserName: "android", version: "4.3"},
        {platform: "linux", browserName: "android", version: "4.4"}
        ];

        grunt.initConfig({
            connect: {
                server: {
                    options: {
                        base: "",
                        port: 9999
                    }
                }
            },
            "saucelabs-jasmine": {
                all: {
                    options: {
                        urls: ["http://127.0.0.1:9999/jasmine/SpecRunner.html"],
                        tunnelTimeout: 30,
                        build: process.env.TRAVIS_JOB_ID,
                        concurrency: 3,
                        browsers: browsers,
                        capabilities: {
                            browserName: "chrome",
                            "chromeOptions":{
                                args: ["--test-type"]
                            }
                        },
                        testname: "sgp4 Unit tests",
                        tags: ["master"],
                        sauceConfig: {
                            "video-upload-on-pass": false,
                            "idle-timeout": 600,
                            "max-duration": 1800,
                            "command-timeout": 600
                        },
                        onTestComplete: function(result, cb){
                         // returning undefined doesn't alter the test result
                         //   but returning true or false does.
                         //   See: https://github.com/axemclion/grunt-saucelabs

                        var user = process.env.SAUCE_USERNAME;
                        var pass = process.env.SAUCE_ACCESS_KEY;
                        request.put({
                            url: ["https://saucelabs.com/rest/v1", user, "jobs", result.job_id].join("/"),
                            auth: { user: user, pass: pass },
                            json: { passed: !result.passed }
                        }, function (error, response, body) {
                          if (error) {
                            cb(error);
                        } else if (response.statusCode !== 200) {
                            cb(new Error("Unexpected response status:" + response.statusCode));
                        } else {
                            cb(null, !result.passed);
                        }
                        body=body; // Shuts up JSHint
                    });
                        // if (result.passed === false) {
                        //     cb(null, true);
                        // } else {
                        //    cb(null,undefined);
                        // }
                    }
                }
            }
        },
        watch: {}
    });

    // Loading dependencies
    for (var key in grunt.file.readJSON("package.json").devDependencies) {
        if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
    }

    grunt.registerTask("dev", ["connect", "watch"]);
    grunt.registerTask("test", ["connect", "saucelabs-jasmine"]);
};
<|endoftext|>


<commit_before>import mitt from 'mitt'

export function createStore (initialState) {
  let state = initialState
  let events = mitt()

  return {
    on: events.on,
    off: events.off,
    emit (type, payload) {
      if (typeof type === 'function') return type(events.emit, this.state)
      events.emit(type, payload)
    },
    addReducer (reducer) {
      for (let type in reducer) {
        let handler
        if (type === '*') {
          handler = (eventType, e) => {
            this.state = reducer[type](this.state, e, eventType) || this.state
          }
        } else {
          handler = e => {
            this.state = reducer[type](this.state, e, type) || this.state
          }
        }

        events.on(type, handler)
      }
    },
    get state () {
      return state
    },
    set state (nextState) {
      state = nextState
    }
  }
}
<commit_msg>#9<commit_after>import mitt from 'mitt'

export function createStore (initialState) {
  let state = initialState
  let events = mitt()

  return {
    on: events.on,
    off: events.off,
    emit (type, payload) {
      if (typeof type === 'function') return type(events.emit, this.state)
      events.emit(type, payload)
    },
    addReducer (reducer) {
      for (let type in reducer) {
        let handler
        handler = (eventType, e) => {
          if (eventType.substring(0, 6) === 'store:') return
          this.state = reducer[type](this.state, e, eventType) || this.state
          events.emit('store:change', this.state)
        }
        if (type !== '*') {
          handler = handler.bind(null, type)
        }
        events.on(type, handler)
      }
    },
    get state () {
      return state
    },
    set state (nextState) {
      state = nextState
    }
  }
}
<|endoftext|>