<commit_before>jasmine.getEnv().defaultTimeoutInterval = 2000;

describe('ZSS Client', function() {
  var Client = require('../../client');
  var errors = require('../../config/errors');
  var zmq = require('zmq');
  var uuid = require('uuid');
  var Message = require('zmq-service-suite-message');
  var Q = require('q');
  var _ = require('lodash');

  var config = {
    broker: 'ipc://tmp/test',
    sid: 'service-identifier',
    identity: "clientX",
    timeout: 500
  };

  describe('#call', function() {

    var client;
    beforeEach(function(){
      client = new Client(config);
      spyOn(uuid, 'v1').andReturn("uuid");
    });

    it('returns a Promise', function() {
      var promise = client.call('foo');

      expect(promise.then).toEqual(jasmine.any(Function));
    });

    describe('connects the zmq socket', function(){

      it('with dealer type', function() {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: Function.apply()
        });

        client.call('foo');
        expect(zmq.socket).toHaveBeenCalledWith('dealer');
      });

      it('with setted identity', function(done) {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: function(uri) {
            expect(this.identity).toEqual("clientX#uuid");
            done();
          }
        });

        client.call('foo');
      });

      it('with setted linger', function(done) {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: function(uri) {
            expect(this.linger).toEqual(0);
            done();
          }
        });

        client.call('foo');
      });

      it('with broker address', function(done) {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: function(uri) {
            expect(uri).toEqual(config.broker);
            done();
          }
        });

        client.call('foo');
      });

    });

    it('registers a "message" callback', function(done) {
      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: Function.apply(),
        on: function(type) {
          if (type === 'message') {
            done();
          }
        }
      });

      client.call('foo');
    });

    it('registers a "error" callback', function(done) {
      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: Function.apply(),
        on: function(type) {
          if (type === 'error') {
            done();
          }
        }
      });

      client.call('foo');
    });

    it('closes the socket when the promise is resolved', function(done) {
      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: Function.apply(),
        on: Function.apply(),
        close: function() {
          done();
        }
      });

      var dfd = Q.defer();
      spyOn(Q, 'defer').andReturn(dfd);

      client.call('foo');
      dfd.resolve();
    });

    it('sends request to socket', function(done) {
      var payload = { something: "payload" };
      var headers = { header: "data" };

      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: function(frames){
          frames.unshift('identity');
          var msg = Message.parse(frames);
          expect(msg.type).toEqual(Message.Type.REQ);
          expect(msg.address.sid).toEqual(config.sid.toUpperCase());
          expect(msg.address.verb).toEqual('FOO');
          expect(msg.payload).toEqual(payload);
          expect(msg.headers).toEqual(headers);
          done();
        },
        on: Function.apply(),
        close: Function.apply()
      });

      client.call('foo', payload, { headers: headers });
    });

    describe('on success', function(){
      var msg;

      beforeEach(function(){
        msg = new Message('sid', 'verb');
        msg.type = Message.Type.REP;
        msg.status = 200;
        msg.payload = "data";
        msg.headers = { something: "data" };

        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: function(type, callback) {
            if (type === 'message') {
              callback.apply(null, msg.toFrames());
            }
          }
        });
      });

      it('resolves the promise with the msg status 200', function(done) {
        client.call('foo')
          .then(function(response){
            expect(response.status).toEqual(200);
            done();
          });
      });

      it('resolves the promise with different success status code', function(done) {
        msg.status = 204;
        client.call('foo')
          .then(function(response){
            expect(response.status).toEqual(204);
            done();
          });
      });

      it('resolves the promise with the payload', function(done) {
        client.call('foo')
          .then(function(response){
            expect(response.payload).toEqual(msg.payload);
            done();
          });
      });

      it('resolves the promise with the headers', function(done) {
        client.call('foo')
          .then(function(response, headers){
            expect(response.headers).toEqual(msg.headers);
            done();
          });
      });
    });

    describe('on error', function(){
      describe('when it receives a error payload', function(){
        var msg;
        beforeEach(function(){
          msg = new Message('sid', 'verb');
          msg.type = Message.Type.REP;

          spyOn(zmq, 'socket').andReturn({
            connect: Function.apply(),
            send: Function.apply(),
            on: function(type, callback) {
              if (type === 'message') {
                callback.apply(null, msg.toFrames());
              }
            }
          });
        });

        it('rejects the promise with the default 500 error', function(done) {
          msg.status = 500;
          client.call('foo')
            .fail(function(error){
              expect(error.code).toBe(500);
              expect(error.userMessage).toBe(errors["500"].userMessage);
              expect(error.developerMessage).toBe(errors["500"].developerMessage);
              done();
            });
        });

        describe('handles errors retrieved by the service', function(){
          it('rejects the promise with the 4xx error', function(done) {
            var serviceError = _.cloneDeep(errors["404"]);
            serviceError.developerMessage = "some usefull message";
            msg.status = 404;
            msg.payload = serviceError;

            client.call('foo')
              .fail(function(error){
                expect(error.code).toBe(404);
                expect(error.userMessage).toBe(serviceError.userMessage);
                expect(error.developerMessage).toBe(serviceError.developerMessage);
                done();
              });
          });

          it('rejects the promise with the 5xx error', function(done) {
            var serviceError = _.cloneDeep(errors["599"]);
            serviceError.developerMessage = "some usefull message";
            msg.status = 599;
            msg.payload = serviceError;

            client.call('foo')
              .fail(function(error){
                expect(error.code).toBe(599);
                expect(error.userMessage).toBe(serviceError.userMessage);
                expect(error.developerMessage).toBe(serviceError.developerMessage);
                done();
              });
          });

          describe('when error contract isnt valid', function(){

            it('rejects the promise with the default error for status', function(done) {
              msg.status = 404;
              msg.payload = {};
              client.call('foo')
                .fail(function(error){
                  expect(error.code).toBe(404);
                  expect(error.userMessage).toBe(errors["404"].userMessage);
                  expect(error.developerMessage).toBe(errors["404"].developerMessage);
                  done();
                });
            });
          });

          it('rejects the promise with the default 500 if status not in errors', function(done) {
            msg.status = 409;
            msg.payload = {};

            client.call('foo')
              .fail(function(error){
                expect(error.code).toBe(500);
                expect(error.userMessage).toBe(errors["500"].userMessage);
                expect(error.developerMessage).toBe(errors["500"].developerMessage);
                done();
              });
          });
        });
      });

      it('fails the promise with the 500 error when the "error" callback is executed', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: function(type, callback) {
            if (type === 'error') {
              callback(new Error('something happen'));
            }
          }
        });

        var client = new Client(config);
        client.call('foo')
          .fail(function(error){
            expect(error.code).toBe(500);
            done();
          });
      });

      it('closes the socket when the promise is rejected', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: function() {
            done();
          }
        });

        var dfd = Q.defer();
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo');
        dfd.reject();
      });

    });

    describe('Timeout', function() {

      it('rejects the promise with the timeout error on default timeout', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        setTimeout(dfd.resolve, 1500);
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {})
          .fail(function (error) {
            expect(error.code).toBe(599);
            done();
          });
      });

      it('fails the promise with the timeout error with a given timeout', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        setTimeout(dfd.resolve, 250);
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {}, {timeout: 10})
          .fail(function (error) {
            expect(error.code).toBe(599);
            done();
          });
      });

      it('fails the promise with the timeout error with a default timeout from config', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        setTimeout(dfd.resolve, 600);
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {})
          .fail(function (error) {
            expect(error.code).toBe(599);
            done();
          });
      });

      it('resolves the promise before timeout', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {}, {timeout: 1000})
          .then(function () {
            done();
          });

        dfd.resolve();
      });
    });

  });
});
<commit_msg>ensure test only assert proper header<commit_after>jasmine.getEnv().defaultTimeoutInterval = 2000;

describe('ZSS Client', function() {
  var Client = require('../../client');
  var errors = require('../../config/errors');
  var zmq = require('zmq');
  var uuid = require('uuid');
  var Message = require('zmq-service-suite-message');
  var Q = require('q');
  var _ = require('lodash');

  var config = {
    broker: 'ipc://tmp/test',
    sid: 'service-identifier',
    identity: "clientX",
    timeout: 500
  };

  describe('#call', function() {

    var client;
    beforeEach(function(){
      client = new Client(config);
      spyOn(uuid, 'v1').andReturn("uuid");
    });

    it('returns a Promise', function() {
      var promise = client.call('foo');

      expect(promise.then).toEqual(jasmine.any(Function));
    });

    describe('connects the zmq socket', function(){

      it('with dealer type', function() {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: Function.apply()
        });

        client.call('foo');
        expect(zmq.socket).toHaveBeenCalledWith('dealer');
      });

      it('with setted identity', function(done) {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: function(uri) {
            expect(this.identity).toEqual("clientX#uuid");
            done();
          }
        });

        client.call('foo');
      });

      it('with setted linger', function(done) {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: function(uri) {
            expect(this.linger).toEqual(0);
            done();
          }
        });

        client.call('foo');
      });

      it('with broker address', function(done) {
        spyOn(zmq, 'socket').andReturn({
          send: Function.apply(),
          on: Function.apply(),
          connect: function(uri) {
            expect(uri).toEqual(config.broker);
            done();
          }
        });

        client.call('foo');
      });

    });

    it('registers a "message" callback', function(done) {
      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: Function.apply(),
        on: function(type) {
          if (type === 'message') {
            done();
          }
        }
      });

      client.call('foo');
    });

    it('registers a "error" callback', function(done) {
      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: Function.apply(),
        on: function(type) {
          if (type === 'error') {
            done();
          }
        }
      });

      client.call('foo');
    });

    it('closes the socket when the promise is resolved', function(done) {
      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: Function.apply(),
        on: Function.apply(),
        close: function() {
          done();
        }
      });

      var dfd = Q.defer();
      spyOn(Q, 'defer').andReturn(dfd);

      client.call('foo');
      dfd.resolve();
    });

    it('sends request to socket', function(done) {
      var payload = { something: "payload" };
      var headers = { header: "data" };

      spyOn(zmq, 'socket').andReturn({
        connect: Function.apply(),
        send: function(frames){
          frames.unshift('identity');
          var msg = Message.parse(frames);
          expect(msg.type).toEqual(Message.Type.REQ);
          expect(msg.address.sid).toEqual(config.sid.toUpperCase());
          expect(msg.address.verb).toEqual('FOO');
          expect(msg.payload).toEqual(payload);
          expect(msg.headers).toEqual(headers);
          done();
        },
        on: Function.apply(),
        close: Function.apply()
      });

      client.call('foo', payload, { headers: headers });
    });

    describe('on success', function(){
      var msg;

      beforeEach(function(){
        msg = new Message('sid', 'verb');
        msg.type = Message.Type.REP;
        msg.status = 200;
        msg.payload = "data";
        msg.headers = { something: "data" };

        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: function(type, callback) {
            if (type === 'message') {
              callback.apply(null, msg.toFrames());
            }
          }
        });
      });

      it('resolves the promise with the msg status 200', function(done) {
        client.call('foo')
          .then(function(response){
            expect(response.status).toEqual(200);
            done();
          });
      });

      it('resolves the promise with different success status code', function(done) {
        msg.status = 204;
        client.call('foo')
          .then(function(response){
            expect(response.status).toEqual(204);
            done();
          });
      });

      it('resolves the promise with the payload', function(done) {
        client.call('foo')
          .then(function(response){
            expect(response.payload).toEqual(msg.payload);
            done();
          });
      });

      it('resolves the promise with the headers', function(done) {
        client.call('foo')
          .then(function(response, headers){
            expect(response.headers.something).toEqual(msg.headers.something);
            done();
          });
      });
    });

    describe('on error', function(){
      describe('when it receives a error payload', function(){
        var msg;
        beforeEach(function(){
          msg = new Message('sid', 'verb');
          msg.type = Message.Type.REP;

          spyOn(zmq, 'socket').andReturn({
            connect: Function.apply(),
            send: Function.apply(),
            on: function(type, callback) {
              if (type === 'message') {
                callback.apply(null, msg.toFrames());
              }
            }
          });
        });

        it('rejects the promise with the default 500 error', function(done) {
          msg.status = 500;
          client.call('foo')
            .fail(function(error){
              expect(error.code).toBe(500);
              expect(error.userMessage).toBe(errors["500"].userMessage);
              expect(error.developerMessage).toBe(errors["500"].developerMessage);
              done();
            });
        });

        describe('handles errors retrieved by the service', function(){
          it('rejects the promise with the 4xx error', function(done) {
            var serviceError = _.cloneDeep(errors["404"]);
            serviceError.developerMessage = "some usefull message";
            msg.status = 404;
            msg.payload = serviceError;

            client.call('foo')
              .fail(function(error){
                expect(error.code).toBe(404);
                expect(error.userMessage).toBe(serviceError.userMessage);
                expect(error.developerMessage).toBe(serviceError.developerMessage);
                done();
              });
          });

          it('rejects the promise with the 5xx error', function(done) {
            var serviceError = _.cloneDeep(errors["599"]);
            serviceError.developerMessage = "some usefull message";
            msg.status = 599;
            msg.payload = serviceError;

            client.call('foo')
              .fail(function(error){
                expect(error.code).toBe(599);
                expect(error.userMessage).toBe(serviceError.userMessage);
                expect(error.developerMessage).toBe(serviceError.developerMessage);
                done();
              });
          });

          describe('when error contract isnt valid', function(){

            it('rejects the promise with the default error for status', function(done) {
              msg.status = 404;
              msg.payload = {};
              client.call('foo')
                .fail(function(error){
                  expect(error.code).toBe(404);
                  expect(error.userMessage).toBe(errors["404"].userMessage);
                  expect(error.developerMessage).toBe(errors["404"].developerMessage);
                  done();
                });
            });
          });

          it('rejects the promise with the default 500 if status not in errors', function(done) {
            msg.status = 409;
            msg.payload = {};

            client.call('foo')
              .fail(function(error){
                expect(error.code).toBe(500);
                expect(error.userMessage).toBe(errors["500"].userMessage);
                expect(error.developerMessage).toBe(errors["500"].developerMessage);
                done();
              });
          });
        });
      });

      it('fails the promise with the 500 error when the "error" callback is executed', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: function(type, callback) {
            if (type === 'error') {
              callback(new Error('something happen'));
            }
          }
        });

        var client = new Client(config);
        client.call('foo')
          .fail(function(error){
            expect(error.code).toBe(500);
            done();
          });
      });

      it('closes the socket when the promise is rejected', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: function() {
            done();
          }
        });

        var dfd = Q.defer();
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo');
        dfd.reject();
      });

    });

    describe('Timeout', function() {

      it('rejects the promise with the timeout error on default timeout', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        setTimeout(dfd.resolve, 1500);
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {})
          .fail(function (error) {
            expect(error.code).toBe(599);
            done();
          });
      });

      it('fails the promise with the timeout error with a given timeout', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        setTimeout(dfd.resolve, 250);
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {}, {timeout: 10})
          .fail(function (error) {
            expect(error.code).toBe(599);
            done();
          });
      });

      it('fails the promise with the timeout error with a default timeout from config', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        setTimeout(dfd.resolve, 600);
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {})
          .fail(function (error) {
            expect(error.code).toBe(599);
            done();
          });
      });

      it('resolves the promise before timeout', function(done) {
        spyOn(zmq, 'socket').andReturn({
          connect: Function.apply(),
          send: Function.apply(),
          on: Function.apply(),
          close: Function.apply(),
        });

        var dfd = Q.defer();
        spyOn(Q, 'defer').andReturn(dfd);

        client.call('foo', {}, {timeout: 1000})
          .then(function () {
            done();
          });

        dfd.resolve();
      });
    });

  });
});
<|endoftext|>


<commit_before>var User = require('../../server/api/users/userModel.js'),
    Roadmap = require('../../server/api/roadmaps/roadmapModel.js'),
    Node = require('../../server/api/nodes/nodeModel.js');

var users = [
  {
    username : 'bowieloverx950',
    password : 'c',
    firstName: 'Bob',
    lastName : 'Johnson',
    roadmaps : []
  },

  {
    username : 'supercoder31337',
    password : 'a',
    firstName: 'Susan',
    lastName : 'Kozlowski',
    roadmaps : []
  },

  {
    username : 'alex<3hiphop',
    password : 'b',
    firstName: 'Alejandro',
    lastName : 'Bautista',
    roadmaps : []
  }
];

var maps = [
  {
    title      : 'Understanding Bowie',
    description: 'This roadmap will help you learn about David Bowie',
    nodes      : []
  },

  {
    title      : 'Learning JavaScript',
    description: '134rn 2 b 4n 1337 h4xx0rz',
    nodes      : []
  },

  {
    title      : 'Straight Outta Knowing Nothing About Straight Outta Compton',
    description: 'Your hip hop history. Learn it.',
    nodes      : []
  }
];

var nodes = [
  {
    title        : 'Watch Life On Mars?',
    description  : 'Watch this classic. Absorb the Bowie.',
    resourceType : 'Music Video',
    resourceURL  : 'https://www.youtube.com/watch?v=v--IqqusnNQ',
    parentRoadmap: []
  },

  {
    title        : 'Take Codecademy\'s Intro Course',
    description  : 'OMG 1f u c4nt h4x th15 w4t h0p d0 u h4v???',
    resourceType : 'Online Course',
    resourceURL  : 'https://www.codecademy.com/learn/javascript',
    parentRoadmap: []
  },

  {
    title        : 'Watch Straight Outta Compton',
    description  : 'It\'s in the name. Watch it.',
    resourceType : 'Music Video',
    resourceURL  : 'https://www.youtube.com/watch?v=TMZi25Pq3T8',
    parentRoadmap: []
  }
];

module.exports.users = users;
module.exports.maps = maps;
module.exports.nodes = nodes;

module.exports.seedUsers = function(next) {

  var addUser = function(i) {
    if (i >= users.length) return next && next();

    User(users[i]).save()
      .then(function (user) {
        if (user) users[i] = user;
        addUser(i + 1);
      });
  };

  addUser(0);
};

module.exports.clearUsers = function(next) {

  var clearUser = function(i) {
    if (i >= users.length) return next && next();

    User.findOne(users[i].username)
      .then(function (user) {
        if (user) user.remove();
        clearUser(i + 1);
      });
  };

  clearUser(0);
};

module.exports.seedData = function(next) {

  var addRoadmap = function(i) {
    if (i >= maps.length) return next && next();

    maps[i].author = users[i]._id;

    Roadmap(maps[i]).save()
      .then(function (map) {
        if (map) maps[i] = map;
        addRoadmap(i + 1);
      });
  };

  module.exports.seedUsers(addRoadmap.bind(null, 0));
};

module.exports.clearData = function(next) {

  var clearRoadmap = function(i) {
    if (i >= maps.length) return next && next();

    Roadmap.findOne(maps[i]._id)
      .then(function (map) {
        if (map) map.remove();
        clearRoadmap(i + 1);
      });
  };

  module.exports.clearUsers(clearRoadmap.bind(null, 0));
};
<commit_msg>(refactor) Change test data somehow.<commit_after>var User = require('../../server/api/users/userModel.js'),
    Roadmap = require('../../server/api/roadmaps/roadmapModel.js'),
    Node = require('../../server/api/nodes/nodeModel.js');

var users = [
  {
    username : 'bowieloverx950',
    password : 'c',
    firstName: 'Bob',
    lastName : 'Johnson',
    roadmaps : []
  },

  {
    username : 'supercoder31337',
    password : 'a',
    firstName: 'Susan',
    lastName : 'Kozlowski',
    roadmaps : []
  },

  {
    username : 'alex<3hiphop',
    password : 'b',
    firstName: 'Alejandro',
    lastName : 'Bautista',
    roadmaps : []
  }
];

var maps = [
  {
    title      : 'Understanding Bowie',
    description: 'This roadmap will help you learn about David Bowie',
    nodes      : []
  },

  {
    title      : 'Learning JavaScript',
    description: '134rn 2 b 4n 1337 h4xx0rz',
    nodes      : []
  },

  {
    title      : 'Straight Outta Knowing Nothing About Straight Outta Compton',
    description: 'Your hip hop history. Learn it.',
    nodes      : []
  }
];

var nodes = [
  {
    title        : 'Watch Life On Mars?',
    description  : 'Watch this classic. Absorb the Bowie.',
    resourceType : 'Music Video',
    resourceURL  : 'https://www.youtube.com/watch?v=v--IqqusnNQ',
    parentRoadmap: []
  },

  {
    title        : 'Take Codecademy\'s Intro Course',
    description  : 'OMG 1f u c4nt h4x th15 w4t h0p d0 u h4v???',
    resourceType : 'Online Course',
    resourceURL  : 'https://www.codecademy.com/learn/javascript',
    parentRoadmap: []
  },

  {
    title        : 'Watch Straight Outta Compton',
    description  : 'It\'s in the name. Watch it.',
    resourceType : 'Music Video',
    resourceURL  : 'https://www.youtube.com/watch?v=TMZi25Pq3T8',
    parentRoadmap: []
  }
];

module.exports.users = users;
module.exports.maps = maps;
module.exports.nodes = nodes;

module.exports.seedUsers = function(next) {

  var addUser = function(i) {
    if (i >= users.length) return next && next();

    User(users[i]).save()
      .then(function (user) {
        if (user) users[i] = user;
        addUser(i + 1);
      });
  };

  addUser(0);
};

module.exports.clearUsers = function(next) {

  var clearUser = function(i) {
    if (i >= users.length) return next && next();

    User.findOne(users[i].username)
      .then(function (user) {
        if (user) user.remove();
        clearUser(i + 1);
      });
  };

  clearUser(0);
};

module.exports.seedData = function(next) {

  var addRoadmap = function(i) {
    if (i >= maps.length) return next && next();

    maps[i].author = users[i]._id;

    Roadmap(maps[i]).save()
      .then(function (map) {
        if (map) maps[i] = map;
        addRoadmap(i + 1);
      });
  };

  module.exports.seedUsers(addRoadmap.bind(null, 0));
};

module.exports.clearData = function(next) {

  var clearRoadmap = function(i) {
    if (i >= maps.length) return next && next();

    Roadmap.findOne(maps[i]._id)
      .then(function (map) {
        if (map) map.remove();
        clearRoadmap(i + 1);
      });
  };

  module.exports.clearUsers(clearRoadmap.bind(null, 0));
};<|endoftext|>


<commit_before>'use strict';
/**
 * @ngdoc overview
 * @name app
 * @description
 * # app
 *
 * Main module of the application.
 */
angular.module('beoi', [
  'beoi.modules.main',
  'beoi.modules.dashboard',
  'beoi.modules.contest',
  'beoi.modules.contestant',
  'auth0'
]).config([
  'authProvider', '$httpProvider', '$logProvider',
  function (authProvider, $httpProvider, $logProvider) {
  console.log('app.config');
  $logProvider.debugEnabled(true);
  authProvider.init({
    domain: 'beoi.auth0.com',
    clientID: 'dmr6gDogihnwo6O47BD6eclcqjvITc8q',
    callbackURL: location.href
  });
}])
.run(['auth',function(auth) {
  console.log('app.run');
  // This hooks al auth events to check everything as soon as the app starts
  auth.hookEvents();
}]);
<commit_msg>disable debugging<commit_after>'use strict';
/**
 * @ngdoc overview
 * @name app
 * @description
 * # app
 *
 * Main module of the application.
 */
angular.module('beoi', [
  'beoi.modules.main',
  'beoi.modules.dashboard',
  'beoi.modules.contest',
  'beoi.modules.contestant',
  'auth0'
]).config([
  'authProvider', '$httpProvider', '$logProvider',
  function (authProvider, $httpProvider, $logProvider) {
  console.log('app.config');
  $logProvider.debugEnabled(false);
  authProvider.init({
    domain: 'beoi.auth0.com',
    clientID: 'dmr6gDogihnwo6O47BD6eclcqjvITc8q',
    callbackURL: location.href
  });
}])
.run(['auth',function(auth) {
  console.log('app.run');
  // This hooks al auth events to check everything as soon as the app starts
  auth.hookEvents();
}]);
<|endoftext|>


<commit_before>const Cast = require('../util/cast.js');
const MathUtil = require('../util/math-util.js');

class Scratch3OperatorsBlocks {
    constructor (runtime) {
        /**
         * The runtime instantiating this block package.
         * @type {Runtime}
         */
        this.runtime = runtime;
    }

    /**
     * Retrieve the block primitives implemented by this package.
     * @return {object.<string, Function>} Mapping of opcode to Function.
     */
    getPrimitives () {
        return {
            operator_add: this.add,
            operator_subtract: this.subtract,
            operator_multiply: this.multiply,
            operator_divide: this.divide,
            operator_lt: this.lt,
            operator_equals: this.equals,
            operator_gt: this.gt,
            operator_and: this.and,
            operator_or: this.or,
            operator_not: this.not,
            operator_random: this.random,
            operator_join: this.join,
            operator_letter_of: this.letterOf,
            operator_length: this.length,
            operator_contains: this.contains,
            operator_mod: this.mod,
            operator_round: this.round,
            operator_mathop: this.mathop
        };
    }

    add (args) {
        return Cast.toNumber(args.NUM1) + Cast.toNumber(args.NUM2);
    }

    subtract (args) {
        return Cast.toNumber(args.NUM1) - Cast.toNumber(args.NUM2);
    }

    multiply (args) {
        return Cast.toNumber(args.NUM1) * Cast.toNumber(args.NUM2);
    }

    divide (args) {
        return Cast.toNumber(args.NUM1) / Cast.toNumber(args.NUM2);
    }

    lt (args) {
        return Cast.compare(args.OPERAND1, args.OPERAND2) < 0;
    }

    equals (args) {
        return Cast.compare(args.OPERAND1, args.OPERAND2) === 0;
    }

    gt (args) {
        return Cast.compare(args.OPERAND1, args.OPERAND2) > 0;
    }

    and (args) {
        return Cast.toBoolean(args.OPERAND1) && Cast.toBoolean(args.OPERAND2);
    }

    or (args) {
        return Cast.toBoolean(args.OPERAND1) || Cast.toBoolean(args.OPERAND2);
    }

    not (args) {
        return !Cast.toBoolean(args.OPERAND);
    }

    random (args) {
        const nFrom = Cast.toNumber(args.FROM);
        const nTo = Cast.toNumber(args.TO);
        const low = nFrom <= nTo ? nFrom : nTo;
        const high = nFrom <= nTo ? nTo : nFrom;
        if (low === high) return low;
        // If both arguments are ints, truncate the result to an int.
        if (Cast.isInt(args.FROM) && Cast.isInt(args.TO)) {
            return low + parseInt(Math.random() * ((high + 1) - low), 10);
        }
        return (Math.random() * (high - low)) + low;
    }

    join (args) {
        return Cast.toString(args.STRING1) + Cast.toString(args.STRING2);
    }

    letterOf (args) {
        const index = Cast.toNumber(args.LETTER) - 1;
        const str = Cast.toString(args.STRING);
        // Out of bounds?
        if (index < 0 || index >= str.length) {
            return '';
        }
        return str.charAt(index);
    }

    length (args) {
        return Cast.toString(args.STRING).length;
    }

    contains (args) {
        return Cast.toString(args.STRING1).toLowerCase()
            .includes(Cast.toString(args.STRING2).toLowerCase());
    }

    mod (args) {
        const n = Cast.toNumber(args.NUM1);
        const modulus = Cast.toNumber(args.NUM2);
        let result = n % modulus;
        // Scratch mod is kept positive.
        if (result / modulus < 0) result += modulus;
        return result;
    }

    round (args) {
        return Math.round(Cast.toNumber(args.NUM));
    }

    mathop (args) {
        const operator = Cast.toString(args.OPERATOR).toLowerCase();
        const n = Cast.toNumber(args.NUM);
        switch (operator) {
        case 'abs': return Math.abs(n);
        case 'floor': return Math.floor(n);
        case 'ceiling': return Math.ceil(n);
        case 'sqrt': return Math.sqrt(n);
        case 'sin': return parseFloat(Math.sin((Math.PI * n) / 180).toFixed(10));
        case 'cos': return parseFloat(Math.cos((Math.PI * n) / 180).toFixed(10));
        case 'tan': return MathUtil.tan(n);
        case 'asin': return (Math.asin(n) * 180) / Math.PI;
        case 'acos': return (Math.acos(n) * 180) / Math.PI;
        case 'atan': return (Math.atan(n) * 180) / Math.PI;
        case 'ln': return Math.log(n);
        case 'log': return Math.log(n) / Math.LN10;
        case 'e ^': return Math.exp(n);
        case '10 ^': return Math.pow(10, n);
        }
        return 0;
    }
}

module.exports = Scratch3OperatorsBlocks;
<commit_msg>Cleaned up<commit_after>const Cast = require('../util/cast.js');
const MathUtil = require('../util/math-util.js');

class Scratch3OperatorsBlocks {
    constructor (runtime) {
        /**
         * The runtime instantiating this block package.
         * @type {Runtime}
         */
        this.runtime = runtime;
    }

    /**
     * Retrieve the block primitives implemented by this package.
     * @return {object.<string, Function>} Mapping of opcode to Function.
     */
    getPrimitives () {
        return {
            operator_add: this.add,
            operator_subtract: this.subtract,
            operator_multiply: this.multiply,
            operator_divide: this.divide,
            operator_lt: this.lt,
            operator_equals: this.equals,
            operator_gt: this.gt,
            operator_and: this.and,
            operator_or: this.or,
            operator_not: this.not,
            operator_random: this.random,
            operator_join: this.join,
            operator_letter_of: this.letterOf,
            operator_length: this.length,
            operator_contains: this.contains,
            operator_mod: this.mod,
            operator_round: this.round,
            operator_mathop: this.mathop
        };
    }

    add (args) {
        return Cast.toNumber(args.NUM1) + Cast.toNumber(args.NUM2);
    }

    subtract (args) {
        return Cast.toNumber(args.NUM1) - Cast.toNumber(args.NUM2);
    }

    multiply (args) {
        return Cast.toNumber(args.NUM1) * Cast.toNumber(args.NUM2);
    }

    divide (args) {
        return Cast.toNumber(args.NUM1) / Cast.toNumber(args.NUM2);
    }

    lt (args) {
        return Cast.compare(args.OPERAND1, args.OPERAND2) < 0;
    }

    equals (args) {
        return Cast.compare(args.OPERAND1, args.OPERAND2) === 0;
    }

    gt (args) {
        return Cast.compare(args.OPERAND1, args.OPERAND2) > 0;
    }

    and (args) {
        return Cast.toBoolean(args.OPERAND1) && Cast.toBoolean(args.OPERAND2);
    }

    or (args) {
        return Cast.toBoolean(args.OPERAND1) || Cast.toBoolean(args.OPERAND2);
    }

    not (args) {
        return !Cast.toBoolean(args.OPERAND);
    }

    random (args) {
        const nFrom = Cast.toNumber(args.FROM);
        const nTo = Cast.toNumber(args.TO);
        const low = nFrom <= nTo ? nFrom : nTo;
        const high = nFrom <= nTo ? nTo : nFrom;
        if (low === high) return low;
        // If both arguments are ints, truncate the result to an int.
        if (Cast.isInt(args.FROM) && Cast.isInt(args.TO)) {
            return low + parseInt(Math.random() * ((high + 1) - low), 10);
        }
        return (Math.random() * (high - low)) + low;
    }

    join (args) {
        return Cast.toString(args.STRING1) + Cast.toString(args.STRING2);
    }

    letterOf (args) {
        const index = Cast.toNumber(args.LETTER) - 1;
        const str = Cast.toString(args.STRING);
        // Out of bounds?
        if (index < 0 || index >= str.length) {
            return '';
        }
        return str.charAt(index);
    }

    length (args) {
        return Cast.toString(args.STRING).length;
    }

    contains (args) {
        const format = function (string) {
            return Cast.toString(string).toLowerCase()
        }
        return format(args.STRING1).includes(format(args.STRING2))
    }

    mod (args) {
        const n = Cast.toNumber(args.NUM1);
        const modulus = Cast.toNumber(args.NUM2);
        let result = n % modulus;
        // Scratch mod is kept positive.
        if (result / modulus < 0) result += modulus;
        return result;
    }

    round (args) {
        return Math.round(Cast.toNumber(args.NUM));
    }

    mathop (args) {
        const operator = Cast.toString(args.OPERATOR).toLowerCase();
        const n = Cast.toNumber(args.NUM);
        switch (operator) {
        case 'abs': return Math.abs(n);
        case 'floor': return Math.floor(n);
        case 'ceiling': return Math.ceil(n);
        case 'sqrt': return Math.sqrt(n);
        case 'sin': return parseFloat(Math.sin((Math.PI * n) / 180).toFixed(10));
        case 'cos': return parseFloat(Math.cos((Math.PI * n) / 180).toFixed(10));
        case 'tan': return MathUtil.tan(n);
        case 'asin': return (Math.asin(n) * 180) / Math.PI;
        case 'acos': return (Math.acos(n) * 180) / Math.PI;
        case 'atan': return (Math.atan(n) * 180) / Math.PI;
        case 'ln': return Math.log(n);
        case 'log': return Math.log(n) / Math.LN10;
        case 'e ^': return Math.exp(n);
        case '10 ^': return Math.pow(10, n);
        }
        return 0;
    }
}

module.exports = Scratch3OperatorsBlocks;
<|endoftext|>


<commit_before>gpub.book.latex.defaultTemplate = [
'{{=<% %>=}}', // Change the tag-type to ERB
'\\documentclass[letterpaper,12pt]{memoir}',
'\\usepackage{color}',
'\\usepackage{wrapfig}',
'\\usepackage{setspace}',
'\\usepackage[cmyk]{xcolor}',
'\\usepackage{graphicx}',
'<%^pdfx1a%>',
'\\usepackage{hyperref}',
'<%/pdfx1a%>',
'\\usepackage{xmpincl}',
'<%#frontmatter.copyright.showPermanenceOfPaper%>',
'\\usepackage{tikz}',
'<%/frontmatter.copyright.showPermanenceOfPaper%>',

'\\usepackage[margin=1in]{geometry}',

'',
'<%#pdfx1a%>',
'%%% PDF/X-1a Header',
'<%ypdfxHeader%>',
'',
'<%/pdfx1a%>',

'%%% Define any extra packages %%%',
'<%init%>',

'',
'\\setlength{\\parskip}{0.5em}',
'\\setlength{\\parindent}{0pt}',
'',

'%%% Diagram Figure defs.',
'% Must expose two commands',
'%  \\gofigure  (mainline diagrams)',
'%  \\godiagram (variation diagrams)',
'% Mainline Diagrams. reset at parts',
'\\newcounter{GoFigure}[part]',
'',
'\\newcommand{\\gofigure}{%',
' \\stepcounter{GoFigure}',
' \\centerline{\\textit{\\textbf{Diagram \\arabic{GoFigure}}}}',
'}',
'',
'% Variation Diagrams. reset at parts.',
'\\newcounter{GoVariation}[part]',
'',
'\\newcommand{\\govariation}{%',
' \\stepcounter{GoVariation}',
' \\textit{Variation \\arabic{GoVariation}}',
'}',
'',
'\\newcommand{\\subtext}[1]{\\centerline{\\textit{#1}}}',
'',
'%%% Define the main title %%%',
'\\definecolor{light-gray}{gray}{0.55}',
'\\newcommand*{\\mainBookTitle}{\\begingroup',
'  \\raggedleft',
'  <%#authors%>',
'     {\\Large{<%.%>}} \\\\',
'     \\vspace*{1 em}',
'  <%/authors%>',
'  \\vspace*{5 em}',
'  {\\textcolor{light-gray}{\\Huge{<%title%>}}}\\\\',
'  \\vspace*{\\baselineskip}',
'  <%#subtitle%>',
'  {\\small \\bfseries <%subtitle%> }\\par',
'  <%/subtitle%>',
'  \\vfill',
'  <%#publisher%>',
'  {\\Large{<%publisher%>}}\\par',
'  \\vspace*{2\\baselineskip}',
'  <%/publisher%>',
'  <%#year%>',
'  {\\large{<%year%>}}\\par',
'  \\vspace*{2\\baselineskip}',
'  <%/year%>',
'\\endgroup}',

' %%% Chapter settings %%%',
//'\\pagestyle{empty}',
//'\\chapterstyle{section}', -- the old style
//'\\chapterstyle{demo2}', -- 2 hrules
// other options for chapter styles:
// bringhurst,crosshead,default,dowding,memman,komalike,ntglike,tandh,wilsondob
'\\chapterstyle{madsen}',
// Muck with the chapter number. The standard madsen style has the numbers off
// the edge of the header box. That works fine until you want to print at
// smaller sizes (e.g., 6x9).
'\\renewcommand*{\\printchapternum}{%',
'  \\resizebox{!}{3ex}{%',
'      {\\hspace{0.2em}\\chapnamefont\\bfseries\\sffamily\\thechapter}%',
'  }%',
'}%',

// openany, openright, openleft
'\\openany',
'\\makepagestyle{headings}',
'\\setlength{\\headwidth}{\\textwidth}',
'\\makeevenhead{headings}{\\thepage}{}{\\slshape\\leftmark}',
'\\makeoddhead{headings}{\\slshape\\rightmark}{}{\\thepage}',
'\\makerunningwidth{headings}[\\textwidth]{\\textwidth}',

'\\pagestyle{companion}',
'\\makerunningwidth{companion}{\\headwidth}',
//'\\renewcommand{\\printchapternum}{\\space}', -- Force no chapter nums

'',
////////////////////////
// Start the document //
////////////////////////
'\\begin{document}',
'%%% The Frontmatter. %%%',
'\\pagestyle{empty}',
'\\mainBookTitle',
'\\cleartoverso',
'',
'<%#frontmatter.copyright%>',
'% Copyright Page',
'\\begin{vplace}[0.7]',
'\\footnotesize{',
'\\textcopyright\\ <%frontmatter.copyright.publishYear%> by <%frontmatter.copyright.publisher%> \\\\',
'<%frontmatter.copyright.license%> Published <%frontmatter.copyright.publishYear%> \\\\',
'First edition published <%frontmatter.copyright.firstEditionYear%>.\\\\',
'\\\\',
'<%&frontmatter.copyright.constructedAddress%>\\\\',
'\\\\',
'<%#frontmatter.copyright.constructedPrintingRun%>',
'<%frontmatter.copyright.constructedPrintingRun%>\\\\',
'<%/frontmatter.copyright.constructedPrintingRun%>',
'\\\\',
'<%#frontmatter.copyright.isbn%>',
'ISBN: <%frontmatter.copyright.isbn%> \\\\',
'<%/frontmatter.copyright.isbn%>',
'<%#frontmatter.copyright.issn%>',
'ISSN: <%frontmatter.copyright.issn%> \\\\',
'<%/frontmatter.copyright.issn%>',
'\\\\',
'\\\\',
'<%#frontmatter.copyright.showPermanenceOfPaper%>',
'\\tikz\\node[circle,draw,inner sep=.1ex] {\\tiny{$\\infty$}};',
'This paper meets or exceeds the requirements',
'of \\textsc{ansi/niso z39.48-1992} \\\\',
'(Permanence of Paper). \\\\',
'<%/frontmatter.copyright.showPermanenceOfPaper%>',
'\\\\',
'\\\\',
'\\\\',
'Created using LaTeX generated by GPub.js.',
'}\\\\',
'\\end{vplace}',
'<%/frontmatter.copyright%>',
'\\cleartorecto',
//'\\cleartoverso',
'',
'<%#frontmatter.generateToc%>',
'\\tableofcontents*',
'<%/frontmatter.generateToc%>',
'\\pagestyle{companion}',
'\\frontmatter',
'',
'<%#frontmatter.foreword%>',
'\\chapter{Foreward}',
'<%frontmatter.foreword.text%>',
'<%/frontmatter.foreword%>',
'',
'<%#frontmatter.preface%>',
'\\chapter{Preface}',
'<%frontmatter.preface.text%>',
'<%/frontmatter.preface%>',
'',
'<%#frontmatter.acknowledgements%>',
'\\chapter{Acknowledgments}',
'<%frontmatter.acknowledgements.text%>',
'<%/frontmatter.acknowledgements%>',
'',
'<%#frontmatter.introduction%>',
'\\chapter{Introduction}',
'<%frontmatter.introduction.text%>',
'<%/frontmatter.introduction%>',
'',
'%%% The content. %%%',
'\\mainmatter',
'<%&content%>',
'',
'\\end{document}'].join('\n');
<commit_msg>Fix the template: pdf/x-1a<commit_after>gpub.book.latex.defaultTemplate = [
'{{=<% %>=}}', // Change the tag-type to ERB
'\\documentclass[letterpaper,12pt]{memoir}',
'\\usepackage{color}',
'\\usepackage{wrapfig}',
'\\usepackage{setspace}',
'\\usepackage[cmyk]{xcolor}',
'\\usepackage{graphicx}',
'<%^pdfx1a%>',
'\\usepackage{hyperref}',
'<%/pdfx1a%>',
'\\usepackage{xmpincl}',
'<%#frontmatter.copyright.showPermanenceOfPaper%>',
'\\usepackage{tikz}',
'<%/frontmatter.copyright.showPermanenceOfPaper%>',
'',
'\\usepackage[margin=1in]{geometry}',
'',
'<%#pdfx1a%>',
'%%% PDF/X-1a Header',
'<%&pdfxHeader%>',
'<%/pdfx1a%>',
'',
'%%% Define any extra packages %%%',
'<%init%>',
'',
'\\setlength{\\parskip}{0.5em}',
'\\setlength{\\parindent}{0pt}',
'',
'%%% Diagram Figure defs.',
'% Must expose two commands',
'%  \\gofigure  (mainline diagrams)',
'%  \\godiagram (variation diagrams)',
'% Mainline Diagrams. reset at parts',
'\\newcounter{GoFigure}[part]',
'',
'\\newcommand{\\gofigure}{%',
' \\stepcounter{GoFigure}',
' \\centerline{\\textit{\\textbf{Diagram \\arabic{GoFigure}}}}',
'}',
'',
'% Variation Diagrams. reset at parts.',
'\\newcounter{GoVariation}[part]',
'',
'\\newcommand{\\govariation}{%',
' \\stepcounter{GoVariation}',
' \\textit{Variation \\arabic{GoVariation}}',
'}',
'',
'\\newcommand{\\subtext}[1]{\\centerline{\\textit{#1}}}',
'',
'%%% Define the main title %%%',
'\\definecolor{light-gray}{gray}{0.55}',
'\\newcommand*{\\mainBookTitle}{\\begingroup',
'  \\raggedleft',
'  <%#authors%>',
'     {\\Large{<%.%>}} \\\\',
'     \\vspace*{1 em}',
'  <%/authors%>',
'  \\vspace*{5 em}',
'  {\\textcolor{light-gray}{\\Huge{<%title%>}}}\\\\',
'  \\vspace*{\\baselineskip}',
'  <%#subtitle%>',
'  {\\small \\bfseries <%subtitle%> }\\par',
'  <%/subtitle%>',
'  \\vfill',
'  <%#publisher%>',
'  {\\Large{<%publisher%>}}\\par',
'  \\vspace*{2\\baselineskip}',
'  <%/publisher%>',
'  <%#year%>',
'  {\\large{<%year%>}}\\par',
'  \\vspace*{2\\baselineskip}',
'  <%/year%>',
'\\endgroup}',

' %%% Chapter settings %%%',
//'\\pagestyle{empty}',
//'\\chapterstyle{section}', -- the old style
//'\\chapterstyle{demo2}', -- 2 hrules
// other options for chapter styles:
// bringhurst,crosshead,default,dowding,memman,komalike,ntglike,tandh,wilsondob
'\\chapterstyle{madsen}',
// Muck with the chapter number. The standard madsen style has the numbers off
// the edge of the header box. That works fine until you want to print at
// smaller sizes (e.g., 6x9).
'\\renewcommand*{\\printchapternum}{%',
'  \\resizebox{!}{3ex}{%',
'      {\\hspace{0.2em}\\chapnamefont\\bfseries\\sffamily\\thechapter}%',
'  }%',
'}%',

// openany, openright, openleft
'\\openany',
'\\makepagestyle{headings}',
'\\setlength{\\headwidth}{\\textwidth}',
'\\makeevenhead{headings}{\\thepage}{}{\\slshape\\leftmark}',
'\\makeoddhead{headings}{\\slshape\\rightmark}{}{\\thepage}',
'\\makerunningwidth{headings}[\\textwidth]{\\textwidth}',
'',
'\\pagestyle{companion}',
'\\makerunningwidth{companion}{\\headwidth}',
//'\\renewcommand{\\printchapternum}{\\space}', -- Force no chapter nums

'',
////////////////////////
// Start the document //
////////////////////////
'\\begin{document}',
'%%% The Frontmatter. %%%',
'\\pagestyle{empty}',
'\\mainBookTitle',
'\\cleartoverso',
'',
'<%#frontmatter.copyright%>',
'% Copyright Page',
'\\begin{vplace}[0.7]',
'\\footnotesize{',
'\\textcopyright\\ <%frontmatter.copyright.publishYear%> by <%frontmatter.copyright.publisher%> \\\\',
'<%frontmatter.copyright.license%> Published <%frontmatter.copyright.publishYear%> \\\\',
'First edition published <%frontmatter.copyright.firstEditionYear%>.\\\\',
'\\\\',
'<%&frontmatter.copyright.constructedAddress%>\\\\',
'\\\\',
'<%#frontmatter.copyright.constructedPrintingRun%>',
'<%frontmatter.copyright.constructedPrintingRun%>\\\\',
'<%/frontmatter.copyright.constructedPrintingRun%>',
'\\\\',
'<%#frontmatter.copyright.isbn%>',
'ISBN: <%frontmatter.copyright.isbn%> \\\\',
'<%/frontmatter.copyright.isbn%>',
'<%#frontmatter.copyright.issn%>',
'ISSN: <%frontmatter.copyright.issn%> \\\\',
'<%/frontmatter.copyright.issn%>',
'\\\\',
'\\\\',
'<%#frontmatter.copyright.showPermanenceOfPaper%>',
'\\tikz\\node[circle,draw,inner sep=.1ex] {\\tiny{$\\infty$}};',
'This paper meets or exceeds the requirements',
'of \\textsc{ansi/niso z39.48-1992} \\\\',
'(Permanence of Paper). \\\\',
'<%/frontmatter.copyright.showPermanenceOfPaper%>',
'\\\\',
'\\\\',
'\\\\',
'Created using LaTeX generated by GPub.js.',
'}\\\\',
'\\end{vplace}',
'<%/frontmatter.copyright%>',
'\\cleartorecto',
//'\\cleartoverso',
'',
'<%#frontmatter.generateToc%>',
'\\tableofcontents*',
'<%/frontmatter.generateToc%>',
'\\pagestyle{companion}',
'\\frontmatter',
'',
'<%#frontmatter.foreword%>',
'\\chapter{Foreward}',
'<%frontmatter.foreword.text%>',
'<%/frontmatter.foreword%>',
'',
'<%#frontmatter.preface%>',
'\\chapter{Preface}',
'<%frontmatter.preface.text%>',
'<%/frontmatter.preface%>',
'',
'<%#frontmatter.acknowledgements%>',
'\\chapter{Acknowledgments}',
'<%frontmatter.acknowledgements.text%>',
'<%/frontmatter.acknowledgements%>',
'',
'<%#frontmatter.introduction%>',
'\\chapter{Introduction}',
'<%frontmatter.introduction.text%>',
'<%/frontmatter.introduction%>',
'',
'%%% The content. %%%',
'\\mainmatter',
'<%&content%>',
'',
'\\end{document}'].join('\n');
<|endoftext|>


<commit_before>// Text loading component with two important limits.
// https://www.nngroup.com/articles/response-times-3-important-limits
// Example:
// {!users ?
//   <Loading />
// :
//

//     users here
//

// }

import './Loading.scss';
import Component from 'react-pure-render/component';
import React, { PropTypes } from 'react';

export default class Loading extends Component {

  static propTypes = {
    loadingText: PropTypes.string.isRequired,
    longLoadingText: PropTypes.string.isRequired
  };

  static defaultProps = {
    loadingText: 'Loading',
    longLoadingText: 'Still loading, please check your internet connection'
  };

  constructor(props) {
    super(props);
    this.state = {
      // Don't show anything for the first second.
      currentText: ''
    };
  }

  componentDidMount() {
    this.timer = setTimeout(() => {
      this.setState({ currentText: this.props.loadingText });
    }, 1000);
    this.longTimer = setTimeout(() => {
      this.setState({ currentText: this.props.longLoadingText });
    }, 10000);
  }

  componentWillUnmount() {
    clearTimeout(this.timer);
    clearTimeout(this.longTimer);
  }

  render() {
    return (

        {this.state.currentText}

    );
  }

}
<commit_msg>Loading should be universal component<commit_after>// Text loading component with two important limits.
// https://www.nngroup.com/articles/response-times-3-important-limits
// Example:
// {!users ?
//   <Loading />
// :
//

//     users here
//

// }
// TODO: Make it universal.

import './Loading.scss';
import Component from 'react-pure-render/component';
import React, { PropTypes } from 'react';

export default class Loading extends Component {

  static propTypes = {
    loadingText: PropTypes.string.isRequired,
    longLoadingText: PropTypes.string.isRequired
  };

  static defaultProps = {
    loadingText: 'Loading',
    longLoadingText: 'Still loading, please check your internet connection'
  };

  constructor(props) {
    super(props);
    this.state = {
      // Don't show anything for the first second.
      currentText: ''
    };
  }

  componentDidMount() {
    this.timer = setTimeout(() => {
      this.setState({ currentText: this.props.loadingText });
    }, 1000);
    this.longTimer = setTimeout(() => {
      this.setState({ currentText: this.props.longLoadingText });
    }, 10000);
  }

  componentWillUnmount() {
    clearTimeout(this.timer);
    clearTimeout(this.longTimer);
  }

  render() {
    return (

        {this.state.currentText}

    );
  }

}
<|endoftext|>


<commit_before>const { Constants, ErrorHelper } =  require('eae-utils');
const JobExecutorFactory = require('./jobExecutorFactory.js');

/**
 * @class JobController
 * @desc Controller of the job execution
 * @param jobCollection MongoDb collection, stores the job data models
 * @param statusHelper Status helper class
 * @constructor
 */
function JobController(jobCollection, statusHelper) {
    this._jobCollection = jobCollection;
    this._status_helper = statusHelper;
    this._jobExecFactory = new JobExecutorFactory();
    this._executor = undefined;

    this.runJob = JobController.prototype.runJob.bind(this);
    this.cancelJob = JobController.prototype.cancelJob.bind(this);
}

/**
 * @fn runJob
 * @desc Starts a new execution from a job_id
 * @param req Express.js request object
 * @param res Express.js response object
 */
JobController.prototype.runJob = function(req, res) {
    let _this = this;
    let job_id = req.body ? req.body.job_id : undefined;

    if (job_id === undefined || job_id === null) {
        res.status(401);
        res.json(ErrorHelper('Unknown job, aborting..'));
        return;
    }
    if (_this._executor !== undefined) {
        res.status(503);
        res.json(ErrorHelper('Service is not available for compute'));
        return;
    }

    //Create executor based on type
    _this._jobExecFactory.createFromId(job_id, _this._jobCollection).then(function(executor) {
        _this._executor = executor;
        //Set the node to busy
        _this._status_helper.setStatus(Constants.EAE_SERVICE_STATUS_BUSY);
        //Trigger asynchronous execution
        _this._executor.startExecution(function(__unused__error) {
            //After exec, set the node to idle
            _this._status_helper.setStatus(Constants.EAE_SERVICE_STATUS_IDLE);
            //Cleanup executor instance
            delete _this._executor;
        });
        res.status(200);
        res.json({ ok: true, status: Constants.EAE_JOB_STATUS_RUNNING });
    }, function(error) {
        res.status(500);
        res.json(ErrorHelper('Execution aborted', error));
        delete _this._executor;
    });
};

/**
 * @fn cancelJob
 * @desc Interrupts the current job
 * @param _unused__req Express.js request object
 * @param res Express.js response object
 */
JobController.prototype.cancelJob = function(__unused__req, res) {
    let _this = this;

    if (_this._executor === undefined || _this._executor === null) {
        res.status(501);
        res.json(ErrorHelper('Not currently running a job'));
        return;
    }
    _this._executor.stopExecution(function(error, jobStatus) {
        //After exec, set the node to idle
        _this._status_helper.setStatus(Constants.EAE_SERVICE_STATUS_IDLE);
        //Cleanup executor instance
        delete _this._executor;

        if (error !== undefined && error !== null) {
            res.status(500);
            res.json(ErrorHelper('Failed to interrupt job', error));
        }
        else {
            //Reply inside callback so the job is stopped
            res.status(200);
            res.json({ status: jobStatus });
        }
    });
};

module.exports = JobController;
<commit_msg>Change of error code for invalid request when there is no job running<commit_after>const { Constants, ErrorHelper } =  require('eae-utils');
const JobExecutorFactory = require('./jobExecutorFactory.js');

/**
 * @class JobController
 * @desc Controller of the job execution
 * @param jobCollection MongoDb collection, stores the job data models
 * @param statusHelper Status helper class
 * @constructor
 */
function JobController(jobCollection, statusHelper) {
    this._jobCollection = jobCollection;
    this._status_helper = statusHelper;
    this._jobExecFactory = new JobExecutorFactory();
    this._executor = undefined;

    this.runJob = JobController.prototype.runJob.bind(this);
    this.cancelJob = JobController.prototype.cancelJob.bind(this);
}

/**
 * @fn runJob
 * @desc Starts a new execution from a job_id
 * @param req Express.js request object
 * @param res Express.js response object
 */
JobController.prototype.runJob = function(req, res) {
    let _this = this;
    let job_id = req.body ? req.body.job_id : undefined;

    if (job_id === undefined || job_id === null) {
        res.status(401);
        res.json(ErrorHelper('Unknown job, aborting..'));
        return;
    }
    if (_this._executor !== undefined) {
        res.status(503);
        res.json(ErrorHelper('Service is not available for compute'));
        return;
    }

    //Create executor based on type
    _this._jobExecFactory.createFromId(job_id, _this._jobCollection).then(function(executor) {
        _this._executor = executor;
        //Set the node to busy
        _this._status_helper.setStatus(Constants.EAE_SERVICE_STATUS_BUSY);
        //Trigger asynchronous execution
        _this._executor.startExecution(function(__unused__error) {
            //After exec, set the node to idle
            _this._status_helper.setStatus(Constants.EAE_SERVICE_STATUS_IDLE);
            //Cleanup executor instance
            delete _this._executor;
        });
        res.status(200);
        res.json({ ok: true, status: Constants.EAE_JOB_STATUS_RUNNING });
    }, function(error) {
        res.status(500);
        res.json(ErrorHelper('Execution aborted', error));
        delete _this._executor;
    });
};

/**
 * @fn cancelJob
 * @desc Interrupts the current job
 * @param _unused__req Express.js request object
 * @param res Express.js response object
 */
JobController.prototype.cancelJob = function(__unused__req, res) {
    let _this = this;

    if (_this._executor === undefined || _this._executor === null) {
        res.status(400);
        res.json(ErrorHelper('Not currently running a job'));
        return;
    }
    _this._executor.stopExecution(function(error, jobStatus) {
        //After exec, set the node to idle
        _this._status_helper.setStatus(Constants.EAE_SERVICE_STATUS_IDLE);
        //Cleanup executor instance
        delete _this._executor;

        if (error !== undefined && error !== null) {
            res.status(500);
            res.json(ErrorHelper('Failed to interrupt job', error));
        }
        else {
            //Reply inside callback so the job is stopped
            res.status(200);
            res.json({ status: jobStatus });
        }
    });
};

module.exports = JobController;
<|endoftext|>


<commit_before>/* eslint-disable max-len */
var ctype = require('./contribTypes');
exports.extensions = {
  supported: [
    { icon: 'actionscript', extensions: ['as'] },
    { icon: 'angular', extensions: [] },
    { icon: 'apache', extensions: ['htaccess', 'htpasswd'] },
    { icon: 'apib', extensions: ['apib'] },
    { icon: 'applescript', extensions: ['app'] },
    { icon: 'appveyor', extensions: ['appveyor.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'ansible', extensions: ['ansible'] },
    { icon: 'asp', extensions: ['asp'] },
    { icon: 'aspx', extensions: ['aspx', 'ascx'] },
    { icon: 'assembly', extensions: ['s', 'asm'] },
    { icon: 'autohotkey', extensions: ['ahk'] },
    { icon: 'babel', extensions: ['babelrc'] },
    { icon: 'binary', extensions: ['bin', 'o', 'a', 'exe', 'obj', 'lib', 'dll', 'so', 'pyc', 'pyd', 'pyo', 'n', 'ndll', 'pdb', 'cmo', 'cmx', 'cma', 'cmxa', 'cmi'] }, // http://www.file-extensions.org/filetype/extension/name/binary-files
    { icon: 'blade', extensions: ['.blade.php'], special: 'php', contribOrder: 1 },
    { icon: 'bower', extensions: ['bowerrc'] },
    { icon: 'bower', extensions: ['bower.json'], special: 'json', contribType: ctype.filename },
    { icon: 'bundler', extensions: ['gemfile'], contribType: ctype.filename },
    { icon: 'bundler', extensions: ['gemfile.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'c++', extensions: ['cpp', 'hpp', 'cc', 'cxx'] },
    { icon: 'c', extensions: ['c'] },
    { icon: 'cake', extensions: ['cake'] },
    { icon: 'cfm', extensions: ['cfm', 'cfc', 'lucee'] },
    { icon: 'cheader', extensions: ['h'] },
    { icon: 'clojure', extensions: ['clojure', 'cjm', 'clj', 'cljs', 'cljc', 'edn'] },
    { icon: 'cobol', extensions: ['cbl', 'cob', 'cpy'] },
    { icon: 'codeclimate', extensions: ['codeclimate.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'coffeescript', extensions: ['coffee'] },
    { icon: 'config', extensions: ['env', 'ini', 'makefile', 'config'] },
    { icon: 'config', extensions: ['makefile'], contribType: ctype.filename },
    { icon: 'compass', extensions: [] },
    { icon: 'composer', extensions: ['composer.json'], special: 'json', contribType: ctype.filename },
    { icon: 'composer', extensions: ['composer.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'cs', extensions: ['cs', 'csx'] },
    { icon: 'cshtml', extensions: ['cshtml'] },
    { icon: 'csproj', extensions: ['csproj'] },
    { icon: 'css', extensions: ['css'] },
    { icon: 'csslint', extensions: ['csslintrc'] },
    { icon: 'cssmap', extensions: ['.css.map'], special: 'map' },
    { icon: 'cucumber', extensions: ['feature'] },
    { icon: 'dartlang', extensions: ['dart'] },
    { icon: 'delphi', extensions: ['pas', 'dfm', 'dpr'] },
    { icon: 'dlang', extensions: ['d'] },
    { icon: 'docker', extensions: ['dockerfile', 'dockerignore'], contribType: ctype.filename },
    { icon: 'docker', extensions: ['dockerignore'] },
    { icon: 'docker', extensions: ['docker-compose.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'editorconfig', extensions: ['editorconfig'] },
    { icon: 'ejs', extensions: ['ejs'] },
    { icon: 'elixir', extensions: ['ex', 'exs', 'eex'] },
    { icon: 'elm', extensions: ['elm'] },
    { icon: 'elm', extensions: ['elm-package.json'], special: 'json', contribType: ctype.filename, contribOrder: 1 },
    { icon: 'erb', extensions: ['rhtml', 'erb'] },
    { icon: 'erlang', extensions: ['erl', 'hrl', 'emakefile', 'emakerfile'] },
    { icon: 'eslint', extensions: ['eslintrc', 'eslintignore'] },
    { icon: 'eslint', extensions: ['.eslintrc.js'], special: 'js', contribType: ctype.filename },
    { icon: 'eslint', extensions: ['.eslintrc.json'], special: 'json', contribType: ctype.filename },
    { icon: 'eslint', extensions: ['.eslintrc.yaml'], special: 'yaml', contribType: ctype.filename },
    { icon: 'eslint', extensions: ['.eslintrc.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'excel', extensions: ['xls', 'xlsx', 'csv', 'ods'] },
    { icon: 'favicon', extensions: ['favicon.ico'], special: 'ico', contribType: ctype.filename },
    { icon: 'flash', extensions: ['swf', 'swc', 'sol'] },
    { icon: 'flow', extensions: ['flowconfig', 'js.flow'] },
    { icon: 'fsharp', extensions: ['fs', 'fsx', 'fsi'] },
    { icon: 'font', extensions: ['woff', 'woff2', 'ttf', 'otf', 'eot', 'pfa', 'pfb', 'sfd'] },
    { icon: 'fortran', extensions: ['f90', 'mod', 'f'] },
    { icon: 'git', extensions: ['gitattributes', 'gitignore', 'gitmodules', 'gitkeep'] },
    { icon: 'go', extensions: ['go'] },
    { icon: 'gradle', extensions: ['gradle'] },
    { icon: 'graphviz', extensions: [] },
    { icon: 'groovy', extensions: ['groovy'] },
    { icon: 'gruntfile', extensions: ['gruntfile.js'], special: 'js', contribType: ctype.filename },
    { icon: 'gulpfile', extensions: ['gulpfile.js'], special: 'js', contribType: ctype.filename },
    { icon: 'haml', extensions: ['haml'] },
    { icon: 'handlebars', extensions: ['hbs', 'handlebars'] },
    { icon: 'haskell', extensions: ['has', 'hs', 'lhs', 'lit', 'gf'] },
    { icon: 'haxe', extensions: ['hx', 'hxml'] },
    { icon: 'haxe', extensions: ['haxelib.json'], special: 'json', contribType: ctype.filename },
    { icon: 'haxecheckstyle', extensions: ['checkstyle.json'], special: 'json', contribType: ctype.filename },
    { icon: 'haxedevelop', extensions: ['hxproj'] },
    { icon: 'html', extensions: ['htm', 'html'] },
    { icon: 'image', extensions: ['jpeg', 'jpg', 'gif', 'png', 'bmp', 'ico'] },
    { icon: 'ionic', extensions: ['ionic.project'], special: 'project', contribType: ctype.filename },
    { icon: 'ionic', extensions: ['ionic.config.json'], special: 'json', contribType: ctype.filename },
    { icon: 'jade', extensions: ['jade', 'pug', 'jade-lintrc', 'pug-lintrc', 'tag'] },
    { icon: 'jade', extensions: ['.jade-lint.json'], special: 'json', contribType: ctype.filename },
    { icon: 'jade', extensions: ['.pug-lintrc.js'], special: 'js', contribType: ctype.filename },
    { icon: 'jade', extensions: ['.pug-lintrc.json'], special: 'json', contribType: ctype.filename },
    { icon: 'java', extensions: ['java'] },
    { icon: 'jinja', extensions: ['jinja'] },
    { icon: 'js', extensions: ['js'] },
    { icon: 'jshintrc', extensions: ['jshintrc'] },
    { icon: 'jsmap', extensions: ['.js.map'], special: 'map' },
    { icon: 'jsp', extensions: ['jsp'] },
    { icon: 'julia', extensions: ['jl'] },
    { icon: 'log', extensions: ['log'] },
    { icon: 'less', extensions: ['less'] },
    { icon: 'license', extensions: ['enc'] },
    { icon: 'license', extensions: ['license', 'licence'], contribType: ctype.filename },
    { icon: 'license', extensions: ['license.md', 'licence.md'], special: 'md', contribType: ctype.filename },
    { icon: 'lisp', extensions: ['bil'] },
    { icon: 'lime', extensions: ['hxp'] },
    { icon: 'lime', extensions: ['include.xml'], special: 'xml', contribType: ctype.filename },
    { icon: 'lsl', extensions: ['lsl'] },
    { icon: 'lua', extensions: ['lua'] },
    { icon: 'm', extensions: ['m'] },
    { icon: 'markdown', extensions: ['md', 'markdown'] },
    { icon: 'marko', extensions: ['marko'] },
    { icon: 'markojs', extensions: ['.marko.js'], special: 'js' },
    { icon: 'markup', extensions: [] },
    { icon: 'matlab', extensions: ['fig', 'mat', 'mex', 'mexn', 'mexrs6', 'mn', 'mum', 'mx', 'mx3', 'rwd', 'slx', 'slddc', 'smv', 'tikz', 'xvc', 'xvc'] },
    { icon: 'masterpage', extensions: ['master'] },
    { icon: 'mustache', extensions: ['mustache', 'mst'] },
    { icon: 'nim', extensions: ['nim', 'nims', 'cfg'] },
    { icon: 'node', extensions: ['json', 'webmanifest'] },
    { icon: 'node2', extensions: ['nvmrc'] },
    { icon: 'npm', extensions: ['npmignore'] },
    { icon: 'npm', extensions: ['package.json'], special: 'json', contribType: ctype.filename },
    { icon: 'nsi', extensions: ['nsi', 'nsh'] },
    { icon: 'nunjucks', extensions: ['njk', 'nunjucks', 'nunjs', 'nunj', 'njs', 'nj'] },
    { icon: 'ocaml', extensions: ['ml', 'mll', 'mli', 'mly', 'ocamlmakefile', 'merlin'] },
    { icon: 'paket', extensions: ['paket.dependencies'], special: 'dependencies', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.references'], special: 'references', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.template'], special: 'template', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.local'], special: 'local', contribType: ctype.filename },
    { icon: 'patch', extensions: ['patch'] },
    { icon: 'perl', extensions: ['perl'] },
    { icon: 'poedit', extensions: ['po', 'mo'] },
    { icon: 'photoshop', extensions: ['psd'] },
    { icon: 'php', extensions: ['php', 'php1', 'php2', 'php3', 'php4', 'php5', 'php6', 'phps', 'phpsa', 'phpt', 'phtml', 'phar'] },
    { icon: 'phpunit', extensions: ['phpunit.xml'], special: 'xml', contribType: ctype.filename },
    { icon: 'plantuml', extensions: ['pu', 'plantuml', 'iuml', 'puml'] },
    { icon: 'procfile', extensions: ['procfile'] },
    { icon: 'postcss', extensions: ['pcss', 'postcss'] },
    { icon: 'powershell', extensions: ['ps1', 'psm1', 'psd1'] },
    { icon: 'protobuf', extensions: ['proto'] },
    { icon: 'puppet', extensions: ['epp'] },
    { icon: 'python', extensions: ['py', 'pyw'] },
    { icon: 'qlikview', extensions: ['qvd', 'qvw'] },
    { icon: 'r', extensions: ['r'] },
    { icon: 'rails', extensions: [] },
    { icon: 'raml', extensions: ['raml'] },
    { icon: 'reactjs', extensions: ['jsx'] },
    { icon: 'reacttemplate', extensions: ['rt'] },
    { icon: 'reactts', extensions: ['tsx'] },
    { icon: 'rest', extensions: ['rest'] },
    { icon: 'riot', extensions: ['tag'] },
    { icon: 'robotframework', extensions: ['robot'] },
    { icon: 'rspec', extensions: ['rspec'] },
    { icon: 'ruby', extensions: ['rb', 'gemspec'] },
    { icon: 'rust', extensions: ['rs'] },
    { icon: 'saltstack', extensions: ['sls'] },
    { icon: 'sass', extensions: ['sass'] },
    { icon: 'scala', extensions: ['scala'] },
    { icon: 'scss', extensions: ['scss'] },
    { icon: 'settings', extensions: [] },
    { icon: 'shell', extensions: ['bat', 'sh', 'cmd', 'bash', 'zsh', 'fish'] },
    { icon: 'slim', extensions: [] },
    { icon: 'sln', extensions: ['sln'] },
    { icon: 'source', extensions: [] },
    { icon: 'sql', extensions: ['sql'] },
    { icon: 'sqlite', extensions: ['sqlite', 'db3'] },
    { icon: 'smarty', extensions: ['tpl', 'swig'] },
    { icon: 'stylelint', extensions: ['stylelintrc'] },
    { icon: 'stylelint', extensions: ['stylelint.config.js'], special: 'js', contribType: ctype.filename },
    { icon: 'stylus', extensions: ['styl'] },
    { icon: 'storyboard', extensions: ['storyboard'] },
    { icon: 'svg', extensions: ['svg'] },
    { icon: 'swift', extensions: ['swift'] },
    { icon: 'tcl', extensions: ['tcl'] },
    { icon: 'terraform', extensions: ['tf', 'terra'] },
    { icon: 'tex', extensions: ['texi', 'tex'] },
    { icon: 'text', extensions: ['txt'] },
    { icon: 'textile', extensions: ['textile'] },
    { icon: 'todo', extensions: ['todo'] },
    { icon: 'travis', extensions: ['.travis.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'twig', extensions: ['twig'] },
    { icon: 'typescript', extensions: ['ts'] },
    { icon: 'typescriptdef', extensions: ['.d.ts'], special: 'ts' },
    { icon: 'vagrant', extensions: ['vagrantfile'], contribType: ctype.filename },
    { icon: 'vash', extensions: ['vash'] },
    { icon: 'vb', extensions: ['vb'] },
    { icon: 'vbhtml', extensions: ['vbhtml'] },
    { icon: 'vbproj', extensions: ['vbproj'] },
    { icon: 'volt', extensions: ['volt'] },
    { icon: 'vue', extensions: ['vue'] },
    { icon: 'vscode', extensions: ['vscodeignore.json', 'launch.json', 'tasks.json', 'jsconfig.json', 'tsconfig.json'], special: 'json', contribType: ctype.filename },
    { icon: 'vscode', extensions: ['vscodeignore'] },
    { icon: 'webpack', extensions: ['webpack.config.js', 'webpack.config.babel.js', 'webpack.config.dev.js', 'webpack.config.staging.js', 'webpack.config.production.js'], special: 'js', contribType: ctype.filename },
    { icon: 'webpack', extensions: ['webpack.config.ts'], special: 'ts', contribType: ctype.filename },
    { icon: 'webpack', extensions: ['webpack.config.coffee'], special: 'coffee', contribType: ctype.filename },
    { icon: 'xib', extensions: ['xib'] },
    { icon: 'xliff', extensions: ['xliff', 'xlf'] },
    { icon: 'xml', extensions: ['xml', 'axml', 'xaml', 'pex'] },
    { icon: 'yaml', extensions: ['yml', 'yaml'] },
    { icon: 'yarn', extensions: ['yarnclean'] },
    { icon: 'yarn', extensions: ['yarn.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'zip', extensions: ['zip', 'rar', '7z', 'tar', 'gz', 'bzip2', 'xz', 'bz2'] }
  ],
  parse: function () {
    var s = this.replace(/\./g, '_');
    if ((/^\d/).test(s)) return 'n' + s;
    return s;
  }
};
<commit_msg>add webconfig.prod.js to webpack icon (#389)<commit_after>/* eslint-disable max-len */
var ctype = require('./contribTypes');
exports.extensions = {
  supported: [
    { icon: 'actionscript', extensions: ['as'] },
    { icon: 'angular', extensions: [] },
    { icon: 'apache', extensions: ['htaccess', 'htpasswd'] },
    { icon: 'apib', extensions: ['apib'] },
    { icon: 'applescript', extensions: ['app'] },
    { icon: 'appveyor', extensions: ['appveyor.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'ansible', extensions: ['ansible'] },
    { icon: 'asp', extensions: ['asp'] },
    { icon: 'aspx', extensions: ['aspx', 'ascx'] },
    { icon: 'assembly', extensions: ['s', 'asm'] },
    { icon: 'autohotkey', extensions: ['ahk'] },
    { icon: 'babel', extensions: ['babelrc'] },
    { icon: 'binary', extensions: ['bin', 'o', 'a', 'exe', 'obj', 'lib', 'dll', 'so', 'pyc', 'pyd', 'pyo', 'n', 'ndll', 'pdb', 'cmo', 'cmx', 'cma', 'cmxa', 'cmi'] }, // http://www.file-extensions.org/filetype/extension/name/binary-files
    { icon: 'blade', extensions: ['.blade.php'], special: 'php', contribOrder: 1 },
    { icon: 'bower', extensions: ['bowerrc'] },
    { icon: 'bower', extensions: ['bower.json'], special: 'json', contribType: ctype.filename },
    { icon: 'bundler', extensions: ['gemfile'], contribType: ctype.filename },
    { icon: 'bundler', extensions: ['gemfile.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'c++', extensions: ['cpp', 'hpp', 'cc', 'cxx'] },
    { icon: 'c', extensions: ['c'] },
    { icon: 'cake', extensions: ['cake'] },
    { icon: 'cfm', extensions: ['cfm', 'cfc', 'lucee'] },
    { icon: 'cheader', extensions: ['h'] },
    { icon: 'clojure', extensions: ['clojure', 'cjm', 'clj', 'cljs', 'cljc', 'edn'] },
    { icon: 'cobol', extensions: ['cbl', 'cob', 'cpy'] },
    { icon: 'codeclimate', extensions: ['codeclimate.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'coffeescript', extensions: ['coffee'] },
    { icon: 'config', extensions: ['env', 'ini', 'makefile', 'config'] },
    { icon: 'config', extensions: ['makefile'], contribType: ctype.filename },
    { icon: 'compass', extensions: [] },
    { icon: 'composer', extensions: ['composer.json'], special: 'json', contribType: ctype.filename },
    { icon: 'composer', extensions: ['composer.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'cs', extensions: ['cs', 'csx'] },
    { icon: 'cshtml', extensions: ['cshtml'] },
    { icon: 'csproj', extensions: ['csproj'] },
    { icon: 'css', extensions: ['css'] },
    { icon: 'csslint', extensions: ['csslintrc'] },
    { icon: 'cssmap', extensions: ['.css.map'], special: 'map' },
    { icon: 'cucumber', extensions: ['feature'] },
    { icon: 'dartlang', extensions: ['dart'] },
    { icon: 'delphi', extensions: ['pas', 'dfm', 'dpr'] },
    { icon: 'dlang', extensions: ['d'] },
    { icon: 'docker', extensions: ['dockerfile', 'dockerignore'], contribType: ctype.filename },
    { icon: 'docker', extensions: ['dockerignore'] },
    { icon: 'docker', extensions: ['docker-compose.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'editorconfig', extensions: ['editorconfig'] },
    { icon: 'ejs', extensions: ['ejs'] },
    { icon: 'elixir', extensions: ['ex', 'exs', 'eex'] },
    { icon: 'elm', extensions: ['elm'] },
    { icon: 'elm', extensions: ['elm-package.json'], special: 'json', contribType: ctype.filename, contribOrder: 1 },
    { icon: 'erb', extensions: ['rhtml', 'erb'] },
    { icon: 'erlang', extensions: ['erl', 'hrl', 'emakefile', 'emakerfile'] },
    { icon: 'eslint', extensions: ['eslintrc', 'eslintignore'] },
    { icon: 'eslint', extensions: ['.eslintrc.js'], special: 'js', contribType: ctype.filename },
    { icon: 'eslint', extensions: ['.eslintrc.json'], special: 'json', contribType: ctype.filename },
    { icon: 'eslint', extensions: ['.eslintrc.yaml'], special: 'yaml', contribType: ctype.filename },
    { icon: 'eslint', extensions: ['.eslintrc.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'excel', extensions: ['xls', 'xlsx', 'csv', 'ods'] },
    { icon: 'favicon', extensions: ['favicon.ico'], special: 'ico', contribType: ctype.filename },
    { icon: 'flash', extensions: ['swf', 'swc', 'sol'] },
    { icon: 'flow', extensions: ['flowconfig', 'js.flow'] },
    { icon: 'fsharp', extensions: ['fs', 'fsx', 'fsi'] },
    { icon: 'font', extensions: ['woff', 'woff2', 'ttf', 'otf', 'eot', 'pfa', 'pfb', 'sfd'] },
    { icon: 'fortran', extensions: ['f90', 'mod', 'f'] },
    { icon: 'git', extensions: ['gitattributes', 'gitignore', 'gitmodules', 'gitkeep'] },
    { icon: 'go', extensions: ['go'] },
    { icon: 'gradle', extensions: ['gradle'] },
    { icon: 'graphviz', extensions: [] },
    { icon: 'groovy', extensions: ['groovy'] },
    { icon: 'gruntfile', extensions: ['gruntfile.js'], special: 'js', contribType: ctype.filename },
    { icon: 'gulpfile', extensions: ['gulpfile.js'], special: 'js', contribType: ctype.filename },
    { icon: 'haml', extensions: ['haml'] },
    { icon: 'handlebars', extensions: ['hbs', 'handlebars'] },
    { icon: 'haskell', extensions: ['has', 'hs', 'lhs', 'lit', 'gf'] },
    { icon: 'haxe', extensions: ['hx', 'hxml'] },
    { icon: 'haxe', extensions: ['haxelib.json'], special: 'json', contribType: ctype.filename },
    { icon: 'haxecheckstyle', extensions: ['checkstyle.json'], special: 'json', contribType: ctype.filename },
    { icon: 'haxedevelop', extensions: ['hxproj'] },
    { icon: 'html', extensions: ['htm', 'html'] },
    { icon: 'image', extensions: ['jpeg', 'jpg', 'gif', 'png', 'bmp', 'ico'] },
    { icon: 'ionic', extensions: ['ionic.project'], special: 'project', contribType: ctype.filename },
    { icon: 'ionic', extensions: ['ionic.config.json'], special: 'json', contribType: ctype.filename },
    { icon: 'jade', extensions: ['jade', 'pug', 'jade-lintrc', 'pug-lintrc', 'tag'] },
    { icon: 'jade', extensions: ['.jade-lint.json'], special: 'json', contribType: ctype.filename },
    { icon: 'jade', extensions: ['.pug-lintrc.js'], special: 'js', contribType: ctype.filename },
    { icon: 'jade', extensions: ['.pug-lintrc.json'], special: 'json', contribType: ctype.filename },
    { icon: 'java', extensions: ['java'] },
    { icon: 'jinja', extensions: ['jinja'] },
    { icon: 'js', extensions: ['js'] },
    { icon: 'jshintrc', extensions: ['jshintrc'] },
    { icon: 'jsmap', extensions: ['.js.map'], special: 'map' },
    { icon: 'jsp', extensions: ['jsp'] },
    { icon: 'julia', extensions: ['jl'] },
    { icon: 'log', extensions: ['log'] },
    { icon: 'less', extensions: ['less'] },
    { icon: 'license', extensions: ['enc'] },
    { icon: 'license', extensions: ['license', 'licence'], contribType: ctype.filename },
    { icon: 'license', extensions: ['license.md', 'licence.md'], special: 'md', contribType: ctype.filename },
    { icon: 'lisp', extensions: ['bil'] },
    { icon: 'lime', extensions: ['hxp'] },
    { icon: 'lime', extensions: ['include.xml'], special: 'xml', contribType: ctype.filename },
    { icon: 'lsl', extensions: ['lsl'] },
    { icon: 'lua', extensions: ['lua'] },
    { icon: 'm', extensions: ['m'] },
    { icon: 'markdown', extensions: ['md', 'markdown'] },
    { icon: 'marko', extensions: ['marko'] },
    { icon: 'markojs', extensions: ['.marko.js'], special: 'js' },
    { icon: 'markup', extensions: [] },
    { icon: 'matlab', extensions: ['fig', 'mat', 'mex', 'mexn', 'mexrs6', 'mn', 'mum', 'mx', 'mx3', 'rwd', 'slx', 'slddc', 'smv', 'tikz', 'xvc', 'xvc'] },
    { icon: 'masterpage', extensions: ['master'] },
    { icon: 'mustache', extensions: ['mustache', 'mst'] },
    { icon: 'nim', extensions: ['nim', 'nims', 'cfg'] },
    { icon: 'node', extensions: ['json', 'webmanifest'] },
    { icon: 'node2', extensions: ['nvmrc'] },
    { icon: 'npm', extensions: ['npmignore'] },
    { icon: 'npm', extensions: ['package.json'], special: 'json', contribType: ctype.filename },
    { icon: 'nsi', extensions: ['nsi', 'nsh'] },
    { icon: 'nunjucks', extensions: ['njk', 'nunjucks', 'nunjs', 'nunj', 'njs', 'nj'] },
    { icon: 'ocaml', extensions: ['ml', 'mll', 'mli', 'mly', 'ocamlmakefile', 'merlin'] },
    { icon: 'paket', extensions: ['paket.dependencies'], special: 'dependencies', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.references'], special: 'references', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.template'], special: 'template', contribType: ctype.filename },
    { icon: 'paket', extensions: ['paket.local'], special: 'local', contribType: ctype.filename },
    { icon: 'patch', extensions: ['patch'] },
    { icon: 'perl', extensions: ['perl'] },
    { icon: 'poedit', extensions: ['po', 'mo'] },
    { icon: 'photoshop', extensions: ['psd'] },
    { icon: 'php', extensions: ['php', 'php1', 'php2', 'php3', 'php4', 'php5', 'php6', 'phps', 'phpsa', 'phpt', 'phtml', 'phar'] },
    { icon: 'phpunit', extensions: ['phpunit.xml'], special: 'xml', contribType: ctype.filename },
    { icon: 'plantuml', extensions: ['pu', 'plantuml', 'iuml', 'puml'] },
    { icon: 'procfile', extensions: ['procfile'] },
    { icon: 'postcss', extensions: ['pcss', 'postcss'] },
    { icon: 'powershell', extensions: ['ps1', 'psm1', 'psd1'] },
    { icon: 'protobuf', extensions: ['proto'] },
    { icon: 'puppet', extensions: ['epp'] },
    { icon: 'python', extensions: ['py', 'pyw'] },
    { icon: 'qlikview', extensions: ['qvd', 'qvw'] },
    { icon: 'r', extensions: ['r'] },
    { icon: 'rails', extensions: [] },
    { icon: 'raml', extensions: ['raml'] },
    { icon: 'reactjs', extensions: ['jsx'] },
    { icon: 'reacttemplate', extensions: ['rt'] },
    { icon: 'reactts', extensions: ['tsx'] },
    { icon: 'rest', extensions: ['rest'] },
    { icon: 'riot', extensions: ['tag'] },
    { icon: 'robotframework', extensions: ['robot'] },
    { icon: 'rspec', extensions: ['rspec'] },
    { icon: 'ruby', extensions: ['rb', 'gemspec'] },
    { icon: 'rust', extensions: ['rs'] },
    { icon: 'saltstack', extensions: ['sls'] },
    { icon: 'sass', extensions: ['sass'] },
    { icon: 'scala', extensions: ['scala'] },
    { icon: 'scss', extensions: ['scss'] },
    { icon: 'settings', extensions: [] },
    { icon: 'shell', extensions: ['bat', 'sh', 'cmd', 'bash', 'zsh', 'fish'] },
    { icon: 'slim', extensions: [] },
    { icon: 'sln', extensions: ['sln'] },
    { icon: 'source', extensions: [] },
    { icon: 'sql', extensions: ['sql'] },
    { icon: 'sqlite', extensions: ['sqlite', 'db3'] },
    { icon: 'smarty', extensions: ['tpl', 'swig'] },
    { icon: 'stylelint', extensions: ['stylelintrc'] },
    { icon: 'stylelint', extensions: ['stylelint.config.js'], special: 'js', contribType: ctype.filename },
    { icon: 'stylus', extensions: ['styl'] },
    { icon: 'storyboard', extensions: ['storyboard'] },
    { icon: 'svg', extensions: ['svg'] },
    { icon: 'swift', extensions: ['swift'] },
    { icon: 'tcl', extensions: ['tcl'] },
    { icon: 'terraform', extensions: ['tf', 'terra'] },
    { icon: 'tex', extensions: ['texi', 'tex'] },
    { icon: 'text', extensions: ['txt'] },
    { icon: 'textile', extensions: ['textile'] },
    { icon: 'todo', extensions: ['todo'] },
    { icon: 'travis', extensions: ['.travis.yml'], special: 'yml', contribType: ctype.filename },
    { icon: 'twig', extensions: ['twig'] },
    { icon: 'typescript', extensions: ['ts'] },
    { icon: 'typescriptdef', extensions: ['.d.ts'], special: 'ts' },
    { icon: 'vagrant', extensions: ['vagrantfile'], contribType: ctype.filename },
    { icon: 'vash', extensions: ['vash'] },
    { icon: 'vb', extensions: ['vb'] },
    { icon: 'vbhtml', extensions: ['vbhtml'] },
    { icon: 'vbproj', extensions: ['vbproj'] },
    { icon: 'volt', extensions: ['volt'] },
    { icon: 'vue', extensions: ['vue'] },
    { icon: 'vscode', extensions: ['vscodeignore.json', 'launch.json', 'tasks.json', 'jsconfig.json', 'tsconfig.json'], special: 'json', contribType: ctype.filename },
    { icon: 'vscode', extensions: ['vscodeignore'] },
    { icon: 'webpack', extensions: ['webpack.config.js', 'webpack.config.babel.js', 'webpack.config.dev.js', 'webpack.config.staging.js', 'webpack.config.production.js', 'webpack.config.prod.js'], special: 'js', contribType: ctype.filename },
    { icon: 'webpack', extensions: ['webpack.config.ts'], special: 'ts', contribType: ctype.filename },
    { icon: 'webpack', extensions: ['webpack.config.coffee'], special: 'coffee', contribType: ctype.filename },
    { icon: 'xib', extensions: ['xib'] },
    { icon: 'xliff', extensions: ['xliff', 'xlf'] },
    { icon: 'xml', extensions: ['xml', 'axml', 'xaml', 'pex'] },
    { icon: 'yaml', extensions: ['yml', 'yaml'] },
    { icon: 'yarn', extensions: ['yarnclean'] },
    { icon: 'yarn', extensions: ['yarn.lock'], special: 'lock', contribType: ctype.filename },
    { icon: 'zip', extensions: ['zip', 'rar', '7z', 'tar', 'gz', 'bzip2', 'xz', 'bz2'] }
  ],
  parse: function () {
    var s = this.replace(/\./g, '_');
    if ((/^\d/).test(s)) return 'n' + s;
    return s;
  }
};
<|endoftext|>


<commit_before>/**
 * jQuery.spCss - A CSS helper plugin for jQuery.
 *
 * This plugin requires:
 *      1. jQuery ~2.0
 *
 * @author    Gonzalo Chumillas <gchumillas@email.com>
 * @license   https://github.com/soloproyectos-js/jquery.sp-css/blob/master/LICENSE MIT License
 * @link      https://github.com/soloproyectos-js/jquery.sp-css
 */
(function ($) {

    /**
     * Available methods
     * @var {Object}
     */
    var methods = {
        /**
         * Encodes a css parameter.
         *
         * For example:
         * ```JavaScript
         * var str = $.spCode('encode', 'Hi there, how are you?');
         * ```
         *
         * @param {string} text Text to be encoded
         *
         * @return   {string}
         */
        'encode': function (text) {
            return text.replace( /(:|\.|\[|\]|,)/g, "\\$1" );
        },

        /**
         * Quotes a css parameter.
         *
         * For example:
         * ```JavaScript
         * var str = 'Hello, "how" \'are\' you?';
         * var div = $('div[title=' + $.spCss('quote', str, "'") + ']');
         * ```
         *
         * @param {string} text      Text to be encoded
         * @param {string} quoteChar Quoted character (default is ")
         *
         * @return {string}
         */
        'quote': function (text, quoteChar) {
            if (quoteChar === undefined) {
                quoteChar = '"';
            }

            // replaces quoted characteres
            var regExp = new RegExp(quoteChar, "g");
            var str = $.spCss('encode', text).replace(regExp, "\\$&");

            return quoteChar + str + quoteChar;
        }
    };

    /**
     * Registers plugin.
     *
     * @param {string} methodName Method name
     * @param {mixed}  args,...   Additional arguments (not required)
     *
     * @return {mixed}
     */
    $.spCss = function (methodName, args) {
        var method = methods[methodName];
        var args = Array.prototype.slice.call(arguments, 1);

        if (method === undefined) {
            $.error('Method not found: ' + methodName);
        }

        return method.apply(this, args);
    };
})(jQuery);
<commit_msg>docfix<commit_after>/**
 * jQuery.spCss - A CSS helper plugin for jQuery.
 *
 * This plugin requires:
 *      1. jQuery ~2.0
 *
 * @author  Gonzalo Chumillas <gchumillas@email.com>
 * @license https://github.com/soloproyectos-js/jquery.sp-css/blob/master/LICENSE MIT License
 * @link    https://github.com/soloproyectos-js/jquery.sp-css
 */
(function ($) {

    /**
     * Available methods
     * @var {Object}
     */
    var methods = {
        /**
         * Encodes a css parameter.
         *
         * For example:
         * ```JavaScript
         * var str = $.spCode('encode', 'Hi there, how are you?');
         * ```
         *
         * @param {string} text Text to be encoded
         *
         * @return   {string}
         */
        'encode': function (text) {
            return text.replace( /(:|\.|\[|\]|,)/g, "\\$1" );
        },

        /**
         * Quotes a css parameter.
         *
         * For example:
         * ```JavaScript
         * var str = 'Hello, "how" \'are\' you?';
         * var div = $('div[title=' + $.spCss('quote', str, "'") + ']');
         * ```
         *
         * @param {string} text      Text to be encoded
         * @param {string} quoteChar Quoted character (default is ")
         *
         * @return {string}
         */
        'quote': function (text, quoteChar) {
            if (quoteChar === undefined) {
                quoteChar = '"';
            }

            // replaces quoted characteres
            var regExp = new RegExp(quoteChar, "g");
            var str = $.spCss('encode', text).replace(regExp, "\\$&");

            return quoteChar + str + quoteChar;
        }
    };

    /**
     * Registers plugin.
     *
     * @param {string} methodName Method name
     * @param {mixed}  args,...   Additional arguments (not required)
     *
     * @return {mixed}
     */
    $.spCss = function (methodName, args) {
        var method = methods[methodName];
        var args = Array.prototype.slice.call(arguments, 1);

        if (method === undefined) {
            $.error('Method not found: ' + methodName);
        }

        return method.apply(this, args);
    };
})(jQuery);
<|endoftext|>