<commit_before>// Copyright 2012 The Obvious Corporation.

/*
 * Tests for the typ module
 */

/*
 * Modules used
 */

"use strict";

var assert = require("assert");
var events = require("events");
var util = require("util");

var typ = require("../");

/*
 * Module variables
 */

/**
 * List of all predicate and assertion functions. Each element maps
 * `assert` to the assertion and `predicate` to the predicate.
 */
var PREDICATES = [
  { assert: typ.assertArray, predicate: typ.isArray },
  { assert: typ.assertBoolean, predicate: typ.isBoolean },
  { assert: typ.assertBuffer, predicate: typ.isBuffer },
  { assert: typ.assertDate, predicate: typ.isDate },
  { assert: typ.assertDefined, predicate: typ.isDefined },
  { assert: typ.assertError, predicate: typ.isError },
  { assert: typ.assertFunction, predicate: typ.isFunction },
  { assert: typ.assertInt, predicate: typ.isInt },
  { assert: typ.assertMap, predicate: typ.isMap },
  { assert: typ.assertNumber, predicate: typ.isNumber },
  { assert: typ.assertObject, predicate: typ.isObject },
  { assert: typ.assertRegExp, predicate: typ.isRegExp },
  { assert: typ.assertString, predicate: typ.isString },
  { assert: typ.assertUint, predicate: typ.isUint },
  { assert: typ.assertUndefined, predicate: typ.isUndefined },
];

/**
 * List of value / predicate correspondences for use as test cases. On
 * each element `v` maps to an arbitrary value, and `p` maps to a list
 * of predicates which should be true for the value. All unlisted predicates
 * for a value are expected to be false for that value.
 */
var PREDICATE_CASES = [
  // arrays
  { v: [], p: [typ.isArray, typ.isObject, typ.isDefined] },
  { v: [1, 2, 3], p: [typ.isArray, typ.isObject, typ.isDefined] },
  // booleans
  { v: false, p: [typ.isBoolean, typ.isDefined] },
  { v: true, p: [typ.isBoolean, typ.isDefined] },
  // buffers
  { v: new Buffer(100), p: [typ.isBuffer, typ.isObject, typ.isDefined] },
  // dates
  { v: new Date(1234567), p: [typ.isDate, typ.isObject, typ.isDefined] },
  // errors
  { v: new Error("oy"), p: [typ.isError, typ.isObject, typ.isDefined] },
  // functions
  { v: function () { return 0; },
    p: [typ.isFunction, typ.isObject, typ.isDefined] },
  // maps
  { v: {}, p: [typ.isMap, typ.isObject, typ.isDefined] },
  { v: { a: 10, b: 20 }, p: [typ.isMap, typ.isObject, typ.isDefined] },
  // numbers
  { v: 0, p: [typ.isInt, typ.isUint, typ.isNumber, typ.isDefined] },
  { v: 10, p: [typ.isInt, typ.isUint, typ.isNumber, typ.isDefined] },
  { v: 1e200, p: [typ.isInt, typ.isUint, typ.isNumber, typ.isDefined] },
  { v: -1, p: [typ.isInt, typ.isNumber, typ.isDefined] },
  { v: -12345, p: [typ.isInt, typ.isNumber, typ.isDefined] },
  { v: -12e55, p: [typ.isInt, typ.isNumber, typ.isDefined] },
  { v: 123.4, p: [typ.isNumber, typ.isDefined] },
  { v: Infinity, p: [typ.isNumber, typ.isDefined] },
  { v: -Infinity, p: [typ.isNumber, typ.isDefined] },
  { v: NaN, p: [typ.isNumber, typ.isDefined] }, // somewhat ironic
  { v: -1e-1000, p: [typ.isNumber, typ.isDefined] },
  // regexps
  { v: /frobozz/, p: [typ.isRegExp, typ.isObject, typ.isDefined] },
  // strings
  { v: "", p: [typ.isString, typ.isDefined] },
  { v: "blort", p: [typ.isString, typ.isDefined] },
  // other
  { v: new events.EventEmitter(), p: [typ.isObject, typ.isDefined] },
  { v: { get a() { return 5; } }, p: [typ.isObject, typ.isDefined] },
  { v: null, p: [typ.isDefined] },
  { v: undefined, p: [typ.isUndefined] }
];

/*
 * Helper functions
 */

/**
 * Gets whether the given value is in the given array.
 */
function contains(array, value) {
  for (var i = 0; i < array.length; i++) {
    if (array[i] === value) {
      return true;
    }
  }

  return false;
}

/*
 * Tests
 */

/**
 * Test all the predicate cases. For each value, run each of the
 * predicates and assertions, checking to make sure they are all
 * as expected.
 */
function testAllPredicates() {
  for (var i = 0; i < PREDICATE_CASES.length; i++) {
    var one = PREDICATE_CASES[i];
    testOneValue(one.v, one.p);
  }

  function testOneValue(value, predicates) {
    for (var i = 0; i < PREDICATES.length; i++) {
      var one = PREDICATES[i];
      var assertFunc = one.assert;
      var predicate = one.predicate;
      var expectTrue = contains(predicates, predicate);

      var passedPredicate;
      try {
        passedPredicate = predicate(value);
      } catch (ex) {
        console.log("Unexpected exception", ex.stack);
        var msg = predicate.name + "(" + util.inspect(value) + ")";
        assert.fail("no exception", ex, msg);
      }

      if (predicate(value) !== expectTrue) {
        var msg = predicate.name + "(" + util.inspect(value) + ")";
        assert.fail(!expectTrue, expectTrue, msg);
      }

      var passedAssert;
      try {
        assertFunc(value);
        passedAssert = true;
      } catch (ex) {
        passedAssert = false;
      }

      if (passedAssert !== expectTrue) {
        var msg = assertFunc.name + "(" + util.inspect(value) + ")";
        assert.fail(!expectTrue, expectTrue, msg);
      }
    }
  }
}

/**
 * Test `hasDefaultPrototype()`.
 */
function testHasDefaultPrototype() {
  assert.ok(typ.hasDefaultPrototype({}));
  assert.ok(!typ.hasDefaultPrototype(Object.create({})));
  assert.ok(!typ.hasDefaultPrototype(new events.EventEmitter()));
}

/**
 * Test `hasOwnProperty()`.
 */
function testHasOwnProperty() {
  assert.ok(typ.hasOwnProperty({a: 10}, "a"));
  assert.ok(!typ.hasOwnProperty({}, "hasOwnProperty"));
  assert.ok(typ.hasOwnProperty({hasOwnProperty: "yay"}, "hasOwnProperty"));
}

testAllPredicates();
testHasDefaultPrototype();
testHasOwnProperty();

console.log("All tests pass.");
<commit_msg>Expanded tests a little.<commit_after>// Copyright 2012 The Obvious Corporation.

/*
 * Tests for the typ module
 */

/*
 * Modules used
 */

"use strict";

var assert = require("assert");
var events = require("events");
var util = require("util");

var typ = require("../");

/*
 * Module variables
 */

/**
 * List of all predicate and assertion functions. Each element maps
 * `assert` to the assertion and `predicate` to the predicate.
 */
var PREDICATES = [
  { assert: typ.assertArray, predicate: typ.isArray },
  { assert: typ.assertBoolean, predicate: typ.isBoolean },
  { assert: typ.assertBuffer, predicate: typ.isBuffer },
  { assert: typ.assertDate, predicate: typ.isDate },
  { assert: typ.assertDefined, predicate: typ.isDefined },
  { assert: typ.assertError, predicate: typ.isError },
  { assert: typ.assertFunction, predicate: typ.isFunction },
  { assert: typ.assertInt, predicate: typ.isInt },
  { assert: typ.assertMap, predicate: typ.isMap },
  { assert: typ.assertNumber, predicate: typ.isNumber },
  { assert: typ.assertObject, predicate: typ.isObject },
  { assert: typ.assertRegExp, predicate: typ.isRegExp },
  { assert: typ.assertString, predicate: typ.isString },
  { assert: typ.assertUint, predicate: typ.isUint },
  { assert: typ.assertUndefined, predicate: typ.isUndefined },
];

/**
 * List of value / predicate correspondences for use as test cases. On
 * each element `v` maps to an arbitrary value, and `p` maps to a list
 * of predicates which should be true for the value. All unlisted predicates
 * for a value are expected to be false for that value.
 */
var PREDICATE_CASES = [
  // arrays
  { v: [], p: [typ.isArray, typ.isObject, typ.isDefined] },
  { v: [1, 2, 3], p: [typ.isArray, typ.isObject, typ.isDefined] },
  // booleans
  { v: false, p: [typ.isBoolean, typ.isDefined] },
  { v: true, p: [typ.isBoolean, typ.isDefined] },
  // buffers
  { v: new Buffer(100), p: [typ.isBuffer, typ.isObject, typ.isDefined] },
  // dates
  { v: new Date(1234567), p: [typ.isDate, typ.isObject, typ.isDefined] },
  // errors
  { v: new Error("oy"), p: [typ.isError, typ.isObject, typ.isDefined] },
  // functions
  { v: function () { return 0; },
    p: [typ.isFunction, typ.isObject, typ.isDefined] },
  { v: new Function("return 5"),
    p: [typ.isFunction, typ.isObject, typ.isDefined] },
  // maps
  { v: {}, p: [typ.isMap, typ.isObject, typ.isDefined] },
  { v: { a: 10, b: 20 }, p: [typ.isMap, typ.isObject, typ.isDefined] },
  // non-map objects
  { v: new events.EventEmitter(), p: [typ.isObject, typ.isDefined] },
  { v: { get a() { return 5; } }, p: [typ.isObject, typ.isDefined] },
  { v: { set b(n) { } }, p: [typ.isObject, typ.isDefined] },
  // numbers
  { v: 0, p: [typ.isInt, typ.isUint, typ.isNumber, typ.isDefined] },
  { v: 10, p: [typ.isInt, typ.isUint, typ.isNumber, typ.isDefined] },
  { v: 1e200, p: [typ.isInt, typ.isUint, typ.isNumber, typ.isDefined] },
  { v: -1, p: [typ.isInt, typ.isNumber, typ.isDefined] },
  { v: -12345, p: [typ.isInt, typ.isNumber, typ.isDefined] },
  { v: -12e55, p: [typ.isInt, typ.isNumber, typ.isDefined] },
  { v: 123.4, p: [typ.isNumber, typ.isDefined] },
  { v: Infinity, p: [typ.isNumber, typ.isDefined] },
  { v: -Infinity, p: [typ.isNumber, typ.isDefined] },
  { v: NaN, p: [typ.isNumber, typ.isDefined] }, // somewhat ironic
  { v: -1e-1000, p: [typ.isNumber, typ.isDefined] }, // !isInt()
  // regexps
  { v: /frobozz/, p: [typ.isRegExp, typ.isObject, typ.isDefined] },
  { v: new RegExp("fizmo"), p: [typ.isRegExp, typ.isObject, typ.isDefined] },
  // strings
  { v: "", p: [typ.isString, typ.isDefined] },
  { v: "blort", p: [typ.isString, typ.isDefined] },
  // notable edge cases
  { v: new Number(5), p: [typ.isObject, typ.isDefined] }, // !isNumber()
  { v: new String("fuzz"), p: [typ.isObject, typ.isDefined] }, // !isString()
  { v: new Boolean(true), p: [typ.isObject, typ.isDefined] }, // !isBoolean()
  // other
  { v: null, p: [typ.isDefined] },
  { v: undefined, p: [typ.isUndefined] }
];

/*
 * Helper functions
 */

/**
 * Gets whether the given value is in the given array.
 */
function contains(array, value) {
  for (var i = 0; i < array.length; i++) {
    if (array[i] === value) {
      return true;
    }
  }

  return false;
}

/*
 * Tests
 */

/**
 * Test all the predicate cases. For each value, run each of the
 * predicates and assertions, checking to make sure they are all
 * as expected.
 */
function testAllPredicates() {
  for (var i = 0; i < PREDICATE_CASES.length; i++) {
    var one = PREDICATE_CASES[i];
    testOneValue(one.v, one.p);
  }

  function testOneValue(value, predicates) {
    for (var i = 0; i < PREDICATES.length; i++) {
      var one = PREDICATES[i];
      var assertFunc = one.assert;
      var predicate = one.predicate;
      var expectTrue = contains(predicates, predicate);

      var passedPredicate;
      try {
        passedPredicate = predicate(value);
      } catch (ex) {
        console.log("Unexpected exception", ex.stack);
        var msg = predicate.name + "(" + util.inspect(value) + ")";
        assert.fail("no exception", ex, msg);
      }

      if (predicate(value) !== expectTrue) {
        var msg = predicate.name + "(" + util.inspect(value) + ")";
        assert.fail(!expectTrue, expectTrue, msg);
      }

      var passedAssert;
      try {
        assertFunc(value);
        passedAssert = true;
      } catch (ex) {
        passedAssert = false;
      }

      if (passedAssert !== expectTrue) {
        var msg = assertFunc.name + "(" + util.inspect(value) + ")";
        assert.fail(!expectTrue, expectTrue, msg);
      }
    }
  }
}

/**
 * Test `hasDefaultPrototype()`.
 */
function testHasDefaultPrototype() {
  assert.ok(typ.hasDefaultPrototype({}));
  assert.ok(!typ.hasDefaultPrototype(Object.create({})));
  assert.ok(!typ.hasDefaultPrototype(new events.EventEmitter()));
}

/**
 * Test `hasOwnProperty()`.
 */
function testHasOwnProperty() {
  assert.ok(typ.hasOwnProperty({a: 10}, "a"));
  assert.ok(!typ.hasOwnProperty({}, "hasOwnProperty"));
  assert.ok(typ.hasOwnProperty({hasOwnProperty: "yay"}, "hasOwnProperty"));
}

testAllPredicates();
testHasDefaultPrototype();
testHasOwnProperty();

console.log("All tests pass.");
<|endoftext|>


<commit_before>angular.module("angular-growl").directive("growl", ["$rootScope", function ($rootScope) {
	"use strict";

	return {
		restrict: 'A',
		template:   '
' +
			'
' +
			'		<button type="button" class="close" ng-click="deleteMessage(message)">×</button>' +
			'            {{ message.text}}' +
			'
' +
			'
',
		replace: false,
		scope: true,
		controller: function ($scope) {
			$scope.messages = [];

			$scope.showMessages = function () {
				return $scope.messages.length > 0;
			};

			$rootScope.$on("growlMessage", function (event, message) {
				$scope.messages.push(message);
			});

			$scope.deleteMessage = function (message) {
				var index = $scope.messages.indexOf(message);
				if (index > -1) {
					$scope.messages.splice(index, 1);
				}

			};

			$scope.computeClasses = function (message) {
				return {
					'alert-success': message.isSuccess,
					'alert-error': message.isError,
					'alert-info': message.isInfo
				};
			};
		}
	};
}]);<commit_msg>Added TTL for growl message (auto expires message)<commit_after>angular.module("angular-growl").directive("growl", ["$rootScope", function ($rootScope) {
	"use strict";

	return {
		restrict: 'A',
		template:   '
' +
			'
' +
			'		<button type="button" class="close" ng-click="deleteMessage(message)">×</button>' +
			'            {{ message.text}}' +
			'
' +
			'
',
		replace: false,
		scope: true,
		controller: function ($scope, $timeout) {
			$scope.messages = [];

			$scope.showMessages = function () {
				return $scope.messages.length > 0;
			};

			$rootScope.$on("growlMessage", function (event, message) {
				$scope.messages.push(message);
				if (message.ttl) {
                                    $timeout(function() { $scope.deleteMessage(message); }, message.ttl);
                                }
			});

			$scope.deleteMessage = function (message) {
				var index = $scope.messages.indexOf(message);
				if (index > -1) {
					$scope.messages.splice(index, 1);
				}

			};

			$scope.computeClasses = function (message) {
				return {
					'alert-success': message.isSuccess,
					'alert-error': message.isError,
					'alert-info': message.isInfo
				};
			};
		}
	};
}]);
<|endoftext|>


<commit_before>import React from 'react'
import ProjectTable from '../components/project-table'

const Projects = () => {
  return (

      <ProjectTable />

  )
}

export default Projects
<commit_msg>redirect if not logged in<commit_after>import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'

import ProjectTable from '../components/project-table'

// TODO - turn project page into a more generic view component after login
class Projects extends Component {

  componentDidMount() {
    if (!this.props.loggedIn) this.context.router.push('/')
  }

  render() {
    return (

        <ProjectTable />

    )
  }
}

Projects.contextTypes = {
  router: PropTypes.object.isRequired
}

const mapStateToProps = (state) =>  {
  return {
    loggedIn: state.login.loggedIn
  }
}

export default connect(mapStateToProps)(Projects)
<|endoftext|>


<commit_before>/*global describe, it, beforeEach */
'use strict';

var expect = require('chai').expect;
var exec = require('child_process').exec;

var KyotoTocoon = require('../index');

describe('kt-client', function() {
  describe('get test', function() {
    beforeEach(function(done) {
      exec('ktremotemgr clear', function () {
        done();
      });
    });

    it('data', function(done) {
      exec('ktremotemgr set test_key test_value', function () {
        var client = new KyotoTocoon();
        client.get('test_key', function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('utf-8 data', function(done) {
      exec('ktremotemgr set test_key test_value', function () {
        var client = new KyotoTocoon();
        var options = {
          encoding: 'utf8'
        };
        client.get('test_key', options, function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('binary data', function(done) {
      exec('ktremotemgr set test_key binary', function () {
        var client = new KyotoTocoon();
        var options = {
          encoding: 'binary'
        };
        client.get('test_key', options, function(error, value, expire) {
          expect(Buffer.isBuffer(value)).to.be.true;
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('data and expiration time', function(done) {
      exec('ktremotemgr set -xt 300 test_key test_value', function () {
        var client = new KyotoTocoon();
        client.get('test_key', function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.an.instanceof(Date);
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('no data', function(done) {
      var client = new KyotoTocoon();
      client.get('test_key', function(error, value, expire) {
        expect(value).to.be.undefined;
        expect(expire).to.be.undefined;
        expect(error).to.equal('No record was found');
        done();
      });
    });

    it('connection error', function(done) {
      var client = new KyotoTocoon({
        host: 'localhost',
        port: 9999
      });
      client.get('test_key', function(error, value, expire) {
        expect(value).to.be.undefined;
        expect(expire).to.be.undefined;
        expect(error).to.equal('Connection error');
        done();
      });
    });
  });

  describe('set test', function() {
    beforeEach(function(done) {
      exec('ktremotemgr clear', function () {
        done();
      });
    });

    it('data', function(done) {
      var client = new KyotoTocoon();
      client.set('test_key', 'test_value', function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('utf-8 data', function(done) {
      var client = new KyotoTocoon();
      var options = {
        encoding: 'utf8'
      };
      client.set('test_key', 'test_value', options, function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', options, function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('binary data', function(done) {
      var client = new KyotoTocoon();
      var testValue = new Buffer('test_value');
      var options = {
        encoding: 'binary'
      };
      client.set('test_key', testValue, options, function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', options, function(error, value, expire) {
          expect(value.toString()).to.equal(testValue.toString());
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('data and expiration time', function(done) {
      var client = new KyotoTocoon();
      var options = {
        expire: 300
      };
      client.set('test_key', 'test_value', options, function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', function(error, value, expire) {
          expect(value.to.equal('test_value'));
          expect(expire).to.be.an.instanceof(Date);
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('connection error', function(done) {
      var client = new KyotoTocoon({
        host: 'localhost',
        port: 9999
      });
      client.set('test_key', 'test_value', function(error) {
        expect(error).to.equal('Connection error');
        done();
      });
    });
  });
});
<commit_msg>Fixed test<commit_after>/*global describe, it, beforeEach*/
/*jshint expr: true*/
'use strict';

var expect = require('chai').expect;
var exec = require('child_process').exec;

var KyotoTocoon = require('../index');

describe('kt-client', function() {
  describe('get test', function() {
    beforeEach(function(done) {
      exec('ktremotemgr clear', function () {
        done();
      });
    });

    it('data', function(done) {
      exec('ktremotemgr set test_key test_value', function () {
        var client = new KyotoTocoon();
        client.get('test_key', function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('utf-8 data', function(done) {
      exec('ktremotemgr set test_key test_value', function () {
        var client = new KyotoTocoon();
        var options = {
          encoding: 'utf8'
        };
        client.get('test_key', options, function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('binary data', function(done) {
      exec('ktremotemgr set test_key binary', function () {
        var client = new KyotoTocoon();
        var options = {
          encoding: 'binary'
        };
        client.get('test_key', options, function(error, value, expire) {
          expect(Buffer.isBuffer(value)).to.be.true;
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('data and expiration time', function(done) {
      exec('ktremotemgr set -xt 300 test_key test_value', function () {
        var client = new KyotoTocoon();
        client.get('test_key', function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.an.instanceof(Date);
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('no data', function(done) {
      var client = new KyotoTocoon();
      client.get('test_key', function(error, value, expire) {
        expect(value).to.be.undefined;
        expect(expire).to.be.undefined;
        expect(error).to.equal('No record was found');
        done();
      });
    });

    it('connection error', function(done) {
      var client = new KyotoTocoon({
        host: 'localhost',
        port: 9999
      });
      client.get('test_key', function(error, value, expire) {
        expect(value).to.be.undefined;
        expect(expire).to.be.undefined;
        expect(error).to.equal('Connection error');
        done();
      });
    });
  });

  describe('set test', function() {
    beforeEach(function(done) {
      exec('ktremotemgr clear', function () {
        done();
      });
    });

    it('data', function(done) {
      var client = new KyotoTocoon();
      client.set('test_key', 'test_value', function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('utf-8 data', function(done) {
      var client = new KyotoTocoon();
      var options = {
        encoding: 'utf8'
      };
      client.set('test_key', 'test_value', options, function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', options, function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('binary data', function(done) {
      var client = new KyotoTocoon();
      var testValue = new Buffer('test_value');
      var options = {
        encoding: 'binary'
      };
      client.set('test_key', testValue, options, function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', options, function(error, value, expire) {
          expect(value.toString()).to.equal(testValue.toString());
          expect(expire).to.be.null;
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('data and expiration time', function(done) {
      var client = new KyotoTocoon();
      var options = {
        expire: 300
      };
      client.set('test_key', 'test_value', options, function(error) {
        expect(error).to.be.undefined;
        client.get('test_key', function(error, value, expire) {
          expect(value).to.equal('test_value');
          expect(expire).to.be.an.instanceof(Date);
          expect(error).to.be.undefined;
          done();
        });
      });
    });

    it('connection error', function(done) {
      var client = new KyotoTocoon({
        host: 'localhost',
        port: 9999
      });
      client.set('test_key', 'test_value', function(error) {
        expect(error).to.equal('Connection error');
        done();
      });
    });
  });
});
<|endoftext|>


<commit_before><commit_msg>Changes select Karma settings to BrowserStack's recommendations.<commit_after><|endoftext|>


<commit_before>// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors

cur_frm.cscript.refresh = function(doc,cdt,cdn){
	cur_frm.toggle_enable('user_input', doc.__islocal);
	if(doc.naming_series=='CUST-')
		cur_frm.toggle_enable('customer_code', doc.__islocal);

	var last_route = frappe.route_history.slice(-2, -1)[0];
	if(last_route && last_route[0]==="Form") {
		var doctype = last_route[1],
		docname = last_route.slice(2).join("/");

	if(["Customer", "Quotation", "Sales Order", "Sales Invoice", "Delivery Note",
		"Installation Note", "Opportunity", "Warranty Claim", "Maintenance Visit",
		"Maintenance Schedule"]
		.indexOf(doctype)!==-1) {
		var refdoc = frappe.get_doc(doctype, docname);
		if((refdoc.doctype == "Quotation" && refdoc.quotation_to=="Customer") ||
			(refdoc.doctype == "Opportunity" && refdoc.enquiry_from=="Customer") ||
			!in_list(["Opportunity", "Quotation"], doctype)) {
				cur_frm.set_value("customer_code",refdoc.customer_code);

		}
	}

}

}

cur_frm.add_fetch('customer','customer_code','customer_code');

cur_frm.add_fetch('city','state','state');
cur_frm.add_fetch('city','district','district');
cur_frm.add_fetch('city','country','country');

<commit_msg>made customer_name field read-only after first save<commit_after>// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors

cur_frm.cscript.refresh = function(doc,cdt,cdn){
	cur_frm.toggle_enable('user_input', doc.__islocal);
	if(doc.naming_series=='CUST-')
		cur_frm.toggle_enable('customer_name', doc.__islocal);

	var last_route = frappe.route_history.slice(-2, -1)[0];
	if(last_route && last_route[0]==="Form") {
		var doctype = last_route[1],
		docname = last_route.slice(2).join("/");

	if(["Customer", "Quotation", "Sales Order", "Sales Invoice", "Delivery Note",
		"Installation Note", "Opportunity", "Warranty Claim", "Maintenance Visit",
		"Maintenance Schedule"]
		.indexOf(doctype)!==-1) {
		var refdoc = frappe.get_doc(doctype, docname);
		if((refdoc.doctype == "Quotation" && refdoc.quotation_to=="Customer") ||
			(refdoc.doctype == "Opportunity" && refdoc.enquiry_from=="Customer") ||
			!in_list(["Opportunity", "Quotation"], doctype)) {
				cur_frm.set_value("customer_code",refdoc.customer_code);

		}
	}

}

}

cur_frm.add_fetch('customer','customer_code','customer_code');

cur_frm.add_fetch('city','state','state');
cur_frm.add_fetch('city','district','district');
cur_frm.add_fetch('city','country','country');

<|endoftext|>


<commit_before>'use strict';

const ghExplore = require('../');
const should = require('should');

(function () {

  describe('Showcases:', function () {

    it('GET /showcases', function (done) {
      ghExplore.showcases.all(function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /showcases?page=<page_num>', function (done) {
      ghExplore.showcases.all({ page_num: 2 }, function (err, res) {
        try {
          should(res).have.property('page', 2);
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /showcases/<showcase_name>', function (done) {
      ghExplore.showcases.get({ showcase: 'machine-learning' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /showcases/<showcase_name>?s=stars', function (done) {
      ghExplore.showcases.get({ showcase: 'machine-learning', sort: 'stars' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /showcases/<showcase_name>?s=language', function (done) {
      ghExplore.showcases.get({ showcase: 'machine-learning', sort: 'language' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /showcases/search?q=<query>', function (done) {
      ghExplore.showcases.search({ query: 'machine learning' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('/showcases/<bad_showcase_name> -> should fail', function (done) {
      ghExplore.showcases.get({ showcase: 'bad-showcase' }, function (err, res) {
        try {
          should(err).have.property('status', 'failed');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

  });

  describe('Integrations:', function () {

    it('GET /integrations', function (done) {
      ghExplore.integrations.all(function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /integrations/feature/<category>', function (done) {
      ghExplore.integrations.all({ category: 'all' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /integrations/<integration_name>', function (done) {
      ghExplore.integrations.get({ integration: 'travis-ci' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /integrations?query=<query>', function (done) {
      ghExplore.integrations.search({ query: 'travis' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('/integrations/feature/<bad_category> -> should fail', function (done) {
      ghExplore.integrations.all({ category: 'bad-category' }, function (err, res) {
        try {
          should(err).have.property('status', 'failed');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('/integrations/<bad-integration_name> -> should fail', function (done) {
      ghExplore.integrations.get({ integration: 'bad-integration' }, function (err, res) {
        try {
          should(err).have.property('status', 'failed');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

  });

  describe('Trending:', function () {

    it('GET /trending', function (done) {
      ghExplore.trending(function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending?since=daily', function (done) {
      ghExplore.trending({ since: 'daily' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending?since=weekly', function (done) {
      ghExplore.trending({ since: 'weekly' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending?since=monthly', function (done) {
      ghExplore.trending({ since: 'monthly' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending/<language>', function (done) {
      ghExplore.trending({ language: 'java' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending/developers', function (done) {
      ghExplore.trending({ type: 'developers' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending/developers?since=daily', function (done) {
      ghExplore.trending({ type: 'developers', since: 'daily' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending/developers?since=weekly', function (done) {
      ghExplore.trending({ type: 'developers', since: 'weekly' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending/developers?since=monthly', function (done) {
      ghExplore.trending({ type: 'developers', since: 'monthly' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

    it('GET /trending/developers/<language>', function (done) {
      ghExplore.trending({ type: 'developers', language: 'java' }, function (err, res) {
        try {
          should(res).have.property('status', 'successful');
          done();
        } catch (e) {
          done(e);
        }
      });
    });

  });

}());
<commit_msg>minor improvements<commit_after>'use strict';

const ghExplore = require('../');
const should = require('should');

describe('Showcases:', function () {

  it('GET /showcases', function (done) {
    ghExplore.showcases.all(function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /showcases?page=<page_num>', function (done) {
    ghExplore.showcases.all({ page_num: 2 }, function (err, res) {
      try {
        should(res).have.property('page', 2);
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /showcases/<showcase_name>', function (done) {
    ghExplore.showcases.get({ showcase: 'machine-learning' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /showcases/<showcase_name>?s=stars', function (done) {
    ghExplore.showcases.get({ showcase: 'machine-learning', sort: 'stars' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
        } catch (e) {
          done(e);
        }
    });
  });

  it('GET /showcases/<showcase_name>?s=language', function (done) {
    ghExplore.showcases.get({ showcase: 'machine-learning', sort: 'language' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /showcases/search?q=<query>', function (done) {
    ghExplore.showcases.search({ query: 'machine learning' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('/showcases/<bad_showcase_name> -> should fail', function (done) {
    ghExplore.showcases.get({ showcase: 'bad-showcase' }, function (err, res) {
      try {
        should(err).have.property('status', 'failed');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

});

describe('Integrations:', function () {

  it('GET /integrations', function (done) {
    ghExplore.integrations.all(function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /integrations/feature/<category>', function (done) {
    ghExplore.integrations.all({ category: 'all' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /integrations/<integration_name>', function (done) {
    ghExplore.integrations.get({ integration: 'travis-ci' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /integrations?query=<query>', function (done) {
    ghExplore.integrations.search({ query: 'travis' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('/integrations/feature/<bad_category> -> should fail', function (done) {
    ghExplore.integrations.all({ category: 'bad-category' }, function (err, res) {
      try {
        should(err).have.property('status', 'failed');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('/integrations/<bad_integration_name> -> should fail', function (done) {
    ghExplore.integrations.get({ integration: 'bad-integration' }, function (err, res) {
      try {
        should(err).have.property('status', 'failed');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

});

describe('Trending:', function () {

  it('GET /trending', function (done) {
    ghExplore.trending(function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending?since=daily', function (done) {
    ghExplore.trending({ since: 'daily' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending?since=weekly', function (done) {
    ghExplore.trending({ since: 'weekly' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending?since=monthly', function (done) {
    ghExplore.trending({ since: 'monthly' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
          done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending/<language>', function (done) {
    ghExplore.trending({ language: 'java' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending/developers', function (done) {
    ghExplore.trending({ type: 'developers' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending/developers?since=daily', function (done) {
    ghExplore.trending({ type: 'developers', since: 'daily' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending/developers?since=weekly', function (done) {
    ghExplore.trending({ type: 'developers', since: 'weekly' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending/developers?since=monthly', function (done) {
    ghExplore.trending({ type: 'developers', since: 'monthly' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

  it('GET /trending/developers/<language>', function (done) {
    ghExplore.trending({ type: 'developers', language: 'java' }, function (err, res) {
      try {
        should(res).have.property('status', 'successful');
        done();
      } catch (e) {
        done(e);
      }
    });
  });

});
<|endoftext|>


<commit_before>/* global describe, it */

var app = require('../app/index');
var request = require('supertest').agent(app.listen());

describe('GET /', function () {
    it('status code should be 200', function (done) {
        request
            .get('/')
            .expect(200, done);
    });
});

describe('GET user id from params', function () {
  it('should display "1024"', function (done) {
    request
      .get('/users/1024')
      .expect('1024', done);
  });
});
<commit_msg>dirty work<commit_after>/* global describe, it */

var app = require('../app/index');
var request = require('supertest').agent(app.listen());

describe('GET /', function () {
  it('status code should be 200', function (done) {
    request
      .get('/')
      .expect(200, done);
  });
});

describe('GET user id from params', function () {
  it('should display "1024"', function (done) {
    request
      .get('/users/1024')
      .expect('1024', done);
  });
});
<|endoftext|>


<commit_before>var starwars = require('../src/index.js');
var test = require('tape');

test ('star-wars argument list tests', function (t) {
  t.notOk(starwars(['--testing', '--testing123']), 'try [\'--testing\', \'--testing123\']; return false');
  t.ok(starwars(['--testing', '--force']), 'try [\'--testing\', \'--force\']; return true');

  t.notOk(starwars('testing'), 'try \'testing\'; return false');
  t.ok(starwars(['force']), 'try \'force\'; return true');

  t.ok(starwars(['force']), 'try [\'force\']; return true');
  t.ok(starwars(['--force']), 'try [\'--force\']; return true');

  t.end();
});
<commit_msg>fix: change test import so we can actually test the code<commit_after>var starwars = require('../index.js');
var test = require('tape');

test ('star-wars argument list tests', function (t) {
  t.notOk(starwars(['--testing', '--testing123']), 'try [\'--testing\', \'--testing123\']; return false');
  t.ok(starwars(['--testing', '--force']), 'try [\'--testing\', \'--force\']; return true');

  t.notOk(starwars('testing'), 'try \'testing\'; return false');
  t.ok(starwars(['force']), 'try \'force\'; return true');

  t.ok(starwars(['force']), 'try [\'force\']; return true');
  t.ok(starwars(['--force']), 'try [\'--force\']; return true');

  t.end();
});
<|endoftext|>


<commit_before>var assert = require( 'assert' );
var rollup = require( 'rollup' );
var plugin = require( '..' );

process.chdir( __dirname );

describe( 'rollup-plugin-typescript', function () {
	this.timeout( 5000 );

	it( 'runs code through typescript', function () {
		var start = Date.now();
		return rollup.rollup({
			entry: 'sample/basic/main.ts',
			plugins: [ plugin() ]
		}).then( function ( bundle ) {
			console.log( 'bundled in %s ms', Date.now() - start );

			start = Date.now();
			const generated = bundle.generate();
			console.log( 'generated in %s ms', Date.now() - start );

			const code = generated.code;

			assert.ok( code.indexOf( 'const' ) === -1, code );
		});
	});
});
<commit_msg>test TS specific features<commit_after>var assert = require( 'assert' );
var rollup = require( 'rollup' );
var plugin = require( '..' );

process.chdir( __dirname );

describe( 'rollup-plugin-typescript', function () {
	this.timeout( 5000 );

	it( 'runs code through typescript', function () {
		var start = Date.now();
		return rollup.rollup({
			entry: 'sample/basic/main.ts',
			plugins: [ plugin() ]
		}).then( function ( bundle ) {
			console.log( 'bundled in %s ms', Date.now() - start );

			start = Date.now();
			const generated = bundle.generate();
			console.log( 'generated in %s ms', Date.now() - start );

			const code = generated.code;

			assert.ok( code.indexOf( 'number' ) === -1, code );
		});
	});
});
<|endoftext|>


<commit_before>'use strict';

require('should');
const checker = require('../index');
const os = require('os');
const execSync = require('child_process').execSync;

describe('check-branch', () => {
  describe('success', () => {
    it('should resolve object with success true if in right branch', () => {
      return checker('master').should.be.fulfilledWith({
        success: true,
        detail: 'master'
      });
    });
  });
  describe('fail', () => {
    beforeEach(() => execSync('git checkout -b sometestbranch', {
      stdio: 'pipe'
    }));
    afterEach(() => {
      execSync('git checkout master', {
        stdio: 'pipe'
      });
      execSync('git branch -D sometestbranch', {
        stdio: 'pipe'
      });
    });
    it('should resolve object with success false if not in right branch', () => {
      return checker('master').should.be.fulfilledWith({
        success: false,
        detail: 'sometestbranch'
      });
    });
  });
  describe('error', () => {
    it('should reject with an error when branch is not a string', () => {
      return checker({}).should.be.rejectedWith(TypeError, {
        message: 'Expected branch to be a string'
      });
    });
    it('should reject with an error when cwd is not a string', () => {
      return checker('master', {}).should.be.rejectedWith(TypeError, {
        message: 'Expected cwd to be a string'
      });
    });
    it('should reject with an error when no git repository found', () => {
      let dir = os.tmpdir();
      return checker('master', dir).should.be.rejectedWith(Error, {
        message: `No git repository was found in ${dir}`
      });
    });
  });
});
<commit_msg>:smile:<commit_after>'use strict';

require('should');
const checker = require('../index');
const os = require('os');
const execSync = require('child_process').execSync;

describe('check-branch', () => {
  const currentBranch = execSync('git status').toString().match(/^On\sbranch\s(.*)\s/)[1];
  before(() => execSync('git checkout -b testbranch', {
    stdio: 'pipe'
  }));
  after(() => {
    execSync(`git checkout ${currentBranch}`, {
      stdio: 'pipe'
    });
    execSync('git branch -D testbranch', {
      stdio: 'pipe'
    });
  });
  describe('success', () => {
    it('should resolve object with success true if in right branch', () => {
      return checker('master').should.be.fulfilledWith({
        success: true,
        detail: 'master'
      });
    });
  });
  describe('fail', () => {
    beforeEach(() => execSync('git checkout -b sometestbranch', {
      stdio: 'pipe'
    }));
    afterEach(() => {
      execSync('git checkout master', {
        stdio: 'pipe'
      });
      execSync('git branch -D sometestbranch', {
        stdio: 'pipe'
      });
    });
    it('should resolve object with success false if not in right branch', () => {
      return checker('master').should.be.fulfilledWith({
        success: false,
        detail: 'sometestbranch'
      });
    });
  });
  describe('error', () => {
    it('should reject with an error when branch is not a string', () => {
      return checker({}).should.be.rejectedWith(TypeError, {
        message: 'Expected branch to be a string'
      });
    });
    it('should reject with an error when cwd is not a string', () => {
      return checker('master', {}).should.be.rejectedWith(TypeError, {
        message: 'Expected cwd to be a string'
      });
    });
    it('should reject with an error when no git repository found', () => {
      let dir = os.tmpdir();
      return checker('master', dir).should.be.rejectedWith(Error, {
        message: `No git repository was found in ${dir}`
      });
    });
  });
});
<|endoftext|>


<commit_before>'use strict';

var assert = require("assert");
var fs = require('fs');
var os = require('os');
var path = require('path');
var touch = require('touch');
var middleware = require('../index.js');

//Helper Functions
function getManifest(server, callback) {
  var buf = [];
  var ccHeader = null;
  var ctHeader = null;

  var mockResponse = {
    end: function(s) {
      if (typeof s === 'string') {
        buf.push(s);
      }
      try {
        assert.equal(ccHeader, 'no-cache', 'Cache-Control header should be no-cache');
        assert.equal(ctHeader, 'text/cache-manifest', 'Content-Type header should be text/cache-manifest');
        var manifest = parseManifest(buf.join(''));
        callback(null, manifest);
      } catch(err) {
        callback(err);
      }
    },
    write: function(s) {
      if (typeof s === 'string') {
        buf.push(s);
      }
    },
    set: function(name, value) {
      if (name === 'Cache-Control') {
        ccHeader = value;
      } else if (name === 'Content-Type') {
        ctHeader = value;
      }
    }
  };

  server(null, mockResponse);
}

function parseManifest(body) {
  var manifest = { CACHE: [], COMMENTS: [] };
  var lines = body.split('\n');
  assert.equal(lines[0], 'CACHE MANIFEST', 'First line should be CACHE MANIFEST');
  var section = 'CACHE';
  for (var i = 1; i < lines.length; i++) {
    var line = lines[i];
    assert.equal(line.trim(), line, 'No extra whitespace expected in cache manifest');
    if (line.length === 0) {
      //Blank line
      section = null;
    } else if (line.startsWith('#')) {
      //Comment
      manifest['COMMENTS'].push(line.substr(1));
    } else if (section === null) {
      //New section header
      assert(line.endsWith(':'), 'Cache section lines should end with :');
      section = line.substr(0, line.length - 1);
      if (section !== 'CACHE') {
        assert(!(section in manifest), 'Multiple copies of section header ' + section + ' found in manifest');
        manifest[section] = [];
      }
    } else {
      //Inside of an existing section
      manifest[section].push(line);
    }
  }

  assert.deepEqual(manifest['CACHE'].slice().sort(), manifest['CACHE'], 'Cache entries should be soted');

  return manifest;
}

//Function to expect a callback to be called one occurrence at a time
function callbackWatcher(defaultTimeout) {
  if (typeof defaultTimeout !== 'number') {
    defaultTimeout = 500;
  }
  var updateCallback = null;
  var currentMsg = null;

  function updateListener() {
    if (typeof updateCallback === 'function') {
      var tmp = updateCallback;
      updateCallback = null;
      currentMsg = null;
      tmp.apply(this, arguments);
    }
  }

  function waitForUpdate(msg, callback, timeout) {
    currentMsg = msg;
    var outtaTime = false;
    if (typeof timeout !== 'number') {
      timeout = defaultTimeout;
    }

    var timeoutId = setTimeout(function() {
      outtaTime = true;
      updateCallback = null;
      currentMsg = null;
      callback(new Error(msg));
    }, timeout);

    updateCallback = function() {
      clearTimeout(timeoutId);
      if (! outtaTime) {
        outtaTime = true; //TODO: rename this
        Array.prototype.splice.call(arguments, 0, 0, null);
        callback.apply(this, arguments);
      }
    };
  }

  return {
    listener: updateListener,
    wait: waitForUpdate
  };
}

var CONFIG = [{
    file: 'test_files/some_files',
    url: 'some'
  }, {
    file: 'test_files/more_files',
    url: 'test_files/more_files'
  }, {
    file: 'test_files/hello.txt',
    url: 'hello.txt'
  }
];

var INITIAL_FILES = [
  'test_files/hello.txt',
  'test_files/some_files/a.txt',
  'test_files/some_files/b.txt',
  'test_files/some_files/nested/x.txt',
  'test_files/some_files/nested/y.txt',
  'test_files/more_files/1.txt',
  'test_files/more_files/2.txt'
];

var INITIAL_URLS = [
  '/hello.txt',
  '/some/a.txt',
  '/some/b.txt',
  '/some/nested/x.txt',
  '/some/nested/y.txt',
  '/test_files/more_files/1.txt',
  '/test_files/more_files/2.txt'
];

//Tests
describe('Check filesystem', function() {
  it('Should contain expected files', function(done) {
    var count = 0;
    for(var i = 0; i < INITIAL_FILES.length; i++) {
      var filePath = INITIAL_FILES[i];
      fs.stat(filePath, function(err, stat) {
        count++;
        try {
          assert(err === null, 'Error getting fs stat');
          assert(stat.isFile(), 'Missing initial file');
          if (count === INITIAL_FILES.length) {
            done();
          }
        } catch(err) {
          done(err);
        }
      });
    }
  });
});

describe('Initialization', function() {
  it('should initialize properly', function (done) {
    middleware.generator(CONFIG, { readyCallback: function(server) {
      server.stop();
      done();
    }});
  });

  it('Should contain expected elements', function (done) {
    middleware.generator(CONFIG, { readyCallback: function(server) {
      getManifest(server, function(err, manifest) {
        try {
          if (err) { throw err; }
          assert.deepEqual(manifest['NETWORK'], ['*'], 'Network section doesn\'t hold expected value'); //TODO: pull this from opts
          assert.deepEqual(manifest['CACHE'], INITIAL_URLS, 'Cache section doesn\'t hold expected value(s)');
          done();
        } catch (err) {
          done(err);
        } finally {
          server.stop();
        }
      });
    }});
  });

  it('Should contain expected elements when configured with absolute paths', function (done) {
    var absolutePaths = [];
    for (var i = 0; i < CONFIG.length; i++) {
      absolutePaths.push({
        file: path.resolve(process.cwd(), CONFIG[i]['file']),
        url: CONFIG[i]['url']
      });
    }

    middleware.generator(absolutePaths, { readyCallback: function(server) {
      getManifest(server, function(err, manifest) {
        try {
          server.stop();
          if (err) { return done(err); }
          assert.deepEqual(manifest['NETWORK'], ['*'], 'Network section doesn\'t hold expected value'); //TODO: pull this from opts
          assert.deepEqual(manifest['CACHE'], INITIAL_URLS, 'Cache section doesn\'t hold expected value(s)');
          done();
        } catch (err) {
          done(err);
        }
      });
    }});
  });
});

describe('Observe Changes', function() {
  var newFile = 'test_files/some_files/new_dir/1.txt';
  var newUrl = '/some/new_dir/1.txt';

  function deleteTempFiles() {
    try {
      fs.statSync(path.dirname(newFile));
      try {
        fs.statSync(newFile);
        fs.unlinkSync(newFile);

      } catch (fileErr) {
        if (fileErr.code !== 'ENOENT') {
          throw fileErr;
        }
      }
      fs.rmdirSync(path.dirname(newFile));
    } catch (dirErr) {
      if (dirErr.code !== 'ENOENT') {
        throw dirErr;
      }
    }
  }

  before(deleteTempFiles);
  after(deleteTempFiles);

  var manifestWatcher = callbackWatcher(500);
  var fileWatcher = callbackWatcher(500);

  var server = null;
  beforeEach(function(done) {
    middleware.generator(CONFIG, {
      catchupDelay: 0,
      updateListener: manifestWatcher.listener,
      fileListener: fileWatcher.listener,
      readyCallback: function(s) {
        server = s;
        done();
      }
    });
  });

  afterEach(function() {
    assert(server !== null, 'Server shouldn\'t be null after test');
    server.stop();
    server = null;
  });

  it('Should observe modifications to watched files', function(done) {
    touch('test_files/hello.txt');
    manifestWatcher.wait('Timeout waiting for manifest update', function(err, manifest) {
      if (err) { done(err); }
      else { done(); }
    });
  });

  it('Should observe modifications to files in watched directories', function(done) {
    touch('test_files/some_files/a.txt');
    manifestWatcher.wait('Timeout waiting for manifest update', function(err, manifest) {
      if (err) { done(err); }
      else { done(); }
    });
  });

  it('Should observe modifications to files in subdirectories', function(done) {
    touch('test_files/some_files/nested/x.txt');
    manifestWatcher.wait('Timeout waiting for manifest update', function(err, manifest) {
      if (err) { done(err); }
      else { done(); }
    });
  });

  it('Should observe file creations and modifications to those new files', function(done) {
    try {
      fs.mkdirSync(path.dirname(newFile));
      fileWatcher.wait('Timeout waiting for directory create event', function(err, evt, evtPath) {
        if (err) { return done(err); }
        console.log('waited and got ' + evt + ', ' + evtPath);
        fs.writeFileSync(newFile, 'TEXT');
        manifestWatcher.wait('Timeout waiting for update after file creation', function(err, manifest) {
          if (err) { return done(err); }
          try {
            assert(manifest['CACHE'].indexOf(newUrl) !== -1, 'Newly created file should be in manifest');
            setTimeout(function() {  //Need to wait a second or the file modify time may be unchanged
              touch.sync(newFile);
              manifestWatcher.wait('Timeout waiting for update after file touch', function(err, manifest) {
                if (err) { return done(err); }
                fs.unlinkSync(newFile);
                //Deleting a directory that is being watched in Windows crashes watchr!
                if (! os.platform().startsWith('win')) {
                  fs.rmdirSync(path.dirname(newFile));
                }
                manifestWatcher.wait('Timeout waiting for update after file delete', function(err, manifest) {
                  if (err) { return done(err); }
                  try {
                    assert(manifest['CACHE'].indexOf(newUrl) === -1, 'Deleted file shouldn\'t be in manifest');
                    done();
                  } catch (err) {
                    done(err);
                  }
                });
              });
            }, 1000);
          } catch (err) {
            done(err);
          }
        });
      });
    } catch (err) {
      done(err);
    }
  });
});
<commit_msg>Removed some debug logging<commit_after>'use strict';

var assert = require("assert");
var fs = require('fs');
var os = require('os');
var path = require('path');
var touch = require('touch');
var middleware = require('../index.js');

//Helper Functions
function getManifest(server, callback) {
  var buf = [];
  var ccHeader = null;
  var ctHeader = null;

  var mockResponse = {
    end: function(s) {
      if (typeof s === 'string') {
        buf.push(s);
      }
      try {
        assert.equal(ccHeader, 'no-cache', 'Cache-Control header should be no-cache');
        assert.equal(ctHeader, 'text/cache-manifest', 'Content-Type header should be text/cache-manifest');
        var manifest = parseManifest(buf.join(''));
        callback(null, manifest);
      } catch(err) {
        callback(err);
      }
    },
    write: function(s) {
      if (typeof s === 'string') {
        buf.push(s);
      }
    },
    set: function(name, value) {
      if (name === 'Cache-Control') {
        ccHeader = value;
      } else if (name === 'Content-Type') {
        ctHeader = value;
      }
    }
  };

  server(null, mockResponse);
}

function parseManifest(body) {
  var manifest = { CACHE: [], COMMENTS: [] };
  var lines = body.split('\n');
  assert.equal(lines[0], 'CACHE MANIFEST', 'First line should be CACHE MANIFEST');
  var section = 'CACHE';
  for (var i = 1; i < lines.length; i++) {
    var line = lines[i];
    assert.equal(line.trim(), line, 'No extra whitespace expected in cache manifest');
    if (line.length === 0) {
      //Blank line
      section = null;
    } else if (line.startsWith('#')) {
      //Comment
      manifest['COMMENTS'].push(line.substr(1));
    } else if (section === null) {
      //New section header
      assert(line.endsWith(':'), 'Cache section lines should end with :');
      section = line.substr(0, line.length - 1);
      if (section !== 'CACHE') {
        assert(!(section in manifest), 'Multiple copies of section header ' + section + ' found in manifest');
        manifest[section] = [];
      }
    } else {
      //Inside of an existing section
      manifest[section].push(line);
    }
  }

  assert.deepEqual(manifest['CACHE'].slice().sort(), manifest['CACHE'], 'Cache entries should be soted');

  return manifest;
}

//Function to expect a callback to be called one occurrence at a time
function callbackWatcher(defaultTimeout) {
  if (typeof defaultTimeout !== 'number') {
    defaultTimeout = 500;
  }
  var updateCallback = null;
  var currentMsg = null;

  function updateListener() {
    if (typeof updateCallback === 'function') {
      var tmp = updateCallback;
      updateCallback = null;
      currentMsg = null;
      tmp.apply(this, arguments);
    }
  }

  function waitForUpdate(msg, callback, timeout) {
    currentMsg = msg;
    var outtaTime = false;
    if (typeof timeout !== 'number') {
      timeout = defaultTimeout;
    }

    var timeoutId = setTimeout(function() {
      outtaTime = true;
      updateCallback = null;
      currentMsg = null;
      callback(new Error(msg));
    }, timeout);

    updateCallback = function() {
      clearTimeout(timeoutId);
      if (! outtaTime) {
        outtaTime = true; //TODO: rename this
        Array.prototype.splice.call(arguments, 0, 0, null);
        callback.apply(this, arguments);
      }
    };
  }

  return {
    listener: updateListener,
    wait: waitForUpdate
  };
}

var CONFIG = [{
    file: 'test_files/some_files',
    url: 'some'
  }, {
    file: 'test_files/more_files',
    url: 'test_files/more_files'
  }, {
    file: 'test_files/hello.txt',
    url: 'hello.txt'
  }
];

var INITIAL_FILES = [
  'test_files/hello.txt',
  'test_files/some_files/a.txt',
  'test_files/some_files/b.txt',
  'test_files/some_files/nested/x.txt',
  'test_files/some_files/nested/y.txt',
  'test_files/more_files/1.txt',
  'test_files/more_files/2.txt'
];

var INITIAL_URLS = [
  '/hello.txt',
  '/some/a.txt',
  '/some/b.txt',
  '/some/nested/x.txt',
  '/some/nested/y.txt',
  '/test_files/more_files/1.txt',
  '/test_files/more_files/2.txt'
];

//Tests
describe('Check filesystem', function() {
  it('Should contain expected files', function(done) {
    var count = 0;
    for(var i = 0; i < INITIAL_FILES.length; i++) {
      var filePath = INITIAL_FILES[i];
      fs.stat(filePath, function(err, stat) {
        count++;
        try {
          assert(err === null, 'Error getting fs stat');
          assert(stat.isFile(), 'Missing initial file');
          if (count === INITIAL_FILES.length) {
            done();
          }
        } catch(err) {
          done(err);
        }
      });
    }
  });
});

describe('Initialization', function() {
  it('should initialize properly', function (done) {
    middleware.generator(CONFIG, { readyCallback: function(server) {
      server.stop();
      done();
    }});
  });

  it('Should contain expected elements', function (done) {
    middleware.generator(CONFIG, { readyCallback: function(server) {
      getManifest(server, function(err, manifest) {
        try {
          if (err) { throw err; }
          assert.deepEqual(manifest['NETWORK'], ['*'], 'Network section doesn\'t hold expected value'); //TODO: pull this from opts
          assert.deepEqual(manifest['CACHE'], INITIAL_URLS, 'Cache section doesn\'t hold expected value(s)');
          done();
        } catch (err) {
          done(err);
        } finally {
          server.stop();
        }
      });
    }});
  });

  it('Should contain expected elements when configured with absolute paths', function (done) {
    var absolutePaths = [];
    for (var i = 0; i < CONFIG.length; i++) {
      absolutePaths.push({
        file: path.resolve(process.cwd(), CONFIG[i]['file']),
        url: CONFIG[i]['url']
      });
    }

    middleware.generator(absolutePaths, { readyCallback: function(server) {
      getManifest(server, function(err, manifest) {
        try {
          server.stop();
          if (err) { return done(err); }
          assert.deepEqual(manifest['NETWORK'], ['*'], 'Network section doesn\'t hold expected value'); //TODO: pull this from opts
          assert.deepEqual(manifest['CACHE'], INITIAL_URLS, 'Cache section doesn\'t hold expected value(s)');
          done();
        } catch (err) {
          done(err);
        }
      });
    }});
  });
});

describe('Observe Changes', function() {
  var newFile = 'test_files/some_files/new_dir/1.txt';
  var newUrl = '/some/new_dir/1.txt';

  function deleteTempFiles() {
    try {
      fs.statSync(path.dirname(newFile));
      try {
        fs.statSync(newFile);
        fs.unlinkSync(newFile);

      } catch (fileErr) {
        if (fileErr.code !== 'ENOENT') {
          throw fileErr;
        }
      }
      fs.rmdirSync(path.dirname(newFile));
    } catch (dirErr) {
      if (dirErr.code !== 'ENOENT') {
        throw dirErr;
      }
    }
  }

  before(deleteTempFiles);
  after(deleteTempFiles);

  var manifestWatcher = callbackWatcher(500);
  var fileWatcher = callbackWatcher(500);

  var server = null;
  beforeEach(function(done) {
    middleware.generator(CONFIG, {
      catchupDelay: 0,
      updateListener: manifestWatcher.listener,
      fileListener: fileWatcher.listener,
      readyCallback: function(s) {
        server = s;
        done();
      }
    });
  });

  afterEach(function() {
    assert(server !== null, 'Server shouldn\'t be null after test');
    server.stop();
    server = null;
  });

  it('Should observe modifications to watched files', function(done) {
    touch('test_files/hello.txt');
    manifestWatcher.wait('Timeout waiting for manifest update', function(err, manifest) {
      if (err) { done(err); }
      else { done(); }
    });
  });

  it('Should observe modifications to files in watched directories', function(done) {
    touch('test_files/some_files/a.txt');
    manifestWatcher.wait('Timeout waiting for manifest update', function(err, manifest) {
      if (err) { done(err); }
      else { done(); }
    });
  });

  it('Should observe modifications to files in subdirectories', function(done) {
    touch('test_files/some_files/nested/x.txt');
    manifestWatcher.wait('Timeout waiting for manifest update', function(err, manifest) {
      if (err) { done(err); }
      else { done(); }
    });
  });

  it('Should observe file creations and modifications to those new files', function(done) {
    try {
      fs.mkdirSync(path.dirname(newFile));
      fileWatcher.wait('Timeout waiting for directory create event', function(err, evt, evtPath) {
        if (err) { return done(err); }
        fs.writeFileSync(newFile, 'TEXT');
        manifestWatcher.wait('Timeout waiting for update after file creation', function(err, manifest) {
          if (err) { return done(err); }
          try {
            assert(manifest['CACHE'].indexOf(newUrl) !== -1, 'Newly created file should be in manifest');
            setTimeout(function() {  //Need to wait a second or the file modify time may be unchanged
              touch.sync(newFile);
              manifestWatcher.wait('Timeout waiting for update after file touch', function(err, manifest) {
                if (err) { return done(err); }
                fs.unlinkSync(newFile);
                //Deleting a directory that is being watched in Windows crashes watchr!
                if (! os.platform().startsWith('win')) {
                  fs.rmdirSync(path.dirname(newFile));
                }
                manifestWatcher.wait('Timeout waiting for update after file delete', function(err, manifest) {
                  if (err) { return done(err); }
                  try {
                    assert(manifest['CACHE'].indexOf(newUrl) === -1, 'Deleted file shouldn\'t be in manifest');
                    done();
                  } catch (err) {
                    done(err);
                  }
                });
              });
            }, 1000);
          } catch (err) {
            done(err);
          }
        });
      });
    } catch (err) {
      done(err);
    }
  });
});
<|endoftext|>


<commit_before>import React, { Component, PropTypes } from "react"
import styles from "./index.css"
import { Treebeard } from "react-treebeard"
import treeStyle from "./treeStyle"
import decorators from "./decorators"
import data from "../../content/toc.json"
import { browserHistory } from "phenomic/lib/client"
const cx = require("classnames/bind").bind(styles)

export default class Menu extends Component {
  static propTypes = {
    visible: PropTypes.bool.isRequired,
  };

  constructor(props) {
    super(props)
    this.state = {}
  }

  handleOnToggle = (node, toggled) => {
    if (this.state.cursor) {
      // eslint-disable-next-line
      this.state.cursor.active = false
    }

    node.active = true

    if (node.children) {
      node.toggled = toggled
    }
    this.setState({ cursor: node })

    if (node.path) {
      browserHistory.push(node.path)
    }
  }

  render() {
    const wrapperClass = cx("menu", "toc-menu", {
      menuVisible: this.props.visible,
    })

    return (

        <Treebeard
          style={ treeStyle }
          data={ data }
          decorators={ decorators }
          onToggle={ this.handleOnToggle }
        />

    )
  }
}
<commit_msg>make disabled node unclickable<commit_after>import React, { Component, PropTypes } from "react"
import styles from "./index.css"
import { Treebeard } from "react-treebeard"
import treeStyle from "./treeStyle"
import decorators from "./decorators"
import data from "../../content/toc.json"
import { browserHistory } from "phenomic/lib/client"
const cx = require("classnames/bind").bind(styles)

export default class Menu extends Component {
  static propTypes = {
    visible: PropTypes.bool.isRequired,
  };

  constructor(props) {
    super(props)
    this.state = {}
  }

  handleOnToggle = (node, toggled) => {
    if (!node.hasOwnProperty("path") && node.level !== 1) {
      return
    }
    if (this.state.cursor) {
      // eslint-disable-next-line
      this.state.cursor.active = false
    }

    node.active = true

    if (node.children) {
      node.toggled = toggled
    }
    this.setState({ cursor: node })

    if (node.path) {
      browserHistory.push(node.path)
    }
  }

  render() {
    const wrapperClass = cx("menu", "toc-menu", {
      menuVisible: this.props.visible,
    })

    return (

        <Treebeard
          style={ treeStyle }
          data={ data }
          decorators={ decorators }
          onToggle={ this.handleOnToggle }
        />

    )
  }
}
<|endoftext|>


<commit_before>Package.describe({
  name: "edgee:slingshot",
  summary: "Directly post files to cloud storage services, such as AWS-S3.",
  version: "0.2.0"
});

Package.on_use(function (api) {
  api.use(["underscore", "check"]);
  api.use("tracker", "client");

  api.add_files("lib/upload.js", "client");
  api.add_files([
    "lib/directive.js",
    "services/aws-s3.js",
    "services/google-cloud.js"
  ], "server");

  api.export("Slingshot");
});
<commit_msg>Package definition<commit_after>Package.describe({
  name: "edgee:slingshot",
  summary: "Directly post files to cloud storage services, such as AWS-S3.",
  version: "0.0.1",
  git: "https://github.com/CulturalMe/meteor-slingshot"
});

Package.on_use(function (api) {
  api.versionsFrom('METEOR@1.0.0');

  api.use(["underscore", "check"]);
  api.use(["tracker", "reactive-var"], "client");

  api.add_files("lib/upload.js", "client");
  api.add_files([
    "lib/directive.js",
    "services/aws-s3.js",
    "services/google-cloud.js"
  ], "server");

  api.export("Slingshot");
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'jagi:astronomy-validators',
  version: '1.0.0',
  summary: 'Validators for Meteor Astronomy',
  git: 'https://github.com/jagi/meteor-astronomy-validators.git'
});

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.2');

  api.use('jagi:astronomy@1.0.0');
  api.use('jagi:reactive-map@1.0.0');
  api.use('underscore');
  api.use('ui');
  api.use('check');
  api.use('tracker');
  api.use('ejson');

  api.imply('jagi:astronomy');

  // Module.
  api.addFiles([
    'lib/module/global.js',
    'lib/module/validation_error.js',
    'lib/module/validation_error_event.js',
    'lib/module/validator.js',
    'lib/module/field_validator.js',
    'lib/module/create_validator.js',
    'lib/module/validate.js',
    'lib/module/get_error.js',
    'lib/module/ejson.js',
    'lib/module/init_definition.js',
    'lib/module/init_schema.js',
    'lib/module/init_class.js'
  ], ['client', 'server']);

  // Type validators.
  api.addFiles([
    'lib/validators/type/string.js',
    'lib/validators/type/number.js',
    'lib/validators/type/boolean.js',
    'lib/validators/type/array.js',
    'lib/validators/type/object.js',
    'lib/validators/type/date.js',
    'lib/validators/type/email.js'
  ], ['client', 'server']);

  // Existence validators.
  api.addFiles([
    'lib/validators/existence/required.js',
    'lib/validators/existence/null.js',
    'lib/validators/existence/not_null.js',
  ], ['client', 'server']);

  // Size validators.
  api.addFiles([
    'lib/validators/size/length.js',
    'lib/validators/size/min_length.js',
    'lib/validators/size/max_length.js',
    'lib/validators/size/gt.js',
    'lib/validators/size/gte.js',
    'lib/validators/size/lt.js',
    'lib/validators/size/lte.js'
  ], ['client', 'server']);

  // Comparison validators.
  api.addFiles([
    'lib/validators/comparison/choice.js',
    'lib/validators/comparison/unique.js',
    'lib/validators/comparison/equal.js',
    'lib/validators/comparison/equal_to.js',
    'lib/validators/comparison/regexp.js'
  ], ['client', 'server']);

  // Logical validators.
  api.addFiles([
    'lib/validators/logical/and.js',
    'lib/validators/logical/or.js',
    'lib/validators/logical/if.js',
    'lib/validators/logical/switch.js'
  ], ['client', 'server']);

  // Embeded validators.
  api.addFiles([
    'lib/validators/nested/every.js',
    'lib/validators/nested/has.js',
    'lib/validators/nested/contains.js'
  ], ['client', 'server']);

  api.export(['Validators'], ['client', 'server']);
});
<commit_msg>Bump version to 1.0.1<commit_after>Package.describe({
  name: 'jagi:astronomy-validators',
  version: '1.0.1',
  summary: 'Validators for Meteor Astronomy',
  git: 'https://github.com/jagi/meteor-astronomy-validators.git'
});

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.2');

  api.use('jagi:astronomy@1.0.0');
  api.use('jagi:reactive-map@1.0.0');
  api.use('underscore');
  api.use('ui');
  api.use('check');
  api.use('tracker');
  api.use('ejson');

  api.imply('jagi:astronomy');

  // Module.
  api.addFiles([
    'lib/module/global.js',
    'lib/module/validation_error.js',
    'lib/module/validation_error_event.js',
    'lib/module/validator.js',
    'lib/module/field_validator.js',
    'lib/module/create_validator.js',
    'lib/module/validate.js',
    'lib/module/get_error.js',
    'lib/module/ejson.js',
    'lib/module/init_definition.js',
    'lib/module/init_schema.js',
    'lib/module/init_class.js'
  ], ['client', 'server']);

  // Type validators.
  api.addFiles([
    'lib/validators/type/string.js',
    'lib/validators/type/number.js',
    'lib/validators/type/boolean.js',
    'lib/validators/type/array.js',
    'lib/validators/type/object.js',
    'lib/validators/type/date.js',
    'lib/validators/type/email.js'
  ], ['client', 'server']);

  // Existence validators.
  api.addFiles([
    'lib/validators/existence/required.js',
    'lib/validators/existence/null.js',
    'lib/validators/existence/not_null.js',
  ], ['client', 'server']);

  // Size validators.
  api.addFiles([
    'lib/validators/size/length.js',
    'lib/validators/size/min_length.js',
    'lib/validators/size/max_length.js',
    'lib/validators/size/gt.js',
    'lib/validators/size/gte.js',
    'lib/validators/size/lt.js',
    'lib/validators/size/lte.js'
  ], ['client', 'server']);

  // Comparison validators.
  api.addFiles([
    'lib/validators/comparison/choice.js',
    'lib/validators/comparison/unique.js',
    'lib/validators/comparison/equal.js',
    'lib/validators/comparison/equal_to.js',
    'lib/validators/comparison/regexp.js'
  ], ['client', 'server']);

  // Logical validators.
  api.addFiles([
    'lib/validators/logical/and.js',
    'lib/validators/logical/or.js',
    'lib/validators/logical/if.js',
    'lib/validators/logical/switch.js'
  ], ['client', 'server']);

  // Embeded validators.
  api.addFiles([
    'lib/validators/nested/every.js',
    'lib/validators/nested/has.js',
    'lib/validators/nested/contains.js'
  ], ['client', 'server']);

  api.export(['Validators'], ['client', 'server']);
});
<|endoftext|>


<commit_before>var fs = require('fs');
var Coinigy = require('../dist/index');
var config = JSON.parse(fs.readFileSync('./test-config.json', 'utf8'));
var coinigy = new Coinigy(config.apiKey, config.apiSecret);
var chai = require('chai');
chai.should();
const child_process = require('child_process');

const sleep = (sec) => {
  child_process.execSync(`sleep ${sec}`);
}

describe('Coinigy API', function () {
  describe('Account Data', function() {
    //userInfo skip because not authorized to use this endpoint
    describe('userInfo', function () {
      it('should return many keys', function () {
        return coinigy.userInfo()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('activity', function () {
      it('should return many keys', function () {
        return coinigy.activity()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.data.should.be.an('array');
          //console.log(b.data);
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('accounts', function () {
      it('lists all accounts', function () {
        return coinigy.accounts()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.notifications.should.be.an('array').with.length(0);
          //b.open_order.should.have.all.keys('exch_name');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('balances', function () {
      it('lists all account balance', function () {
        return coinigy.balances()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.notifications.should.be.an('array').with.length(0);
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('balance history', function() {
      it('should have keys', function () {
        return coinigy.balanceHistory({date: '2017-07-01'})
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('orders', function () {
      it('lists all orders', function () {
        return coinigy.orders()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.notifications.should.be.an('array').with.length(0);
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('alerts', function() {
      it('should have keys', function () {
        return coinigy.alerts()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('user watch list', function() {
      it('should have keys', function () {
        return coinigy.userWatchList()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('news feed', function() {
      it('should have keys', function () {
        return coinigy.newsFeed()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    //end account data
  });

  //accout functions
  describe('Account Functions', function() {

    //TODO update user
    //TODO save preferences
    //TODO update tickers
    //TODO order types

    describe('refreshBalance', function () {
      it('refresh balance of specific auth_ids, in this case coinbase 8304', function () {
        return coinigy.refreshBalance({auth_id: 13605})
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    //TODO add alert
    //TODO delete alert
    //TODO add api key
    //TODO delete api key
    //TODO activate api key
    //TODO activate trading key
    //TODO add order
    //TODO cancel order
  });

  describe('Market Data', function() {
    describe('exchanges', function () {
      it('should get the exchanges', function () {
        return coinigy.exchanges()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('markets', function () {
      it('should get the markets', function () {
        return coinigy.markets()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('data', function () {
      it('should get the data', function () {
        return coinigy.data({exchange_code: 'GDAX', exchange_market: 'BTC/USD', type: 'history'})
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('ticker', function () {
      it('should get the ticker', function () {
        return coinigy.ticker({
          exchange_code: 'GDAX',
          exchange_market: 'BTC/USD'
        })
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });
  });

  //How do I test post with a specific body? IE: auth_ids = 1234 in post for Refresh Balance
  //http://docs.coinigy.apiary.io/#reference/account-functions/refresh-balance/refreshbalance
});
<commit_msg>- require test-config.json directly<commit_after>var Coinigy = require('../dist/index');
var config = require('../test-config.json');
var coinigy = new Coinigy(config.apiKey, config.apiSecret);
var chai = require('chai');
chai.should();
const child_process = require('child_process');

const sleep = (sec) => {
  child_process.execSync(`sleep ${sec}`);
}

describe('Coinigy API', function () {
  describe('Account Data', function() {
    //userInfo skip because not authorized to use this endpoint
    describe('userInfo', function () {
      it('should return many keys', function () {
        return coinigy.userInfo()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('activity', function () {
      it('should return many keys', function () {
        return coinigy.activity()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.data.should.be.an('array');
          //console.log(b.data);
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('accounts', function () {
      it('lists all accounts', function () {
        return coinigy.accounts()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.notifications.should.be.an('array').with.length(0);
          //b.open_order.should.have.all.keys('exch_name');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('balances', function () {
      it('lists all account balance', function () {
        return coinigy.balances()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.notifications.should.be.an('array').with.length(0);
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('balance history', function() {
      it('should have keys', function () {
        return coinigy.balanceHistory({date: '2017-07-01'})
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('orders', function () {
      it('lists all orders', function () {
        return coinigy.orders()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
          b.notifications.should.be.an('array').with.length(0);
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('alerts', function() {
      it('should have keys', function () {
        return coinigy.alerts()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('user watch list', function() {
      it('should have keys', function () {
        return coinigy.userWatchList()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    describe('news feed', function() {
      it('should have keys', function () {
        return coinigy.newsFeed()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
          //console.log(err);
        });
      });
      sleep(1);
    });

    //end account data
  });

  //accout functions
  describe('Account Functions', function() {

    //TODO update user
    //TODO save preferences
    //TODO update tickers
    //TODO order types

    describe('refreshBalance', function () {
      it('refresh balance of specific auth_ids, in this case coinbase', function () {
        return coinigy.refreshBalance({auth_id: })
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    //TODO add alert
    //TODO delete alert
    //TODO add api key
    //TODO delete api key
    //TODO activate api key
    //TODO activate trading key
    //TODO add order
    //TODO cancel order
  });

  describe('Market Data', function() {
    describe('exchanges', function () {
      it('should get the exchanges', function () {
        return coinigy.exchanges()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('markets', function () {
      it('should get the markets', function () {
        return coinigy.markets()
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('data', function () {
      it('should get the data', function () {
        return coinigy.data({exchange_code: 'GDAX', exchange_market: 'BTC/USD', type: 'history'})
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });

    describe('ticker', function () {
      it('should get the ticker', function () {
        return coinigy.ticker({
          exchange_code: 'GDAX',
          exchange_market: 'BTC/USD'
        })
        .then(function (b) {
          b.should.have.all.keys('data', 'notifications');
        })
        .catch(function (err) {
          err.should.not.exist;
        });
      });
      sleep(1);
    });
  });

  //How do I test post with a specific body? IE: auth_ids = 1234 in post for Refresh Balance
  //http://docs.coinigy.apiary.io/#reference/account-functions/refresh-balance/refreshbalance
});
<|endoftext|>


<commit_before>Package.describe({
  name: "ground:db",
  version: "0.2.3",
  summary: "Ground Meteor.Collections offline",
  git: "https://github.com/GroundMeteor/db.git"
});

Package.onUse(function (api) {
  api.versionsFrom('1.0');

  api.use('meteor-platform', ['client', 'server']);

  api.use([
    'meteor',
    'underscore',
    'minimongo',
    'ejson',
    'ground:util@0.1.7',
    'ground:servertime@0.0.3',
    //'ground:minimax@1.0.1', // Its implied by ground:util
    'ground:localstorage@0.1.7',
    'raix:eventemitter@0.1.1',
    'raix:stubfence@1.0.1',
    'raix:onetimeout@1.0.3'
  ], ['client', 'server']);

  // Make sure any storage adapters are loaded first
  // api.use([
  //   'ground:localstorage'
  // ], 'client', { weak: true });

  api.export('Ground');
  api.export('GroundDB');

  api.use(['tracker'], 'client');

  //api.use([], 'server');
  //api.use(['localstorage', 'ejson'], 'client');
  api.addFiles([
    'groundDB.client.js',
    'wrap.collection.js',
    'wrap.eventemitter.js',
    'wrap.proto.eventemitter.js',
    ], 'client');
  api.addFiles('groundDB.server.js', 'server');
});

Package.onTest(function (api) {
  api.use('ground:db', ['client']);
  api.use('test-helpers', 'client');
  api.use(['tinytest', 'underscore', 'ejson', 'ordered-dict',
           'random', 'tracker']);

  api.addFiles('groundDB.client.tests.js', 'client');
  api.addFiles('groundDB.server.tests.js', 'server');
});
<commit_msg>Bump to version 0.2.4<commit_after>Package.describe({
  name: "ground:db",
  version: "0.2.4",
  summary: "Ground Meteor.Collections offline",
  git: "https://github.com/GroundMeteor/db.git"
});

Package.onUse(function (api) {
  api.versionsFrom('1.0');

  api.use('meteor-platform', ['client', 'server']);

  api.use([
    'meteor',
    'underscore',
    'minimongo',
    'ejson',
    'ground:util@0.1.7',
    'ground:servertime@0.0.3',
    //'ground:minimax@1.0.1', // Its implied by ground:util
    'ground:localstorage@0.1.7',
    'raix:eventemitter@0.1.1',
    'raix:stubfence@1.0.1',
    'raix:onetimeout@1.0.3'
  ], ['client', 'server']);

  // Make sure any storage adapters are loaded first
  // api.use([
  //   'ground:localstorage'
  // ], 'client', { weak: true });

  api.export('Ground');
  api.export('GroundDB');

  api.use(['tracker'], 'client');

  //api.use([], 'server');
  //api.use(['localstorage', 'ejson'], 'client');
  api.addFiles([
    'groundDB.client.js',
    'wrap.collection.js',
    'wrap.eventemitter.js',
    'wrap.proto.eventemitter.js',
    ], 'client');
  api.addFiles('groundDB.server.js', 'server');
});

Package.onTest(function (api) {
  api.use('ground:db', ['client']);
  api.use('test-helpers', 'client');
  api.use(['tinytest', 'underscore', 'ejson', 'ordered-dict',
           'random', 'tracker']);

  api.addFiles('groundDB.client.tests.js', 'client');
  api.addFiles('groundDB.server.tests.js', 'server');
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'd4nyll:odometeor',
  summary: 'A wrapper for odometer by HupSpot',
  version: '0.2.1',
  git: 'https://github.com/d4nyll/odometeor.git'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0.2.1');
  api.use(['templating'], 'client');
  api.addFiles('d4nyll:odometeor.html', 'client');
  api.addFiles('lib/odometer.js', 'client');
  api.addFiles('lib/themes/odometer-theme-car.css', 'client');
  api.addFiles('lib/themes/odometer-theme-default.css', 'client');
  api.addFiles('lib/themes/odometer-theme-digital.css', 'client');
  api.addFiles('lib/themes/odometer-theme-minimal.css', 'client');
  api.addFiles('lib/themes/odometer-theme-plaza.css', 'client');
  api.addFiles('lib/themes/odometer-theme-slot-machine.css', 'client');
  api.addFiles('lib/themes/odometer-theme-train-station.css', 'client');
  api.addFiles('d4nyll:odometeor.js', 'client');
  api.export('Odometeor', 'client');
});
<commit_msg>Fix typo<commit_after>Package.describe({
  name: 'd4nyll:odometeor',
  summary: 'A wrapper for odometer by HubSpot',
  version: '0.2.1',
  git: 'https://github.com/d4nyll/odometeor.git'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0.2.1');
  api.use(['templating'], 'client');
  api.addFiles('d4nyll:odometeor.html', 'client');
  api.addFiles('lib/odometer.js', 'client');
  api.addFiles('lib/themes/odometer-theme-car.css', 'client');
  api.addFiles('lib/themes/odometer-theme-default.css', 'client');
  api.addFiles('lib/themes/odometer-theme-digital.css', 'client');
  api.addFiles('lib/themes/odometer-theme-minimal.css', 'client');
  api.addFiles('lib/themes/odometer-theme-plaza.css', 'client');
  api.addFiles('lib/themes/odometer-theme-slot-machine.css', 'client');
  api.addFiles('lib/themes/odometer-theme-train-station.css', 'client');
  api.addFiles('d4nyll:odometeor.js', 'client');
  api.export('Odometeor', 'client');
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'jss:meteor-google-prediction',
  version: '0.2.0',
  summary: 'Google Prediction API v1.6 client',
  git: 'https://github.com/JSSolutions/meteor-google-prediction'
});

Package.onUse(function (api) {
  api.versionsFrom('1.1.0.2');
  api.addFiles('connector.js', 'server');
  api.export('GooglePrediction', 'server');
});

Npm.depends({
  "node-google-prediction": "0.0.4"
});<commit_msg>Updated version<commit_after>Package.describe({
  name: 'jss:meteor-google-prediction',
  version: '0.2.1',
  summary: 'Google Prediction API v1.6 client',
  git: 'https://github.com/JSSolutions/meteor-google-prediction'
});

Package.onUse(function (api) {
  api.versionsFrom('1.1.0.2');
  api.addFiles('connector.js', 'server');
  api.export('GooglePrediction', 'server');
});

Npm.depends({
  "node-google-prediction": "0.0.4"
});<|endoftext|>