<commit_before>var request = require('superagent');

module.exports = function(config){
    for(var param in ({user:1, apiKey:1, room:1}))
        if(!config.hasOwnProperty(param))
            throw 'Missing config parameter: ' + param;

    var DEFAULTS = {
        pingInterval: 2e3,
        pingTimeout: 30,
        autoReconnect: true,
        reconnectInterval: 30e3,
        debug: false
    };
    for(var param in DEFAULTS)
        if(!config.hasOwnProperty(param))
            config[param] = DEFAULTS[param];
    if(config.pingInterval < 2e3)
        throw 'Don\'t be a jerk.';

    /* private variables of interest */
    var apiVersion = 1,
    baseURL = 'http://www.icanhazchat.com/api.ashx?v=' + apiVersion,
    isConnected = false,
    keyedURL = '',
    cammers = {},
    listeners = {
        connect: [],
        disconnect: [],
        ping:[],
        message: [],
        pm: [],
        whisper: [],
        userJoin: [],
        userKick: [],
        userQuit: [],
        userCamUp: [],
        userCamDown: [],
        send:[],
        error: []
    },
    trigger = function(type, data){
        var modifiedData = {
            eventType: type
        };
        for(var x in data)
            if(x != 'eventType')
                modifiedData[x] = data[x];
        (listeners[type] || []).forEach(function(listener){
            listener.call(chain, modifiedData);
        });
    },
    error = function(message){
        if(listeners.error.length){
            trigger('error', {
                message: message
            });
        }
    },
    makeRequest = function(params, success, fail){
        var url = isConnected ? keyedURL : baseURL;
        for(var param in params)
            url += '&' + param + '=' + params[param];
        request.get(url).end(function(response){
            if(!response.ok){
                error('Request error: ' + response.text);
                fail && fail.call(chain);
                return;
            }
            if(config.debug)
                console.log(url + '\n' + response.text + '\n');
            var lines = response.text.split(/\n/),
                isOK = lines.shift();
            if(isOK != 'OK'){
                fail && fail.call(chain, isOK);
                return;
            }
            success && success.call(chain, lines);
            parseResponse.call(chain, lines);
       });
    },
    pingFailures = 0,
    intPing = -1,
    disconnect = function(){
        isConnected = false;
        clearInterval(intPing);
        keyedURL = '';
        if(config.autoReconnect){
            (function reconnect(){
                chain.connect(null, function(){
                    setTimeout(reconnect, reconnectInterval)
                });
            })();
        }
    },
    ping = function(){
        makeRequest({
            a: 'recv'
        }, function(){
            pingFailures = 0;
            trigger('ping');
        }, function(){
            if(++pingFailures == config.pingTimeout)
                disconnect();
        });
    },
    htmlEntityDecode = function(text){
        return text.replace(/&#(\d+);/g, function(entity, num){
            return String.fromCharCode(num);
        });
    }
    parseResponse = function(lines){
        lines.forEach(function(line){
            var r = /^\[([^\]]+)\]/,
            eventType = (line.match(/^\[([^\]]+)\]/) || [, 'message'])[1];
            line = line.replace(r, '');
            switch(eventType){
                case 'message':
                    var parse = line.match(/^.+\|(.*?)(\:)?\s(.+)/);
                    if(parse){
                        username = parse[1],
                        message = parse[3];
                        if(username){
                            trigger('message', {
                                username: username,
                                message: htmlEntityDecode(message),
                                emote: !!parse[2]
                            });
                        } else {
                            var parseMsg;
                            if(parseMsg = message.match(/(.+?) has kicked (.+?) from the room/)){
                                trigger('userKick', {
                                    username: parseMsg[2],
                                    kickedBy: parseMsg[1]
                                });
                            }
                        }
                    }
                    break;

                case 'msg':
                    var parse = line.match(/^.+\|(.+?)\|.+?\|(.+)/),
                    username = parse[1];
                    if(username != config.user){
                        trigger('whisper', {
                            username: username,
                            message: htmlEntityDecode(parse[2])
                        });
                    }
                    break;

                case 'priv':
                    var parse = line.match(/^.+\|(.+?)\|(.+)/);
                    if(!/\|from you to /.test(line)){
                        trigger('pm', {
                            username: parse[1],
                            message: htmlEntityDecode(parse[2])
                        });
                    }
                    break;

                case 'hi':
                    var rMod = /\*$/,
                        username = line.replace(rMod, '');
                    if(username != config.user){
                        trigger('userJoin',{
                            username: username,
                            mod: rMod.test(line)
                        });
                    }
                    break;

                case 'bye':
                    trigger('userQuit', {
                        username: line
                    });
                    break;

                case 'c+':
                    var parse = line.match(/1(.{12})(.+?)\./),
                    hash = parse[1],
                    username = parse[2];
                    cammers[hash] =  username;
                    trigger('userCamUp', {
                        username: username
                    });
                    break;

                case 'c-':
                    var username = cammers[line] || '';
                    delete cammers[line];
                    trigger('userCamDown', {
                        username: username
                    });
                    break;

                case '':
                    disconnect();
                    trigger('disconnect');
                    break;
            }
        });
    },
    chain = {
        /* command functions */

        connect: function(success, fail){
            if(isConnected)
                error('Already connected.');
            else {
                makeRequest({
                    u: config.user,
                    p: config.apiKey,
                    a: 'join',
                    w: config.room
                }, function(data){
                    isConnected = true;
                    keyedURL = baseURL + '&k=' + data[0];
                    intPing = setInterval(ping, config.pingInterval);
                    success && success.call(chain, data);
                    trigger('connect');
                }, function(data){
                    fail && fail.call(chain, data);
                });
            }
            return this;
        },

        send: function(message, success, fail){
            if(!message)
                error('No message.');
            else if(!isConnected)
                error('Not connected.');
            else {
                makeRequest({
                    a: 'send',
                    w: message
                }, success, fail);
                trigger('send', {
                    message: message
                });
            }
            return this;
        },

        whisper: function(username, message, success, fail){
            return this.send('/msg ' + username + ' ' + message, success, fail);
        },

        pm: function(username, message, success, fail){
            return this.send('/privmsg ' + username + ' ' + message, success, fail);
        },

        /* getter functions */
        /* I'll build these later
        getUsers: function(success, fail){
            return this;
        },

        getIdlers: function(success, fail){
            return this;
        },

        getMods: function(success, fail){
            return this;
        },

        getCammers: function(success, fail){
            return this;
        },
        */

        /* event listener functions */

        on: function(evt, handler){
            evt.split(' ').forEach(function(evt){
                if(!listeners[evt])
                    error('Invalid event type: ' + evt);
                else if(typeof handler != 'function')
                    error('Event handler must be a function.');
                else
                    listeners[evt].push(handler);
            });
            return this;
        },

        off: function(evt, handler){
            evt.split(' ').forEach(function(evt){
                if(!listeners[evt])
                    for(var evt in listeners)
                        listeners[evt] = [];
                else if(!handler)
                    listeners[evt] = [];
                else
                    listeners[evt] = listeners[evt].filter(function(listener){
                        return listener !== handler;
                    });
            });
            return this;
        }
    };

    return chain;
};<commit_msg>Timeout fixes.<commit_after>var request = require('superagent');

module.exports = function(config){
    for(var param in ({user:1, apiKey:1, room:1}))
        if(!config.hasOwnProperty(param))
            throw 'Missing config parameter: ' + param;

    var DEFAULTS = {
        pingInterval: 2e3,
        pingTimeout: 30,
        autoReconnect: true,
        reconnectInterval: 30e3,
        debug: false
    };
    for(var param in DEFAULTS)
        if(!config.hasOwnProperty(param))
            config[param] = DEFAULTS[param];
    if(config.pingInterval < 2e3)
        throw 'Don\'t be a jerk.';

    /* private variables of interest */
    var apiVersion = 1,
    baseURL = 'http://www.icanhazchat.com/api.ashx?v=' + apiVersion,
    isConnected = false,
    keyedURL = '',
    cammers = {},
    listeners = {
        connect: [],
        disconnect: [],
        ping:[],
        message: [],
        pm: [],
        whisper: [],
        userJoin: [],
        userKick: [],
        userQuit: [],
        userCamUp: [],
        userCamDown: [],
        send:[],
        error: []
    },
    trigger = function(type, data){
        var modifiedData = {
            eventType: type
        };
        for(var x in data)
            if(x != 'eventType')
                modifiedData[x] = data[x];
        (listeners[type] || []).forEach(function(listener){
            listener.call(chain, modifiedData);
        });
    },
    error = function(message){
        if(listeners.error.length){
            trigger('error', {
                message: message
            });
        }
    },
    makeRequest = function(params, success, fail){
        var url = isConnected ? keyedURL : baseURL;
        for(var param in params)
            url += '&' + param + '=' + params[param];
        request.get(url).
        on('error', function(err){
            error('Request error: ' + err);
            fail && fail.call(chain);
        }).
        end(function(response){
            if(!response.ok){
                error('Request error: ' + response.text);
                fail && fail.call(chain);
                return;
            }
            if(config.debug)
                console.log(url + '\n' + response.text + '\n');
            var lines = response.text.split(/\n/),
                isOK = lines.shift();
            if(isOK != 'OK'){
                fail && fail.call(chain, isOK);
                return;
            }
            success && success.call(chain, lines);
            parseResponse.call(chain, lines);
       });
    },
    pingFailures = 0,
    intPing = -1,
    disconnect = function(){
        isConnected = false;
        clearInterval(intPing);
        keyedURL = '';
        if(config.autoReconnect){
            (function reconnect(){
                chain.connect(null, function(){
                    setTimeout(reconnect, config.reconnectInterval)
                });
            })();
        }
    },
    ping = function(){
        makeRequest({
            a: 'recv'
        }, function(){
            pingFailures = 0;
            trigger('ping');
        }, function(){
            if(++pingFailures == config.pingTimeout)
                disconnect();
        });
    },
    htmlEntityDecode = function(text){
        return text.replace(/&#(\d+);/g, function(entity, num){
            return String.fromCharCode(num);
        });
    }
    parseResponse = function(lines){
        lines.forEach(function(line){
            var r = /^\[([^\]]+)\]/,
            eventType = (line.match(/^\[([^\]]+)\]/) || [, 'message'])[1];
            line = line.replace(r, '');
            switch(eventType){
                case 'message':
                    var parse = line.match(/^.+\|(.*?)(\:)?\s(.+)/);
                    if(parse){
                        username = parse[1],
                        message = parse[3];
                        if(username){
                            trigger('message', {
                                username: username,
                                message: htmlEntityDecode(message),
                                emote: !!parse[2]
                            });
                        } else {
                            var parseMsg;
                            if(parseMsg = message.match(/(.+?) has kicked (.+?) from the room/)){
                                trigger('userKick', {
                                    username: parseMsg[2],
                                    kickedBy: parseMsg[1]
                                });
                            }
                        }
                    }
                    break;

                case 'msg':
                    var parse = line.match(/^.+\|(.+?)\|.+?\|(.+)/),
                    username = parse[1];
                    if(username != config.user){
                        trigger('whisper', {
                            username: username,
                            message: htmlEntityDecode(parse[2])
                        });
                    }
                    break;

                case 'priv':
                    var parse = line.match(/^.+\|(.+?)\|(.+)/);
                    if(!/\|from you to /.test(line)){
                        trigger('pm', {
                            username: parse[1],
                            message: htmlEntityDecode(parse[2])
                        });
                    }
                    break;

                case 'hi':
                    var rMod = /\*$/,
                        username = line.replace(rMod, '');
                    if(username != config.user){
                        trigger('userJoin',{
                            username: username,
                            mod: rMod.test(line)
                        });
                    }
                    break;

                case 'bye':
                    trigger('userQuit', {
                        username: line
                    });
                    break;

                case 'c+':
                    var parse = line.match(/1(.{12})(.+?)\./),
                    hash = parse[1],
                    username = parse[2];
                    cammers[hash] =  username;
                    trigger('userCamUp', {
                        username: username
                    });
                    break;

                case 'c-':
                    var username = cammers[line] || '';
                    delete cammers[line];
                    trigger('userCamDown', {
                        username: username
                    });
                    break;

                case '':
                    disconnect();
                    trigger('disconnect');
                    break;
            }
        });
    },
    chain = {
        /* command functions */

        connect: function(success, fail){
            if(isConnected)
                error('Already connected.');
            else {
                makeRequest({
                    u: config.user,
                    p: config.apiKey,
                    a: 'join',
                    w: config.room
                }, function(data){
                    isConnected = true;
                    keyedURL = baseURL + '&k=' + data[0];
                    intPing = setInterval(ping, config.pingInterval);
                    success && success.call(chain, data);
                    trigger('connect');
                }, function(data){
                    fail && fail.call(chain, data);
                });
            }
            return this;
        },

        send: function(message, success, fail){
            if(!message)
                error('No message.');
            else if(!isConnected)
                error('Not connected.');
            else {
                makeRequest({
                    a: 'send',
                    w: message
                }, success, fail);
                trigger('send', {
                    message: message
                });
            }
            return this;
        },

        whisper: function(username, message, success, fail){
            return this.send('/msg ' + username + ' ' + message, success, fail);
        },

        pm: function(username, message, success, fail){
            return this.send('/privmsg ' + username + ' ' + message, success, fail);
        },

        /* getter functions */
        /* I'll build these later
        getUsers: function(success, fail){
            return this;
        },

        getIdlers: function(success, fail){
            return this;
        },

        getMods: function(success, fail){
            return this;
        },

        getCammers: function(success, fail){
            return this;
        },
        */

        /* event listener functions */

        on: function(evt, handler){
            evt.split(' ').forEach(function(evt){
                if(!listeners[evt])
                    error('Invalid event type: ' + evt);
                else if(typeof handler != 'function')
                    error('Event handler must be a function.');
                else
                    listeners[evt].push(handler);
            });
            return this;
        },

        off: function(evt, handler){
            evt.split(' ').forEach(function(evt){
                if(!listeners[evt])
                    for(var evt in listeners)
                        listeners[evt] = [];
                else if(!handler)
                    listeners[evt] = [];
                else
                    listeners[evt] = listeners[evt].filter(function(listener){
                        return listener !== handler;
                    });
            });
            return this;
        }
    };

    return chain;
};<|endoftext|>


<commit_before>/*
 * grunt-git-reset
 * https://github.com/zachwolf/grunt-git-reset
 *
 * Copyright (c) 2014 Zach Wolf
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  grunt.registerMultiTask('git_reset', 'Grunt task to reset directory in a git project', function() {
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      punctuation: '.',
      separator: ', '
    });

    // Iterate over all specified file groups.
    this.files.forEach(function(f) {
      // Concat specified files.
      var src = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      }).map(function(filepath) {
        // Read file source.
        return grunt.file.read(filepath);
      }).join(grunt.util.normalizelf(options.separator));

      // Handle options.
      src += options.punctuation;

      // Write the destination file.
      grunt.file.write(f.dest, src);

      // Print a success message.
      grunt.log.writeln('File "' + f.dest + '" created.');
    });
  });

};
<commit_msg>Finished task<commit_after>/*
 * grunt-git-reset
 * https://github.com/zachwolf/grunt-git-reset
 *
 * Copyright (c) 2014 Zach Wolf
 * Licensed under the MIT license.
 */

'use strict';

var spawn = require('child_process').spawn,
    checkout,
    errorMessage;

module.exports = function(grunt) {

  grunt.registerMultiTask('git_reset', 'Grunt task to reset directory in a git project', function() {
    var options,
        done;

    // Merge task-specific and/or target-specific options with these defaults.
    options = this.options({});

    done = this.async();

    if (!options.path) {
      errorMessage  = '`path` setting is required to prevent' +
                      'unwanted lose of changes. If you want to' +
                      'reset changes from the root, use `path: \'.\'`';
      grunt.log.writeln(errorMessage);
      return;
    }

    checkout = spawn('git', ['checkout', '--', options.path]);

    checkout.stdout.on('data', function (data) {
      grunt.log.writeln('stdout: ' + data);
      done();
    });

  });

};
<|endoftext|>


<commit_before>function Init() { // Setup!

	// Light_World is the light world (with the dark world overlayed on top). It is the visible game screen too.

	Light_World = document.createElement("canvas");

	Light_World.width = 400;
	Light_World.height = 400;

	light_draw = Light_World.getContext("2d");
	light_draw.imageSmoothingEnabled = false; // No pixelizing here!
	document.body.appendChild(Light_World);

	// Style!

	Light_World.style.position = "absolute";
	Light_World.style.margin = "auto";
	Light_World.style.top = "0";
	Light_World.style.left = "0";
	Light_World.style.bottom = "0";
	Light_World.style.right = "0";

	// Dark_World is the dark world (to be overlayed on the light world).

	Dark_World = document.createElement("canvas");

	Dark_World.width = 100;
	Dark_World.height = 100;

	dark_draw = Dark_World.getContext("2d");

	// No need for style becuase the dark world canvas is invisible!

	// Add keyboard events.

	Keys_Setup(window, Light_World); // The visible screen is the one that gets the events.

	// Game objects.

	light_objects = { // Objects in the light world.

		player: {}, // The controllable player.
		blocks: [], // Blocks the player.
		walls: [], // World walls.
		switches: [], // Buttons that open doors.
		doors: [], // Locked doors.
		exit: {} // Level ends.

	};

	dark_objects = { // Objects in the dark world.

		player: {}, // Same as for light objects.
		blocks: [],
		walls: [],
		switches: [],
		doors: [],
		exit: {}

	};

	interdimensional = {}; // Variables used by objects in BOTH worlds.

}<commit_msg>Delete Init.js<commit_after><|endoftext|>


<commit_before>/*
 * grunticon
 * https://github.com/filamentgroup/grunticon
 *
 * Copyright (c) 2012 Scott Jehl, Filament Group, Inc
 * Licensed under the MIT license.
 */

/*global __dirname:true*/
/*global require:true*/

module.exports = function (grunt, undefined) {

	"use strict";

	var path = require('path');
	var os = require('os');

	var fs = require('fs-extra');
	var uglify = require('uglify-js');
	var RSVP = require('rsvp');

	var DirectoryColorfy = require('directory-colorfy');
	var DirectoryEncoder = require('directory-encoder');
	var svgToPng = require('svg-to-png');

	var helper = require(path.join('..', 'lib', 'grunticon-helper'));

	grunt.registerMultiTask('grunticon', 'A mystical CSS icon solution.', function () {
		var done = this.async();

		// get the config
		var config = this.options({
			datasvgcss: "icons.data.svg.css",
			datapngcss: "icons.data.png.css",
			urlpngcss: "icons.fallback.css",
			files: {
				loader: path.join(__dirname, 'grunticon', 'static', 'grunticon.loader.js'),
				banner: path.join(__dirname, 'grunticon', 'static', 'grunticon.loader.banner.js')
			},
			previewhtml: "preview.html",
			loadersnippet: "grunticon.loader.js",
			cssbasepath: path.sep,
			customselectors: {},
			cssprefix: ".icon-",
			defaultWidth: "400px",
			defaultHeight: "300px",
			colors: {},
			pngfolder: "png",
			pngpath: "",
			template: "",
			tmpDir: "grunticon-tmp",
			previewTemplate: path.join(__dirname, "..", "example", "preview.hbs"),
			dynamicColorOnly: true,
			stylesheet: '',
			lessprefix: '',
			preview: false,
			loader: false,
		});

		// just a quick starting message
		grunt.log.writeln("(EBSCO) Look, it's a grunticon!");

		var files = this.files.filter(function (file) {
			return file.src[0].match(/png|svg/);
		});
		if (files.length === 0) {
			grunt.log.writeln("Grunticon has no files to read!");
			done();
			return;
		}

		files = files.map(function (file) {
			return file.src[0];
		});

		config.src = this.files[0].orig.cwd;
		config.dest = this.files[0].orig.dest;

		if (!config.dest || config.dest && config.dest === "") {
			grunt.fatal("The destination must be a directory");
		}

		// folder name (within the output folder) for generated png files
		var pngfolder = path.join.apply(null, config.pngfolder.split(path.sep));

		// create the output directory
		grunt.file.mkdir(config.dest);

		// minify the source of the grunticon loader and write that to the output
		if (config.loader) {
			grunt.log.writeln("grunticon now minifying the stylesheet loader source.");
			var banner = grunt.file.read(config.files.banner);
			config.min = banner + "\n" + uglify.minify(config.files.loader).code;
			grunt.file.write(path.join(config.dest, config.loadersnippet), config.min);
			grunt.log.writeln("grunticon loader file created.");
		}

		var svgToPngOpts = {
			pngfolder: pngfolder,
			defaultWidth: config.defaultWidth,
			defaultHeight: config.defaultHeight
		};

		var o = {
			pngfolder: pngfolder,
			customselectors: config.customselectors,
			template: path.resolve(config.template),
			previewTemplate: path.resolve(config.previewTemplate),
			noencodepng: false,
			prefix: config.cssprefix
		};

		var o2 = {
			pngfolder: pngfolder,
			pngpath: config.pngpath,
			customselectors: config.customselectors,
			template: path.resolve(config.template),
			previewTemplate: path.resolve(config.previewTemplate),
			noencodepng: true,
			prefix: config.cssprefix
		};
		//EBSCO - Parsing less file, parse function found on stackoverflow, question 11827453;

		var lessFilePath = path.resolve(config.stylesheet),
			lessFile, lessVars,
			getLessVars = function (lessStr) {
				var keyVar, lessVars, line, lines, _i, _len;
				lines = lessStr.split('\n');
				lessVars = {};
				for (_i = 0, _len = lines.length; _i < _len; _i++) {
					line = lines[_i];
					if (line.indexOf('@') === 0) {
						keyVar = line.split(';')[0].split(':');
						if (keyVar[1].indexOf('@') > -1) {
							lessVars[keyVar[0].trim()] = lessVars[keyVar[1].trim()];
						}
						else {
							lessVars[keyVar[0].trim()] = keyVar[1].trim();
						}
					}
				}
				return lessVars;
			};

		if (grunt.file.exists(lessFilePath) && !grunt.file.isDir(lessFilePath)) {
			lessFile = fs.readFileSync(lessFilePath).toString();
		}
		if (typeof lessFile === 'string' && config.lessprefix) {
			lessVars = getLessVars(lessFile);

			var prefixLocation, colorName;
			for (var key in lessVars) {
				prefixLocation = key.indexOf(config.lessprefix);
				if (prefixLocation === 1) { // first character of less variables is '@'
					colorName = key.replace('@' + config.lessprefix, '');
					config.colors[colorName] = lessVars[key];
				}
			}
		}

		grunt.log.writeln("Coloring SVG files");
		// create the tmp directory
		var tmp = path.join(os.tmpDir(), config.tmpDir);
		if (grunt.file.exists(tmp)) {
			fs.removeSync(tmp);
		}
		grunt.file.mkdir(tmp);
		var colorFiles,
			isEmpty = function (obj) {
				for (var prop in obj) {
					if (obj.hasOwnProperty(prop)) {
						return false;
					}
				}

				return true;
			};

		try {
			var dc = new DirectoryColorfy(config.src, tmp, {
				colors: config.colors,
				dynamicColorOnly: isEmpty(config.colors) ? false : config.dynamicColorOnly
			});
			colorFiles = dc.convert();
		} catch (e) {
			grunt.fatal(e);
			done(false);
		}

		//copy non color config files into temp directory
		var transferFiles = this.files.filter(function (f) {
			return !f.src[0].match(/\.colors/);
		});

		transferFiles.forEach(function (f) {
			var filenameArr = f.src[0].split("/"),
				filename = filenameArr[filenameArr.length - 1];
			grunt.file.copy(f.src[0], path.join(tmp, filename));
		});

		grunt.log.writeln("Converting SVG to PNG OR NOT");
		svgToPng.convert(tmp, path.join(config.dest, pngfolder), svgToPngOpts)
			.then(function (result, err) {
				if (err) {
					grunt.fatal(err);
				}

				var svgde = new DirectoryEncoder(tmp, path.join(config.dest, config.datasvgcss), o),
					pngde = new DirectoryEncoder(path.join(config.dest, pngfolder), path.join(config.dest, config.datapngcss), o),
					pngdefall = new DirectoryEncoder(path.join(config.dest, pngfolder), path.join(config.dest, config.urlpngcss), o2);

				grunt.log.writeln("Writing CSS");
				try {
					svgde.encode();
					pngde.encode();
					pngdefall.encode();
				} catch (e) {
					grunt.fatal(e);
					done(false);
				}
				if (config.preview === true) {
					grunt.log.writeln("Grunticon now creating Preview File");
					try {
						helper.createPreview(tmp, config);
					} catch (er) {
						grunt.fatal(er);
					}
				}

				grunt.log.writeln("Delete Temp Files");
				fs.removeSync(tmp);
				done();
			});

	});
};
<commit_msg>updating log statement<commit_after>/*
 * grunticon
 * https://github.com/filamentgroup/grunticon
 *
 * Copyright (c) 2012 Scott Jehl, Filament Group, Inc
 * Licensed under the MIT license.
 */

/*global __dirname:true*/
/*global require:true*/

module.exports = function (grunt, undefined) {

	"use strict";

	var path = require('path');
	var os = require('os');

	var fs = require('fs-extra');
	var uglify = require('uglify-js');
	var RSVP = require('rsvp');

	var DirectoryColorfy = require('directory-colorfy');
	var DirectoryEncoder = require('directory-encoder');
	var svgToPng = require('svg-to-png');

	var helper = require(path.join('..', 'lib', 'grunticon-helper'));

	grunt.registerMultiTask('grunticon', 'A mystical CSS icon solution.', function () {
		var done = this.async();

		// get the config
		var config = this.options({
			datasvgcss: "icons.data.svg.css",
			datapngcss: "icons.data.png.css",
			urlpngcss: "icons.fallback.css",
			files: {
				loader: path.join(__dirname, 'grunticon', 'static', 'grunticon.loader.js'),
				banner: path.join(__dirname, 'grunticon', 'static', 'grunticon.loader.banner.js')
			},
			previewhtml: "preview.html",
			loadersnippet: "grunticon.loader.js",
			cssbasepath: path.sep,
			customselectors: {},
			cssprefix: ".icon-",
			defaultWidth: "400px",
			defaultHeight: "300px",
			colors: {},
			pngfolder: "png",
			pngpath: "",
			template: "",
			tmpDir: "grunticon-tmp",
			previewTemplate: path.join(__dirname, "..", "example", "preview.hbs"),
			dynamicColorOnly: true,
			stylesheet: '',
			lessprefix: '',
			preview: false,
			loader: false,
		});

		// just a quick starting message
		grunt.log.writeln("(EBSCO) Look, it's a grunticon!");

		var files = this.files.filter(function (file) {
			return file.src[0].match(/png|svg/);
		});
		if (files.length === 0) {
			grunt.log.writeln("Grunticon has no files to read!");
			done();
			return;
		}

		files = files.map(function (file) {
			return file.src[0];
		});

		config.src = this.files[0].orig.cwd;
		config.dest = this.files[0].orig.dest;

		if (!config.dest || config.dest && config.dest === "") {
			grunt.fatal("The destination must be a directory");
		}

		// folder name (within the output folder) for generated png files
		var pngfolder = path.join.apply(null, config.pngfolder.split(path.sep));

		// create the output directory
		grunt.file.mkdir(config.dest);

		// minify the source of the grunticon loader and write that to the output
		if (config.loader) {
			grunt.log.writeln("grunticon now minifying the stylesheet loader source.");
			var banner = grunt.file.read(config.files.banner);
			config.min = banner + "\n" + uglify.minify(config.files.loader).code;
			grunt.file.write(path.join(config.dest, config.loadersnippet), config.min);
			grunt.log.writeln("grunticon loader file created.");
		}

		var svgToPngOpts = {
			pngfolder: pngfolder,
			defaultWidth: config.defaultWidth,
			defaultHeight: config.defaultHeight
		};

		var o = {
			pngfolder: pngfolder,
			customselectors: config.customselectors,
			template: path.resolve(config.template),
			previewTemplate: path.resolve(config.previewTemplate),
			noencodepng: false,
			prefix: config.cssprefix
		};

		var o2 = {
			pngfolder: pngfolder,
			pngpath: config.pngpath,
			customselectors: config.customselectors,
			template: path.resolve(config.template),
			previewTemplate: path.resolve(config.previewTemplate),
			noencodepng: true,
			prefix: config.cssprefix
		};
		//EBSCO - Parsing less file, parse function found on stackoverflow, question 11827453;

		var lessFilePath = path.resolve(config.stylesheet),
			lessFile, lessVars,
			getLessVars = function (lessStr) {
				var keyVar, lessVars, line, lines, _i, _len;
				lines = lessStr.split('\n');
				lessVars = {};
				for (_i = 0, _len = lines.length; _i < _len; _i++) {
					line = lines[_i];
					if (line.indexOf('@') === 0) {
						keyVar = line.split(';')[0].split(':');
						if (keyVar[1].indexOf('@') > -1) {
							lessVars[keyVar[0].trim()] = lessVars[keyVar[1].trim()];
						}
						else {
							lessVars[keyVar[0].trim()] = keyVar[1].trim();
						}
					}
				}
				return lessVars;
			};

		if (grunt.file.exists(lessFilePath) && !grunt.file.isDir(lessFilePath)) {
			lessFile = fs.readFileSync(lessFilePath).toString();
		}
		if (typeof lessFile === 'string' && config.lessprefix) {
			lessVars = getLessVars(lessFile);

			var prefixLocation, colorName;
			for (var key in lessVars) {
				prefixLocation = key.indexOf(config.lessprefix);
				if (prefixLocation === 1) { // first character of less variables is '@'
					colorName = key.replace('@' + config.lessprefix, '');
					config.colors[colorName] = lessVars[key];
				}
			}
		}

		grunt.log.writeln("Coloring SVG files");
		// create the tmp directory
		var tmp = path.join(os.tmpDir(), config.tmpDir);
		if (grunt.file.exists(tmp)) {
			fs.removeSync(tmp);
		}
		grunt.file.mkdir(tmp);
		var colorFiles,
			isEmpty = function (obj) {
				for (var prop in obj) {
					if (obj.hasOwnProperty(prop)) {
						return false;
					}
				}

				return true;
			};

		try {
			var dc = new DirectoryColorfy(config.src, tmp, {
				colors: config.colors,
				dynamicColorOnly: isEmpty(config.colors) ? false : config.dynamicColorOnly
			});
			colorFiles = dc.convert();
		} catch (e) {
			grunt.fatal(e);
			done(false);
		}

		//copy non color config files into temp directory
		var transferFiles = this.files.filter(function (f) {
			return !f.src[0].match(/\.colors/);
		});

		transferFiles.forEach(function (f) {
			var filenameArr = f.src[0].split("/"),
				filename = filenameArr[filenameArr.length - 1];
			grunt.file.copy(f.src[0], path.join(tmp, filename));
		});

		grunt.log.writeln("Converting SVG to PNG");
		svgToPng.convert(tmp, path.join(config.dest, pngfolder), svgToPngOpts)
			.then(function (result, err) {
				if (err) {
					grunt.fatal(err);
				}

				var svgde = new DirectoryEncoder(tmp, path.join(config.dest, config.datasvgcss), o),
					pngde = new DirectoryEncoder(path.join(config.dest, pngfolder), path.join(config.dest, config.datapngcss), o),
					pngdefall = new DirectoryEncoder(path.join(config.dest, pngfolder), path.join(config.dest, config.urlpngcss), o2);

				grunt.log.writeln("Writing CSS");
				try {
					svgde.encode();
					pngde.encode();
					pngdefall.encode();
				} catch (e) {
					grunt.fatal(e);
					done(false);
				}
				if (config.preview === true) {
					grunt.log.writeln("Grunticon now creating Preview File");
					try {
						helper.createPreview(tmp, config);
					} catch (er) {
						grunt.fatal(er);
					}
				}

				grunt.log.writeln("Delete Temp Files");
				fs.removeSync(tmp);
				done();
			});

	});
};
<|endoftext|>


<commit_before>module.exports = function(gulp, speck) {
  return gulp.task('js:vendor', function() {
    var uglify = require('gulp-uglify'),
      gulpif = require('gulp-if'),
      insert = require('gulp-insert'),
      concat = require('gulp-concat');

    return gulp.src(speck.config.vendorJS)
      .pipe(gulpif(speck.build.env.optimise, uglify()))
      .pipe(concat('vendor.js'))
      .pipe(gulpif(speck.build.env.optimise, insert.prepend(
        '/*\n' +
        '* ' + speck.config.name + ', ' + speck.config.version + ' (' + speck.config.currentRevision + ')\n' +
        '* ' + 'vendor.js built ' + new Date().toISOString().substring(0, 10) + '\n' +
        '* Don\'t edit this file directly.\n' +
        '*/\n'
      )))
      .pipe(gulp.dest(speck.assets.build.js));
  });
};
<commit_msg>Add size loging for vendor.js file<commit_after>module.exports = function(gulp, speck) {
  return gulp.task('js:vendor', function() {
    var uglify = require('gulp-uglify'),
      gulpif = require('gulp-if'),
      insert = require('gulp-insert'),
      size = require('gulp-size'),
      concat = require('gulp-concat');

    return gulp.src(speck.config.vendorJS)
      .pipe(gulpif(speck.build.env.optimise, uglify()))
      .pipe(concat('vendor.js'))
      .pipe(gulpif(speck.build.env.optimise, insert.prepend(
        '/*\n' +
        '* ' + speck.config.name + ', ' + speck.config.version + ' (' + speck.config.currentRevision + ')\n' +
        '* ' + 'vendor.js built ' + new Date().toISOString().substring(0, 10) + '\n' +
        '* Don\'t edit this file directly.\n' +
        '*/\n'
      )))
      .pipe(size({gzip: true, title: 'vendor.js'}))
      .pipe(gulp.dest(speck.assets.build.js));
  });
};
<|endoftext|>


<commit_before>/*
 * grunt-jsinspect
 *
 *
 * Copyright (c) 2014 Stefan Judis
 * Licensed under the MIT license.
 */

'use strict';

var Inspector = require('jsinspect/lib/inspector');
var Reporter = require('jsinspect/lib/reporters');

module.exports = function(grunt) {

  grunt.registerMultiTask('jsinspect', 'Grunt task for jsinspect', function() {

    var options = this.options({
      threshold: 30,
      diff: false,
      identifiers: false
    });

    var inspector = new Inspector(this.filesSrc, {
      threshold:   options.threshold,
      diff:        options.diff,
      identifiers: options.identifiers
    });

    var reporterType = new Reporter.default(inspector, options.diff);

    inspector.run();
  });
};
<commit_msg>fix coding style<commit_after>/*
 * grunt-jsinspect
 *
 *
 * Copyright (c) 2014 Stefan Judis
 * Licensed under the MIT license.
 */

'use strict';

var Inspector = require('jsinspect/lib/inspector');
var Reporter = require('jsinspect/lib/reporters');

module.exports = function(grunt) {

  grunt.registerMultiTask('jsinspect', 'Grunt task for jsinspect', function() {

    var options = this.options({
      threshold:   30,
      diff:        false,
      identifiers: false
    });

    var inspector = new Inspector(this.filesSrc, {
      threshold:   options.threshold,
      diff:        options.diff,
      identifiers: options.identifiers
    });

    var reporterType = new Reporter.default(inspector, options.diff);

    inspector.run();
  });
};
<|endoftext|>


<commit_before>/*
 * grunt-jsinspect
 *
 *
 * Copyright (c) Stefan Judis and Juga Paazmaya
 * Licensed under the MIT license.
 */

'use strict';

var Inspector = require('jsinspect/lib/inspector');
var Reporter = require('jsinspect/lib/reporters');

module.exports = function(grunt) {

  grunt.registerMultiTask('jsinspect', 'Grunt task for jsinspect', function() {
    var taskSucceeded = true;

    var options = this.options({
      threshold:   30,
      diff:        true,
      identifiers: false,
      failOnMatch: true,
      reporter:    'default'
    });

    var inspector = new Inspector(this.filesSrc, {
      threshold:   options.threshold,
      diff:        options.diff,
      identifiers: options.identifiers
    });

    var reporterType = new Reporter[options.reporter](inspector, options.diff);

    if (options.failOnMatch) {
      inspector.on('match', function() {
        taskSucceeded = false;
      });
    }

    inspector.run();

    return taskSucceeded;
  });
};
<commit_msg>Proper error message when configured report is invalid<commit_after>/*
 * grunt-jsinspect
 *
 *
 * Copyright (c) Stefan Judis and Juga Paazmaya
 * Licensed under the MIT license.
 */

'use strict';

var Inspector = require('jsinspect/lib/inspector');
var Reporter = require('jsinspect/lib/reporters');

module.exports = function(grunt) {

  grunt.registerMultiTask('jsinspect', 'Grunt task for jsinspect', function() {
    var taskSucceeded = true;

    var options = this.options({
      threshold:   30,
      diff:        true,
      identifiers: false,
      failOnMatch: true,
      reporter:    'default'
    });

    var inspector = new Inspector(this.filesSrc, {
      threshold:   options.threshold,
      diff:        options.diff,
      identifiers: options.identifiers
    });

    if (!Reporter.hasOwnProperty(options.reporter) || typeof Reporter[options.reporter] !== 'function') {
      grunt.log.error('Sorry but the configured reporter "' + options.reporter + '" does not exist, thus exiting');
      return false;
    }

    var reporterType = new Reporter[options.reporter](inspector, options.diff);

    if (options.failOnMatch) {
      inspector.on('match', function() {
        taskSucceeded = false;
      });
    }

    inspector.run();

    return taskSucceeded;
  });
};
<|endoftext|>


<commit_before>/*
 * grunt-nginclude
 * https://github.com/mgcrea/grunt-nginclude
 *
 * Copyright (c) 2014 Olivier Louvignes
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  var chalk = require('chalk');
  var cheerio = require('cheerio');

  grunt.registerMultiTask('nginclude', 'Embed static ngIncludes.', function() {

    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      assetsDirs: [this.target]
    });

    // Process some options to create others.
    options.baseSearchpath = options.assetsDirs.length > 1 ? '{' + options.assetsDirs.join(',') + '}' : options.assetsDirs[0];

    // This function receives an ng-include src and tries to read it from the filesystem.
    var readSource = function(src) {
      var searchpath = options.baseSearchpath + '/' + src.substr(1, src.length - 2);
      var foundfiles = grunt.file.expand(searchpath);
      if(!foundfiles.length) {
        grunt.log.warn('Included file "' + searchpath + '" not found.');
        return;
      }
      var include = grunt.file.read(foundfiles[0]).trim();
      return include;
    };

    // Heavy lifting is done here. Parses ng-include tags and includes the source contents inside them.
    var processHtml = function(html) {
      var $ = cheerio.load(html);

      // Use while to make the task recursive.
      while (true) {
        var tags = $('ng-include, [ng-include]');

        // If we don't find any more ng-include tags, we're done.
        if (tags.length === 0) {
          return $.html();
        }

        // For each tag, grab the associated source file and sub it in.
        tags.each(function(i, ng) {
          var $ng = $(ng);
          var src = $ng.attr('src') || $ng.attr('ng-include');

          if(!src.match(/^'.+'$/g)) {
            return;
          }

          // Remove old ng-include attributes so Angular doesn't read them.
          $ng.removeAttr('src').removeAttr('ng-include');

          var comment1 = "\n<!-- ngInclude: '" + src + "' -->\n";
          var comment2 = "\n<!--/ngInclude: '" + src + "' -->\n";
          var include = readSource(src);

          // As per Angular's behaviour, the included source is put inside the
          $ng.html(comment1 + include + comment2);
        });
      }
    };

    // Iterate over all specified file groups.
    this.files.forEach(function(f) {
      // Concat specified files.
      var src = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      }).map(function(filepath) {
        // Read file source.
        return grunt.file.read(filepath);
      }).map(function(html) {
        // Process the file's HTML source.
        return processHtml(html);
      }).map(function(output) {
        grunt.file.write(f.dest, output);

        // Print a success message.
        grunt.log.writeln('File ' + chalk.cyan(f.dest) + ' created.');
      });

    });

  });

};
<commit_msg>chore(jshint): make jshint happy<commit_after>/*
 * grunt-nginclude
 * https://github.com/mgcrea/grunt-nginclude
 *
 * Copyright (c) 2014 Olivier Louvignes
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  var chalk = require('chalk');
  var cheerio = require('cheerio');

  grunt.registerMultiTask('nginclude', 'Embed static ngIncludes.', function() {

    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      assetsDirs: [this.target]
    });

    // Process some options to create others.
    options.baseSearchpath = options.assetsDirs.length > 1 ? '{' + options.assetsDirs.join(',') + '}' : options.assetsDirs[0];

    // This function receives an ng-include src and tries to read it from the filesystem.
    var readSource = function(src) {
      var searchpath = options.baseSearchpath + '/' + src.substr(1, src.length - 2);
      var foundfiles = grunt.file.expand(searchpath);
      if(!foundfiles.length) {
        grunt.log.warn('Included file "' + searchpath + '" not found.');
        return;
      }
      var include = grunt.file.read(foundfiles[0]).trim();
      return include;
    };

    // Heavy lifting is done here. Parses ng-include tags and includes the source contents inside them.
    var processHtml = function(html) {
      var $ = cheerio.load(html);

      function processTag(i, ng) {
        var $ng = $(ng);
        var src = $ng.attr('src') || $ng.attr('ng-include');

        if(!src.match(/^'.+'$/g)) {
          return;
        }

        // Remove old ng-include attributes so Angular doesn't read them.
        $ng.removeAttr('src').removeAttr('ng-include');

        var comment1 = "\n<!-- ngInclude: '" + src + "' -->\n";
        var comment2 = "\n<!--/ngInclude: '" + src + "' -->\n";
        var include = readSource(src);

        // As per Angular's behaviour, the included source is put inside the
        $ng.html(comment1 + include + comment2);
      }

      // Use while to make the task recursive.
      while (true) {
        var tags = $('ng-include, [ng-include]');

        // If we don't find any more ng-include tags, we're done.
        if (tags.length === 0) {
          return $.html();
        }

        // For each tag, grab the associated source file and sub it in.
        tags.each(processTag);
      }
    };

    // Iterate over all specified file groups.
    this.files.forEach(function(f) {
      // Concat specified files.
      var src = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      }).map(function(filepath) {
        // Read file source.
        return grunt.file.read(filepath);
      }).map(function(html) {
        // Process the file's HTML source.
        return processHtml(html);
      }).map(function(output) {
        grunt.file.write(f.dest, output);

        // Print a success message.
        grunt.log.writeln('File ' + chalk.cyan(f.dest) + ' created.');
      });

    });

  });

};
<|endoftext|>


<commit_before>/*
 * grunt-nginclude
 * https://github.com/mgcrea/grunt-nginclude
 *
 * Copyright (c) 2014 Olivier Louvignes
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  var chalk = require('chalk');
  var cheerio = require('cheerio');

  grunt.registerMultiTask('nginclude', 'Embed static ngIncludes.', function() {

    var processHtml = function(html){
      var $ = cheerio.load(html);

      // Use while to make the task recursive.
      while (true) {
        var tags = $('ng-include, [ng-include]');

        // If we don't find any more ng-include tags, we're done.
        if (tags.length == 0) {
          return $.html();
        }

        // For each tag, grab the associated source file and sub it in.
        tags.each(function(i, ng) {
          var $ng = $(ng);
          var src = $ng.attr('src') || $ng.attr('ng-include');
          if(!src.match(/^'.+'$/g)) {
            return;
          }
          var searchpath = options.assetsDirs.length > 1 ? '{' + options.assetsDirs.join(',') + '}' : options.assetsDirs[0];
          searchpath += '/' + src.substr(1, src.length - 2);
          var foundfiles = grunt.file.expand(searchpath);
          if(!foundfiles.length) {
            grunt.log.warn('Included file "' + searchpath + '" not found.');
            return;
          }
          var include = grunt.file.read(foundfiles[0]).trim();
          $ng.replaceWith('<!-- ngInclude: \'' + foundfiles[0] + '\' -->\n' + include);
        });
      }
    }

    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      assetsDirs: [this.target]
    });

    // Iterate over all specified file groups.
    this.files.forEach(function(f) {
      // Concat specified files.
      var src = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      }).map(function(filepath) {
        // Read file source.
        return grunt.file.read(filepath);
      }).map(function(html) {
        // Process the file's HTML source.
        return processHtml(html);
      }).map(function(output) {
        grunt.file.write(f.dest, output);

        // Print a success message.
        grunt.log.writeln('File ' + chalk.cyan(f.dest) + ' created.');
      });

    });

  });

};
<commit_msg>fix(typo): use === instead of ==<commit_after>/*
 * grunt-nginclude
 * https://github.com/mgcrea/grunt-nginclude
 *
 * Copyright (c) 2014 Olivier Louvignes
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  var chalk = require('chalk');
  var cheerio = require('cheerio');

  grunt.registerMultiTask('nginclude', 'Embed static ngIncludes.', function() {

    var processHtml = function(html){
      var $ = cheerio.load(html);

      // Use while to make the task recursive.
      while (true) {
        var tags = $('ng-include, [ng-include]');

        // If we don't find any more ng-include tags, we're done.
        if (tags.length === 0) {
          return $.html();
        }

        // For each tag, grab the associated source file and sub it in.
        tags.each(function(i, ng) {
          var $ng = $(ng);
          var src = $ng.attr('src') || $ng.attr('ng-include');
          if(!src.match(/^'.+'$/g)) {
            return;
          }
          var searchpath = options.assetsDirs.length > 1 ? '{' + options.assetsDirs.join(',') + '}' : options.assetsDirs[0];
          searchpath += '/' + src.substr(1, src.length - 2);
          var foundfiles = grunt.file.expand(searchpath);
          if(!foundfiles.length) {
            grunt.log.warn('Included file "' + searchpath + '" not found.');
            return;
          }
          var include = grunt.file.read(foundfiles[0]).trim();
          $ng.replaceWith('<!-- ngInclude: \'' + foundfiles[0] + '\' -->\n' + include);
        });
      }
    }

    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      assetsDirs: [this.target]
    });

    // Iterate over all specified file groups.
    this.files.forEach(function(f) {
      // Concat specified files.
      var src = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      }).map(function(filepath) {
        // Read file source.
        return grunt.file.read(filepath);
      }).map(function(html) {
        // Process the file's HTML source.
        return processHtml(html);
      }).map(function(output) {
        grunt.file.write(f.dest, output);

        // Print a success message.
        grunt.log.writeln('File ' + chalk.cyan(f.dest) + ' created.');
      });

    });

  });

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {
  var Q = require('q');
  var SauceTunnel = require('sauce-tunnel');
  var TestRunner = require('../src/TestRunner')(grunt);

  Q.longStackSupport = true;

  function unsupportedPort(url) {
    // Not all ports are proxied by Sauce Connect. List of supported ports is
    // available at https://saucelabs.com/docs/connect#localhost
    var portRegExp = /:(\d+)\//;
    var matches = portRegExp.exec(url);
    var port = matches ? parseInt(matches[1], 10) : null;
    var supportedPorts = [
        80, 443, 888, 2000, 2001, 2020, 2109, 2222, 2310, 3000, 3001, 3030,
        3210, 3333, 4000, 4001, 4040, 4321, 4502, 4503, 4567, 5000, 5001, 5050, 5555, 5432, 6000,
        6001, 6060, 6666, 6543, 7000, 7070, 7774, 7777, 8000, 8001, 8003, 8031, 8080, 8081, 8765,
        8888, 9000, 9001, 9080, 9090, 9876, 9877, 9999, 49221, 55001
      ];

    if (port) {
      return supportedPorts.indexOf(port) === -1;
    }

    return false;
  }

  function reportProgress(notification) {
    switch (notification.type) {
    case 'tunnelOpen':
      grunt.log.writeln('=> Starting Tunnel to Sauce Labs'.inverse.bold);
      break;
    case 'tunnelOpened':
      grunt.log.ok('Connected to Saucelabs');
      break;
    case 'tunnelClose':
      grunt.log.writeln('=> Stopping Tunnel to Sauce Labs'.inverse.bold);
      break;
    case 'tunnelEvent':
      if (notification.verbose) {
        grunt.verbose[notification.method](notification.text);
      } else {
        grunt.log[notification.method](notification.text);
      }
      break;
    case 'jobStarted':
      grunt.log.writeln('\n', notification.startedJobs, '/', notification.numberOfJobs, 'tests started');
      break;
    case 'jobCompleted':
      grunt.log.subhead('\nTested %s', notification.url);
      grunt.log.writeln('Platform: %s', notification.platform);

      if (notification.tunnelId && unsupportedPort(notification.url)) {
        grunt.log.writeln('Warning: This url might use a port that is not proxied by Sauce Connect.'.yellow);
      }

      grunt.log.writeln('Passed: %s', notification.passed);
      grunt.log.writeln('Url %s', notification.jobUrl);
      break;
    case 'testCompleted':
      grunt.log[notification.passed ? 'ok' : 'error']('All tests completed with status %s', notification.passed);
      break;
    case 'retrying':
      grunt.log.writeln('Timed out, retrying URL %s on browser %s', notification.url, JSON.stringify(notification.browser));
      break;
    default:
      grunt.log.error('Unexpected notification type');
  }
  }

  function createTunnel(arg) {
    var tunnel;

    reportProgress({
      type: 'tunnelOpen'
    });

    tunnel = new SauceTunnel(arg.username, arg.key(), arg.identifier, true, ['-P', '0'].concat(arg.tunnelArgs));

    ['write', 'writeln', 'error', 'ok', 'debug'].forEach(function (method) {
      tunnel.on('log:' + method, function (text) {
        reportProgress({
          type: 'tunnelEvent',
          verbose: false,
          method: method,
          text: text
        });
      });
      tunnel.on('verbose:' + method, function (text) {
        reportProgress({
          type: 'tunnelEvent',
          verbose: true,
          method: method,
          text: text
        });
      });
    });

    return tunnel;
  }

  function runTask(arg, framework, callback) {
    var tunnel;

    Q
      .fcall(function () {
        var deferred;

        if (arg.tunneled) {
          deferred = Q.defer();

          tunnel = createTunnel(arg);
          tunnel.start(function (succeeded) {
            if (!succeeded) {
              deferred.reject('Could not create tunnel to Sauce Labs');
            } else {
              reportProgress({
                type: 'tunnelOpened'
              });

              deferred.resolve();
            }
          });
          return deferred.promise;
        }
      })
      .then(function () {
        var testRunner = new TestRunner(arg, framework, reportProgress);
        return testRunner.runTests();
      })
      .fin(function () {
        var deferred;

        if (tunnel) {
          deferred = Q.defer();

          reportProgress({
            type: 'tunnelClose'
          });

          tunnel.stop(function () {
            deferred.resolve();
          });

          return deferred.promise;
        }
      })
      .then(
        function (passed) {
          callback(passed);
        },
        function (error) {
          grunt.log.error(error.stack || error.toString());
          callback(false);
        }
      )
      .done();
  }

  var defaults = {
    username: process.env.SAUCE_USERNAME,
    tunneled: true,
    identifier: Math.floor((new Date()).getTime() / 1000 - 1230768000).toString(),
    pollInterval: 1000 * 2,
    statusCheckAttempts: 90,
    testname: '',
    browsers: [{}],
    tunnelArgs: [],
    sauceConfig: {},
    maxRetries: 0
  };

  // Grunt will print the options hash to console.log when run in verbose
  // mode. This can cause credential leaks per issue #203. This block will allow
  // assignments so it can integrate with Grunt's APIs, but it will always
  // return the getter as a function so that the 'toString' and 'toJSON' can be
  // overidden.
  var key = process.env.SAUCE_ACCESS_KEY;
  Object.defineProperty(defaults, 'key', {
    enumerable: true,
    configurable: false,
    writeable: true,
    set: function (newKey) {
      key = newKey;
    },
    get: function () {
      var get = function () { return key; };
      get.toString = function () { return key ? "[hidden]" : undefined; };
      get.toJSON = get.toString;
      return get;
    }
  });

  grunt.registerMultiTask('saucelabs-jasmine', 'Run Jasmine test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'jasmine', done);
  });

  grunt.registerMultiTask('saucelabs-qunit', 'Run Qunit test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'qunit', done);
  });

  grunt.registerMultiTask('saucelabs-yui', 'Run YUI test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'YUI Test', done);
  });

  grunt.registerMultiTask('saucelabs-mocha', 'Run Mocha test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'mocha', done);
  });

  grunt.registerMultiTask('saucelabs-custom', 'Run custom test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'custom', done);
  });
};
<commit_msg>fix formatting<commit_after>'use strict';

module.exports = function (grunt) {
  var Q = require('q');
  var SauceTunnel = require('sauce-tunnel');
  var TestRunner = require('../src/TestRunner')(grunt);

  Q.longStackSupport = true;

  function unsupportedPort(url) {
    // Not all ports are proxied by Sauce Connect. List of supported ports is
    // available at https://saucelabs.com/docs/connect#localhost
    var portRegExp = /:(\d+)\//;
    var matches = portRegExp.exec(url);
    var port = matches ? parseInt(matches[1], 10) : null;
    var supportedPorts = [
        80, 443, 888, 2000, 2001, 2020, 2109, 2222, 2310, 3000, 3001, 3030,
        3210, 3333, 4000, 4001, 4040, 4321, 4502, 4503, 4567, 5000, 5001, 5050, 5555, 5432, 6000,
        6001, 6060, 6666, 6543, 7000, 7070, 7774, 7777, 8000, 8001, 8003, 8031, 8080, 8081, 8765,
        8888, 9000, 9001, 9080, 9090, 9876, 9877, 9999, 49221, 55001
      ];

    if (port) {
      return supportedPorts.indexOf(port) === -1;
    }

    return false;
  }

  function reportProgress(notification) {
    switch (notification.type) {
    case 'tunnelOpen':
      grunt.log.writeln('=> Starting Tunnel to Sauce Labs'.inverse.bold);
      break;
    case 'tunnelOpened':
      grunt.log.ok('Connected to Saucelabs');
      break;
    case 'tunnelClose':
      grunt.log.writeln('=> Stopping Tunnel to Sauce Labs'.inverse.bold);
      break;
    case 'tunnelEvent':
      if (notification.verbose) {
        grunt.verbose[notification.method](notification.text);
      } else {
        grunt.log[notification.method](notification.text);
      }
      break;
    case 'jobStarted':
      grunt.log.writeln('\n', notification.startedJobs, '/', notification.numberOfJobs, 'tests started');
      break;
    case 'jobCompleted':
      grunt.log.subhead('\nTested %s', notification.url);
      grunt.log.writeln('Platform: %s', notification.platform);

      if (notification.tunnelId && unsupportedPort(notification.url)) {
        grunt.log.writeln('Warning: This url might use a port that is not proxied by Sauce Connect.'.yellow);
      }

      grunt.log.writeln('Passed: %s', notification.passed);
      grunt.log.writeln('Url %s', notification.jobUrl);
      break;
    case 'testCompleted':
      grunt.log[notification.passed ? 'ok' : 'error']('All tests completed with status %s', notification.passed);
      break;
    case 'retrying':
      grunt.log.writeln('Timed out, retrying URL %s on browser %s', notification.url, JSON.stringify(notification.browser));
      break;
    default:
      grunt.log.error('Unexpected notification type');
    }
  }

  function createTunnel(arg) {
    var tunnel;

    reportProgress({
      type: 'tunnelOpen'
    });

    tunnel = new SauceTunnel(arg.username, arg.key(), arg.identifier, true, ['-P', '0'].concat(arg.tunnelArgs));

    ['write', 'writeln', 'error', 'ok', 'debug'].forEach(function (method) {
      tunnel.on('log:' + method, function (text) {
        reportProgress({
          type: 'tunnelEvent',
          verbose: false,
          method: method,
          text: text
        });
      });
      tunnel.on('verbose:' + method, function (text) {
        reportProgress({
          type: 'tunnelEvent',
          verbose: true,
          method: method,
          text: text
        });
      });
    });

    return tunnel;
  }

  function runTask(arg, framework, callback) {
    var tunnel;

    Q
      .fcall(function () {
        var deferred;

        if (arg.tunneled) {
          deferred = Q.defer();

          tunnel = createTunnel(arg);
          tunnel.start(function (succeeded) {
            if (!succeeded) {
              deferred.reject('Could not create tunnel to Sauce Labs');
            } else {
              reportProgress({
                type: 'tunnelOpened'
              });

              deferred.resolve();
            }
          });
          return deferred.promise;
        }
      })
      .then(function () {
        var testRunner = new TestRunner(arg, framework, reportProgress);
        return testRunner.runTests();
      })
      .fin(function () {
        var deferred;

        if (tunnel) {
          deferred = Q.defer();

          reportProgress({
            type: 'tunnelClose'
          });

          tunnel.stop(function () {
            deferred.resolve();
          });

          return deferred.promise;
        }
      })
      .then(
        function (passed) {
          callback(passed);
        },
        function (error) {
          grunt.log.error(error.stack || error.toString());
          callback(false);
        }
      )
      .done();
  }

  var defaults = {
    username: process.env.SAUCE_USERNAME,
    tunneled: true,
    identifier: Math.floor((new Date()).getTime() / 1000 - 1230768000).toString(),
    pollInterval: 1000 * 2,
    statusCheckAttempts: 90,
    testname: '',
    browsers: [{}],
    tunnelArgs: [],
    sauceConfig: {},
    maxRetries: 0
  };

  // Grunt will print the options hash to console.log when run in verbose
  // mode. This can cause credential leaks per issue #203. This block will allow
  // assignments so it can integrate with Grunt's APIs, but it will always
  // return the getter as a function so that the 'toString' and 'toJSON' can be
  // overidden.
  var key = process.env.SAUCE_ACCESS_KEY;
  Object.defineProperty(defaults, 'key', {
    enumerable: true,
    configurable: false,
    writeable: true,
    set: function (newKey) {
      key = newKey;
    },
    get: function () {
      var get = function () { return key; };
      get.toString = function () { return key ? "[hidden]" : undefined; };
      get.toJSON = get.toString;
      return get;
    }
  });

  grunt.registerMultiTask('saucelabs-jasmine', 'Run Jasmine test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'jasmine', done);
  });

  grunt.registerMultiTask('saucelabs-qunit', 'Run Qunit test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'qunit', done);
  });

  grunt.registerMultiTask('saucelabs-yui', 'Run YUI test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'YUI Test', done);
  });

  grunt.registerMultiTask('saucelabs-mocha', 'Run Mocha test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'mocha', done);
  });

  grunt.registerMultiTask('saucelabs-custom', 'Run custom test cases using Sauce Labs browsers', function () {
    var done = this.async();
    var arg = this.options(defaults);

    runTask(arg, 'custom', done);
  });
};
<|endoftext|>


<commit_before>/*
* Copyright (c) 2015 CoNWeT Lab., Universidad Politécnica de Madrid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var utils = require('./lib/utils');
var ConfigParser = require('wirecloud-config-parser');

module.exports = function (grunt) {

    function error (done, e) {
        if (typeof e === 'string') {
            grunt.verbose.error().error(e);
        } else {
            grunt.verbose.error().error(e.message);
        }
        grunt.log.error('Error overwriting mashable application component.');
        done(false);
    }

    grunt.registerMultiTask('wirecloud', 'Upload Mashable Application Components to a wirecloud instance.', function() {
        var done = this.async();

        // Merge task-specific and/or target-specific options with these defaults.
        var options = this.options({
            force: false,
            reporterOutput: null,
            instance: 'fiwarelab',
            overwrite: false,
            configFile: './src/config.xml'
        });

        // don't fail if there are problems uploading the MAC
        var force = options.force;
        delete options.force;

        if (typeof this.data.file !== 'string') {
            grunt.log.error('Missing info about the file to upload');
            return done(false);
        }

        var instance = grunt.option('target') ? grunt.option('target') : options.instance;
        var msg = 'Uploading ' + this.data.file + ' to ' + instance + '... ';
        grunt.log.write(msg);
        var canDelete = false;

        if (options.overwrite) {
            var configParser = new ConfigParser();
            configParser.setFile(options.configFile).then(function () {
                var name = options.mac_name ? options.mac_name : configParser.getName();
                var vendor = options.mac_vendor ? options.mac_vendor : configParser.getVendor();
                var version = options.mac_version ? options.mac_version : configParser.getVersion();

                // Check if MAC is already uploaded
                utils.mac_exists(grunt, instance, name, vendor, version).then(function (exists) {
                    canDelete = exists;
                })

                // Delete MAC if already uploaded
                .then(function () {
                    if (canDelete) {
                        return utils.delete_mac(grunt, instance, name, vendor, version);
                    }
                })

                // Upload new MAC
                .then(utils.upload_mac.bind(this, grunt, instance, this.data.file))

                // OK message and finish
                .then(function () {
                    grunt.log.ok();
                    done();
                })

                // Error catcher for all previous promises
                .catch(error.bind(null, done));
            }.bind(this))

            .catch(grunt.log.error);
        }

        // overwrite: false
        else {
            utils.upload_mac(grunt, options.instance, this.data.file).then(function () {
                grunt.log.ok();
                done();
            }, error.bind(null, done));
        }

    });

};
<commit_msg>Change use of wirecloud config parser<commit_after>/*
* Copyright (c) 2015 CoNWeT Lab., Universidad Politécnica de Madrid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var utils = require('./lib/utils');
var ConfigParser = require('wirecloud-config-parser');

module.exports = function (grunt) {

    function error (done, e) {
        if (typeof e === 'string') {
            grunt.verbose.error().error(e);
        } else {
            grunt.verbose.error().error(e.message);
        }
        grunt.log.error('Error overwriting mashable application component.');
        done(false);
    }

    grunt.registerMultiTask('wirecloud', 'Upload Mashable Application Components to a wirecloud instance.', function() {
        var done = this.async();

        // Merge task-specific and/or target-specific options with these defaults.
        var options = this.options({
            force: false,
            reporterOutput: null,
            instance: 'fiwarelab',
            overwrite: false,
            configFile: './src/config.xml'
        });

        // don't fail if there are problems uploading the MAC
        var force = options.force;
        delete options.force;

        if (typeof this.data.file !== 'string') {
            grunt.log.error('Missing info about the file to upload');
            return done(false);
        }

        var instance = grunt.option('target') ? grunt.option('target') : options.instance;
        var msg = 'Uploading ' + this.data.file + ' to ' + instance + '... ';
        grunt.log.write(msg);

        if (options.overwrite) {
            var configParser;
            try {
                configParser = new ConfigParser(options.configFile, true);
            } catch (e) {
                error(done, e);
            }
            var configData = configParser.getData();
            var name = options.mac_name ? options.mac_name : configData.name;
            var vendor = options.mac_vendor ? options.mac_vendor : configData.vendor;
            var version = options.mac_version ? options.mac_version : configData.version;

            // Check if MAC is already uploaded
            utils.mac_exists(grunt, instance, name, vendor, version).then(function (exists) {
                return exists;
            })

            // Delete MAC if already uploaded
            .then(function () {
                if (canDelete) {
                    return utils.delete_mac(grunt, instance, name, vendor, version);
                }
            })

            // Upload new MAC
            .then(utils.upload_mac.bind(this, grunt, instance, this.data.file))

            // OK message and finish
            .then(function () {
                grunt.log.ok();
                done();
            })

            // Error catcher for all previous promises
            .catch(error.bind(null, done));
        }

        // overwrite: false
        else {
            utils.upload_mac(grunt, options.instance, this.data.file).then(function () {
                grunt.log.ok();
                done();
            }, error.bind(null, done));
        }

    });

};
<|endoftext|>


<commit_before>var fs = require('fs');

var FileUploader = require("./FileUploader.js")
var BatchPreparer = require("./BatchPreparer.js")

var batchPreparer = new BatchPreparer();

var logBatches = function(batches){
	console.log("Found files:");

	batches.forEach(function(ftpBatch){
		ftpBatch.files.forEach(function(file){
			console.log(file.sourcePath);
		});

		ftpBatch.files.forEach(function(file){
			console.log(file.destinationPath);
		});
	});
};

var batches = [];

var uploadBatchesRecursive = function(uploader, i){
	if(i >= batches.length){
		console.log('Finished all uploads!');
		process.exit();
		return;
	}

	uploader.uploadFiles(batches[i].files, function(){
		uploadBatchesRecursive(uploader, i + 1);
	});
};

var upload = function(configFile){
	var config = JSON.parse(fs.readFileSync(configFile, 'utf8'));

	batchPreparer.prepare(config);

	if(config.debugMode === true)
		logBatches(config.ftpBatches);

	var uploader = new FileUploader(config);

	batches = config.ftpBatches;
	uploadBatchesRecursive(uploader, 0);
};

upload('ftp_config.json');<commit_msg>Handle ftp_config.json not exists<commit_after>var fs = require('fs');

var FileUploader = require("./FileUploader.js");
var BatchPreparer = require("./BatchPreparer.js");

var batchPreparer = new BatchPreparer();

var logBatches = function(batches){
	console.log("Found files:");

	batches.forEach(function(ftpBatch){
		ftpBatch.files.forEach(function(file){
			console.log(file.sourcePath);
		});

		ftpBatch.files.forEach(function(file){
			console.log(file.destinationPath);
		});
	});
};

var batches = [];

var uploadBatchesRecursive = function(uploader, i){
	if(i >= batches.length){
		console.log('Finished all uploads!');
		process.exit();
		return;
	}

	uploader.uploadFiles(batches[i].files, function(){
		uploadBatchesRecursive(uploader, i + 1);
	});
};

var upload = function(configFile){
	var config;

	try
	{
		config = JSON.parse(fs.readFileSync(configFile, 'utf8'));
	}
	catch(e)
	{
		if(e.errno == 34){
			console.log('Cannot find file ftp_config.json, exiting...');
			process.exit();
		}
		throw e;
	}

	batchPreparer.prepare(config);

	if(config.debugMode === true)
		logBatches(config.ftpBatches);

	var uploader = new FileUploader(config);

	batches = config.ftpBatches;
	uploadBatchesRecursive(uploader, 0);
};

upload('ftp_config.json');<|endoftext|>


<commit_before>'use strict';

treeherder.value("thPlatformNameMap", {
    "linux32": "Linux",
    "linux64": "Linux x64",
    "osx-10-6": "OS X 10.6",
    "osx-10-7": "OS X 10.7",
    "osx-10-8": "OS X 10.8",
    "osx-10-9": "OS X 10.9",
    "osx-10-10": "OS X 10.10",
    "osx-10-11": "OS X 10.11",
    "windowsxp": "Windows XP",
    "windows7-32": "Windows 7",
    "windows7-64": "Windows 7 x64",
    "windows8-32": "Windows 8",
    "windows8-64": "Windows 8 x64",
    "windows10-32": "Windows 10",
    "windows10-64": "Windows 10 x64",
    "windows2012-64": "Windows 2012 x64",
    "android-2-2-armv6": "Android 2.2 Armv6",
    "android-2-2": "Android 2.2",
    "android-2-3-armv6": "Android 2.3 Armv6",
    "android-2-3": "Android 2.3",
    "android-2-3-armv7-api9": "Android 2.3 API9",
    "android-4-0": "Android 4.0",
    "android-4-0-armv7-api10": "Android 4.0 API10+",
    "android-4-0-armv7-api11": "Android 4.0 API11+",
    "android-4-0-armv7-api15": "Android 4.0 API15+",
    "android-4-2-x86": "Android 4.2 x86",
    "android-4-2": "Android 4.2",
    "android-4-2-armv7-api11": "Android 4.2 API11+",
    "android-4-2-armv7-api15": "Android 4.2 API15+",
    "android-4-3": "Android 4.3",
    "android-4-3-armv7-api11": "Android 4.3 API11+",
    "android-4-3-armv7-api15": "Android 4.3 API15+",
    "android-4-4": "Android 4.4",
    "android-4-4-armv7-api11": "Android 4.4 API11+",
    "android-4-4-armv7-api15": "Android 4.4 API15+",
    "android-5-0-armv7-api11": "Android 5.0 API11+",
    "android-5-0-armv7-api15": "Android 5.0 API15+",
    "b2gdroid-4-0-armv7-api11": "B2GDroid 4.0 API11+",
    "b2gdroid-4-0-armv7-api15": "B2GDroid 4.0 API15+",
    "android-4-0-armv7-api11-partner1": "Android API11+ partner1",
    "android-4-0-armv7-api15-partner1": "Android API15+ partner1",
    "b2g-linux32": "B2G Desktop Linux",
    "b2g-linux64": "B2G Desktop Linux x64",
    "b2g-osx": "B2G Desktop OS X",
    "b2g-win32": "B2G Desktop Windows",
    "b2g-emu-ics": "B2G ICS Emulator",
    "b2g-emu-jb": "B2G JB Emulator",
    "b2g-emu-kk": "B2G KK Emulator",
    "b2g-emu-x86-kk": "B2G KK Emulator x86",
    "b2g-emu-l": "B2G L Emulator",
    "b2g-device-image" : "B2G Device Image",
    "mulet-linux32" : "Mulet Linux",
    "mulet-linux64" : "Mulet Linux x64",
    "mulet-osx": "Mulet OS X",
    "mulet-win32": "Mulet Windows",
    "graphene-linux64": "Graphene Linux x64",
    "graphene-osx": "Graphene OS X",
    "graphene-win64": "Graphene Windows x64",
    "horizon-linux64": "Horizon Linux x64",
    "horizon-osx": "Horizon OS X",
    "horizon-win64": "Horizon Windows x64",
    "other": "Other"
});

treeherder.value("thPlatformOrder", {
    "linux32": 0,
    "linux64": 1,
    "osx-10-6": 10,
    "osx-10-7": 11,
    "osx-10-8": 12,
    "osx-10-9": 13,
    "osx-10-10": 14,
    "osx-10-11": 15,
    "windowsxp": 20,
    "windows7-32": 21,
    "windows7-64": 22,
    "windows8-32": 23,
    "windows8-64": 24,
    "windows10-32": 25,
    "windows10-64": 26,
    "windows2012-64": 27,
    "android-2-2-armv6": 30,
    "android-2-2": 31,
    "android-2-3-armv6": 32,
    "android-2-3": 33,
    "android-2-3-armv7-api9": 34,
    "android-4-0": 35,
    "android-4-0-armv7-api10": 36,
    "android-4-0-armv7-api11": 37,
    "android-4-0-armv7-api15": 38,
    "android-4-2-x86": 39,
    "android-4-2": 40,
    "android-4-2-armv7-api11": 41,
    "android-4-2-armv7-api15": 42,
    "android-4-3": 43,
    "android-4-3-armv7-api11": 44,
    "android-4-3-armv7-api15": 45,
    "android-4-4": 46,
    "android-4-4-armv7-api11": 47,
    "android-4-4-armv7-api15": 48,
    "android-5-0-armv7-api11": 49,
    "android-5-0-armv7-api15": 50,
    "b2gdroid-4-0-armv7-api11": 51,
    "b2gdroid-4-0-armv7-api15": 52,
    "android-4-0-armv7-api11-partner1": 53,
    "android-4-0-armv7-api15-partner1": 54,
    "b2g-linux32": 55,
    "b2g-linux64": 56,
    "b2g-osx": 57,
    "b2g-win32": 58,
    "b2g-emu-ics": 59,
    "b2g-emu-jb": 50,
    "b2g-emu-kk": 61,
    "b2g-emu-x86-kk": 62,
    "b2g-emu-l": 63,
    "b2g-device-image" : 64,
    "mulet-linux32" : 65,
    "mulet-linux64" : 66,
    "mulet-osx": 67,
    "mulet-win32": 68,
    "graphene-linux64": 71,
    "graphene-osx": 72,
    "graphene-win64": 73,
    "horizon-linux64": 74,
    "horizon-osx": 75,
    "horizon-win64": 76,
    "other": 99,
});

treeherder.value("thOptionOrder", {
    "opt": 0,
    "pgo": 1,
    "asan": 2,
    "tsan": 3,
    "debug": 4,
    "cc": 5,
    "addon": 6,
});

treeherder.value("thFailureResults", ["testfailed", "busted", "exception"]);

treeherder.value("thFavicons", {
    "closed": "img/tree_closed.png",
    "open": "img/tree_open.png",
    "approval required": "img/tree_open.png",
    "unavailable": "img/tree_open.png"
});

treeherder.value("thRepoGroupOrder", {
    "development": 1,
    "project repositories": 2,
    "try": 3,
    "release-stabilization": 4,
    "taskcluster": 5,
    "qa automation tests": 6
});

treeherder.value("thDefaultRepo", "mozilla-inbound");

treeherder.value("thDateFormat", "EEE MMM d, H:mm:ss");

treeherder.value("phCompareDefaultOriginalRepo", "mozilla-inbound");

treeherder.value("phCompareDefaultNewRepo", "try");

treeherder.value("phTimeRanges", [
      { "value":86400, "text": "Last day" },
      { "value":604800, "text": "Last 7 days" },
      { "value":1209600, "text": "Last 14 days" },
      { "value":2592000, "text": "Last 30 days" },
      { "value":5184000, "text": "Last 60 days" },
      { "value":7776000, "text": "Last 90 days" },
      { "value":31536000, "text": "Last year" } ]);

treeherder.value("phDefaultTimeRangeValue", 1209600);

treeherder.value("phAlertResolutionMap", {
    UNTRIAGED: 0,
    INVALID: 1,
    WONTFIX: 2,
    RESOLVED: 3,
    INVESTIGATING: 4,
    DUPLICATE: 5
});

treeherder.value("phTalosDocumentationMap", {
    "a11yr": "a11y",
    "cart": "TART.2FCART",
    "damp": "DAMP",
    "dromaeo_css": "Dromaeo_Tests",
    "dromaeo_dom": "Dromaeo_Tests",
    "sessionrestore": "sessionrestore.2Fsessionrestore_no_auto_restore",
    "sessionrestore_no_auto_restore": "sessionrestore.2Fsessionrestore_no_auto_restore",
    "tart": "TART.2FCART",
    "tcanvasmark": "CanvasMark",
    "tp5n_main_normal_fileio": "xperf",
    "tp5n_main_normal_netio": "xperf",
    "tp5n_main_startup_fileio": "xperf",
    "tp5n_main_startup_netio": "xperf",
    "tp5n_nonmain_normal_fileio": "xperf",
    "tp5n_nonmain_normal_netio": "xperf",
    "tp5n_nonmain_startup_fileio": "xperf",
    "tp5o": "tp5",
    "tp5o_% processor time": ".25_CPU",
    "tp5o_main_rss": "RSS_.28Resident_Set_Size.29",
    "tp5o_modified page list bytes": "Modified_Page_List_Bytes",
    "tp5o_private bytes": "Private_Bytes",
    "tp5o_xres": "Xres_.28X_Resource_Monitoring.29",
    "tsvgr_opacity": "tsvg-opacity",
    "v8_7": "V8.2C_version_7",
});

treeherder.value("phTrySyntaxBuildPlatformMap", {
    "android-4-0-armv7-api11": "android-api-11",
    "osx-10-10": "macosx64",
    "windows7-32": "win32",
    "windows8-64": "win64",
    "windowsxp": "win32"
});

treeherder.value("phTrySyntaxTalosModifierMap", {
    "android-4-0-armv7-api11": "Android",
    "osx-10-10": "10.10",
    "windows7-32": "Windows 7",
    "windows8-64": "Windows 8",
    "windowsxp": "Windows XP"
});

treeherder.value('mcTalosConfigUrl',
                 'http://hg.mozilla.org/mozilla-central/raw-file/tip/testing/talos/talos.json');

treeherder.value("thJobNavSelectors",
    {
        ALL_JOBS: {
            name: "jobs",
            selector: ".job-btn, .selected-job, .selected-count"
        },
        UNCLASSIFIED_FAILURES: {
            name: "unclassified failures",
            selector: ".selected-job, .selected-count, " +
                      ".job-btn.btn-red, " +
                      ".job-btn.btn-orange, " +
                      ".job-btn.btn-purple"
        }
    }
);

treeherder.value("thPerformanceBranches", [
    "mozilla-inbound", "mozilla-central", "fx-team", "b2g-inbound"
]);
<commit_msg>Bug 1234320 - Fix mixed content warning<commit_after>'use strict';

treeherder.value("thPlatformNameMap", {
    "linux32": "Linux",
    "linux64": "Linux x64",
    "osx-10-6": "OS X 10.6",
    "osx-10-7": "OS X 10.7",
    "osx-10-8": "OS X 10.8",
    "osx-10-9": "OS X 10.9",
    "osx-10-10": "OS X 10.10",
    "osx-10-11": "OS X 10.11",
    "windowsxp": "Windows XP",
    "windows7-32": "Windows 7",
    "windows7-64": "Windows 7 x64",
    "windows8-32": "Windows 8",
    "windows8-64": "Windows 8 x64",
    "windows10-32": "Windows 10",
    "windows10-64": "Windows 10 x64",
    "windows2012-64": "Windows 2012 x64",
    "android-2-2-armv6": "Android 2.2 Armv6",
    "android-2-2": "Android 2.2",
    "android-2-3-armv6": "Android 2.3 Armv6",
    "android-2-3": "Android 2.3",
    "android-2-3-armv7-api9": "Android 2.3 API9",
    "android-4-0": "Android 4.0",
    "android-4-0-armv7-api10": "Android 4.0 API10+",
    "android-4-0-armv7-api11": "Android 4.0 API11+",
    "android-4-0-armv7-api15": "Android 4.0 API15+",
    "android-4-2-x86": "Android 4.2 x86",
    "android-4-2": "Android 4.2",
    "android-4-2-armv7-api11": "Android 4.2 API11+",
    "android-4-2-armv7-api15": "Android 4.2 API15+",
    "android-4-3": "Android 4.3",
    "android-4-3-armv7-api11": "Android 4.3 API11+",
    "android-4-3-armv7-api15": "Android 4.3 API15+",
    "android-4-4": "Android 4.4",
    "android-4-4-armv7-api11": "Android 4.4 API11+",
    "android-4-4-armv7-api15": "Android 4.4 API15+",
    "android-5-0-armv7-api11": "Android 5.0 API11+",
    "android-5-0-armv7-api15": "Android 5.0 API15+",
    "b2gdroid-4-0-armv7-api11": "B2GDroid 4.0 API11+",
    "b2gdroid-4-0-armv7-api15": "B2GDroid 4.0 API15+",
    "android-4-0-armv7-api11-partner1": "Android API11+ partner1",
    "android-4-0-armv7-api15-partner1": "Android API15+ partner1",
    "b2g-linux32": "B2G Desktop Linux",
    "b2g-linux64": "B2G Desktop Linux x64",
    "b2g-osx": "B2G Desktop OS X",
    "b2g-win32": "B2G Desktop Windows",
    "b2g-emu-ics": "B2G ICS Emulator",
    "b2g-emu-jb": "B2G JB Emulator",
    "b2g-emu-kk": "B2G KK Emulator",
    "b2g-emu-x86-kk": "B2G KK Emulator x86",
    "b2g-emu-l": "B2G L Emulator",
    "b2g-device-image" : "B2G Device Image",
    "mulet-linux32" : "Mulet Linux",
    "mulet-linux64" : "Mulet Linux x64",
    "mulet-osx": "Mulet OS X",
    "mulet-win32": "Mulet Windows",
    "graphene-linux64": "Graphene Linux x64",
    "graphene-osx": "Graphene OS X",
    "graphene-win64": "Graphene Windows x64",
    "horizon-linux64": "Horizon Linux x64",
    "horizon-osx": "Horizon OS X",
    "horizon-win64": "Horizon Windows x64",
    "other": "Other"
});

treeherder.value("thPlatformOrder", {
    "linux32": 0,
    "linux64": 1,
    "osx-10-6": 10,
    "osx-10-7": 11,
    "osx-10-8": 12,
    "osx-10-9": 13,
    "osx-10-10": 14,
    "osx-10-11": 15,
    "windowsxp": 20,
    "windows7-32": 21,
    "windows7-64": 22,
    "windows8-32": 23,
    "windows8-64": 24,
    "windows10-32": 25,
    "windows10-64": 26,
    "windows2012-64": 27,
    "android-2-2-armv6": 30,
    "android-2-2": 31,
    "android-2-3-armv6": 32,
    "android-2-3": 33,
    "android-2-3-armv7-api9": 34,
    "android-4-0": 35,
    "android-4-0-armv7-api10": 36,
    "android-4-0-armv7-api11": 37,
    "android-4-0-armv7-api15": 38,
    "android-4-2-x86": 39,
    "android-4-2": 40,
    "android-4-2-armv7-api11": 41,
    "android-4-2-armv7-api15": 42,
    "android-4-3": 43,
    "android-4-3-armv7-api11": 44,
    "android-4-3-armv7-api15": 45,
    "android-4-4": 46,
    "android-4-4-armv7-api11": 47,
    "android-4-4-armv7-api15": 48,
    "android-5-0-armv7-api11": 49,
    "android-5-0-armv7-api15": 50,
    "b2gdroid-4-0-armv7-api11": 51,
    "b2gdroid-4-0-armv7-api15": 52,
    "android-4-0-armv7-api11-partner1": 53,
    "android-4-0-armv7-api15-partner1": 54,
    "b2g-linux32": 55,
    "b2g-linux64": 56,
    "b2g-osx": 57,
    "b2g-win32": 58,
    "b2g-emu-ics": 59,
    "b2g-emu-jb": 50,
    "b2g-emu-kk": 61,
    "b2g-emu-x86-kk": 62,
    "b2g-emu-l": 63,
    "b2g-device-image" : 64,
    "mulet-linux32" : 65,
    "mulet-linux64" : 66,
    "mulet-osx": 67,
    "mulet-win32": 68,
    "graphene-linux64": 71,
    "graphene-osx": 72,
    "graphene-win64": 73,
    "horizon-linux64": 74,
    "horizon-osx": 75,
    "horizon-win64": 76,
    "other": 99,
});

treeherder.value("thOptionOrder", {
    "opt": 0,
    "pgo": 1,
    "asan": 2,
    "tsan": 3,
    "debug": 4,
    "cc": 5,
    "addon": 6,
});

treeherder.value("thFailureResults", ["testfailed", "busted", "exception"]);

treeherder.value("thFavicons", {
    "closed": "img/tree_closed.png",
    "open": "img/tree_open.png",
    "approval required": "img/tree_open.png",
    "unavailable": "img/tree_open.png"
});

treeherder.value("thRepoGroupOrder", {
    "development": 1,
    "project repositories": 2,
    "try": 3,
    "release-stabilization": 4,
    "taskcluster": 5,
    "qa automation tests": 6
});

treeherder.value("thDefaultRepo", "mozilla-inbound");

treeherder.value("thDateFormat", "EEE MMM d, H:mm:ss");

treeherder.value("phCompareDefaultOriginalRepo", "mozilla-inbound");

treeherder.value("phCompareDefaultNewRepo", "try");

treeherder.value("phTimeRanges", [
      { "value":86400, "text": "Last day" },
      { "value":604800, "text": "Last 7 days" },
      { "value":1209600, "text": "Last 14 days" },
      { "value":2592000, "text": "Last 30 days" },
      { "value":5184000, "text": "Last 60 days" },
      { "value":7776000, "text": "Last 90 days" },
      { "value":31536000, "text": "Last year" } ]);

treeherder.value("phDefaultTimeRangeValue", 1209600);

treeherder.value("phAlertResolutionMap", {
    UNTRIAGED: 0,
    INVALID: 1,
    WONTFIX: 2,
    RESOLVED: 3,
    INVESTIGATING: 4,
    DUPLICATE: 5
});

treeherder.value("phTalosDocumentationMap", {
    "a11yr": "a11y",
    "cart": "TART.2FCART",
    "damp": "DAMP",
    "dromaeo_css": "Dromaeo_Tests",
    "dromaeo_dom": "Dromaeo_Tests",
    "sessionrestore": "sessionrestore.2Fsessionrestore_no_auto_restore",
    "sessionrestore_no_auto_restore": "sessionrestore.2Fsessionrestore_no_auto_restore",
    "tart": "TART.2FCART",
    "tcanvasmark": "CanvasMark",
    "tp5n_main_normal_fileio": "xperf",
    "tp5n_main_normal_netio": "xperf",
    "tp5n_main_startup_fileio": "xperf",
    "tp5n_main_startup_netio": "xperf",
    "tp5n_nonmain_normal_fileio": "xperf",
    "tp5n_nonmain_normal_netio": "xperf",
    "tp5n_nonmain_startup_fileio": "xperf",
    "tp5o": "tp5",
    "tp5o_% processor time": ".25_CPU",
    "tp5o_main_rss": "RSS_.28Resident_Set_Size.29",
    "tp5o_modified page list bytes": "Modified_Page_List_Bytes",
    "tp5o_private bytes": "Private_Bytes",
    "tp5o_xres": "Xres_.28X_Resource_Monitoring.29",
    "tsvgr_opacity": "tsvg-opacity",
    "v8_7": "V8.2C_version_7",
});

treeherder.value("phTrySyntaxBuildPlatformMap", {
    "android-4-0-armv7-api11": "android-api-11",
    "osx-10-10": "macosx64",
    "windows7-32": "win32",
    "windows8-64": "win64",
    "windowsxp": "win32"
});

treeherder.value("phTrySyntaxTalosModifierMap", {
    "android-4-0-armv7-api11": "Android",
    "osx-10-10": "10.10",
    "windows7-32": "Windows 7",
    "windows8-64": "Windows 8",
    "windowsxp": "Windows XP"
});

treeherder.value('mcTalosConfigUrl',
                 'https://hg.mozilla.org/mozilla-central/raw-file/tip/testing/talos/talos.json');

treeherder.value("thJobNavSelectors",
    {
        ALL_JOBS: {
            name: "jobs",
            selector: ".job-btn, .selected-job, .selected-count"
        },
        UNCLASSIFIED_FAILURES: {
            name: "unclassified failures",
            selector: ".selected-job, .selected-count, " +
                      ".job-btn.btn-red, " +
                      ".job-btn.btn-orange, " +
                      ".job-btn.btn-purple"
        }
    }
);

treeherder.value("thPerformanceBranches", [
    "mozilla-inbound", "mozilla-central", "fx-team", "b2g-inbound"
]);
<|endoftext|>