Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

removing c9 stuff

  • Loading branch information...
commit a77f2828a5d8c21419f3835900044235ba3b3e96 1 parent 93a5813
@aaronpowell authored
1  .c9revisions/lib/tbd.js.c9save
@@ -1 +0,0 @@
-{"ts":1343446476673,"silentsave":true,"restoring":false,"patch":[[{"diffs":[[1,"(function () {\n 'use strict';\n var hasOwnProp = Object.prototype.hasOwnProperty,\n tbd;\n\n function ValueBuilder(def, builder) {\n var value = def,\n self = this;\n = function () {\n if (typeof value === 'function') {\n return value();\n } else if (typeof value === 'object' && value) {\n if (value.constructor === Array) {\n return value.slice();\n }\n\n return tbd.from(value).make(1)[0];\n }\n return value;\n };\n\n this.use = function (data) {\n value = data;\n return self;\n };\n\n this.make = function (num) {\n return builder.make(num);\n };\n\n this.done = function () {\n return builder;\n };\n }\n\n function ObjectBuilder(schema) {\n var i, ctorArgs,\n props = {},\n self = this,\n source = schema;\n\n function parseSchema() {\n var i;\n for (i in schema) {\n if (!, i) ||, i)) continue;\n\n props[i] = {\n value: new ValueBuilder(schema[i], self)\n };\n } \n }\n\n if(typeof source !== 'function') {\n parseSchema();\n } else {\n this.constructWith = function() {\n ctorArgs = [];\n return self;\n };\n }\n\n this.make = function (num) {\n var o, j,\n ret = [];\n \n for (i = 0; i < num; i++) {\n o = {};\n if(typeof source === 'function') {\n if(ctorArgs) {\n schema = {};\n source.apply(schema, ctorArgs);\n } else {\n schema = new source();\n }\n parseSchema();\n o.constructor = source;\n }\n\n for (j in props) {\n o[j] = props[j];\n }\n ret.push(o);\n }\n\n return ret;\n };\n\n this.prop = function (propName) {\n if (!props[propName]) {\n props[propName] = {\n value: new ValueBuilder(null, self)\n };\n }\n\n return props[propName].value;\n };\n }\n\n tbd = this.tbd = {\n from: function (schema) {\n return new ObjectBuilder(schema);\n }\n };\n}).call(this);\n\n(function() {\n 'use strict';\n var utils = {};\n \n utils.random = function () {\n var args = [];\n \n return function () {\n var random = Math.random();\n \n return args[Math.floor(random * args.length)];\n };\n };\n \n utils.range = function (min, max) {\n return function () {\n var random = Math.random();\n var val = Math.floor(random * (max - min + 1) + min);\n if(min.constructor === Date || max === Date) {\n val = Math.floor(random * (max.getTime() - min.getTime()));\n return new Date(max.getTime() - val);\n } else {\n return val;\n }\n };\n };\n \n utils.sequential = function(start) {\n if (start.constructor === Number) {\n return function () {\n return start++;\n };\n } else if (start.constructor === String) {\n var letters = 'abcdefghijklmnopqrstuvwxyz'.split('');\n if (start.length === 1) {\n start = letters.indexOf(start);\n return function () {\n if (start === letters.length) {\n start = 0;\n }\n return letters[start++];\n }; \n } else {\n var index = -1;\n return function () {\n if (index === -1) {\n index++;\n return start;\n }\n return start + letters[index++];\n };\n }\n } else if (start.constructor === Date) {\n var dateType = arguments[1] || 'd',\n inc = 0;\n return function () {\n start = new Date(start.getFullYear(), start.getMonth(), start.getDate(), start.getHours(), start.getMinutes(), start.getSeconds(), start.getMilliseconds());\n switch(dateType) {\n case 'y':\n start.setFullYear(start.getFullYear() + inc);\n break;\n case 'M':\n start.setMonth(start.getMonth() + inc);\n break;\n case 'd':\n start.setDate(start.getDate() + inc);\n break;\n case 'h':\n start.setHours(start.getHours() + inc);\n break;\n case 'm':\n start.setMinutes(start.getMinutes() + inc);\n break;\n case 's':\n start.setSeconds(start.getSeconds() + inc);\n break;\n default:\n throw 'The value ' + dateType + ' is not an understood date part';\n }\n inc = inc || 1;\n return start;\n };\n } else {\n throw 'This type is not supported for sequential values at the moment';\n }\n };\n \n this.tbd.utils = utils;\n}).call(this);"]],"start1":0,"start2":0,"length1":0,"length2":5842}]],"length":5842}
1  .c9revisions/tests.js.c9save
@@ -1 +0,0 @@
-{"ts":1342738436115,"silentsave":true,"restoring":false,"patch":[[{"diffs":[[1,"var jasmine = require('jasmine-node');\nvar matcher = new RegExp(\"spec\\\\.(js|coffee)$\", 'i');\n\njasmine.executeSpecsInFolder(\n __dirname + '/tests',\n function(runner, log) { },\n true,\n true,\n false,\n false,\n matcher,\n {\n report: false,\n savePath : \"./reports/\",\n useDotNotation: true,\n consolidate: true\n }\n);\n\nif (process.argv.length === 3 && process.argv[2] === 'web') {\n var express = require('express'),\n fs = require('fs'),\n pub = __dirname + '/web/public',\n tests = __dirname + '/tests/',\n server;\n\n server = express.createServer();\n\n server.use(server.router);\n server.use(express.static(pub));\n server.set('view engine', 'jade');\n server.set('views', __dirname + '/web/views');\n\n server.get('/specs.js', function (req, res) {\n var files = fs.readdirSync(tests).filter(function (x) { return x.match(matcher); });\n var js = '';\n \n for (var i =0, il = files.length; i < il; i++) {\n js += fs.readFileSync(tests + files[i]);\n }\n res.send(js, { 'Content-Type': 'application/javascript' });\n });\n \n server.get('/tbd.js', function (req, res) {\n var tbd = fs.readFileSync(__dirname + '/lib/tbd.js');\n \n res.send(tbd, { 'Content-Type': 'application/javascript' });\n });\n\n server.get('/', function (req, res) {\n res.render('index');\n });\n\n console.log('We are up and running');\n\n server.listen(process.env.PORT || 2911);\n}"]],"start1":0,"start2":0,"length1":0,"length2":1526}]],"length":1526}
3  .c9revisions/tests/basic-api-spec.js.c9save
@@ -1,3 +0,0 @@
-{"ts":1342738436271,"silentsave":true,"restoring":false,"patch":[[{"diffs":[[1,"describe('tbd-builder', function() {\n var tbd = require('../lib/');\n \n beforeEach(function() {\n this.addMatchers({\n toBeInArray: function(array) {\n return ~array.indexOf(this.actual);\n },\n toBeInDateRange: function(min, max) {\n var actual = this.actual.getTime();\n return actual <= max.getTime() && actual >= min.getTime();\n },\n toBeInNumericalRange: function (min, max) {\n var actual = this.actual;\n return actual <= max && actual >= min;\n }\n });\n });\n \n it('should allow usage of undefined', function() {\n var amount = 10,\n data = tbd.from().make(amount);\n \n expect(data.length).toEqual(amount);\n });\n \n it('should return an empty set with no make amount', function() {\n var data = tbd.from().make();\n \n expect(data.length).toEqual(0);\n });\n \n it('should allow making from property builder', function() {\n var number = 10,\n data = tbd.from({ foo: 'bar' }).prop('foo').make(number),\n data2 = tbd.from({ foo: 'bar' }).make(number);\n \n expect(data.length).toEqual(number);\n expect(data.length).toEqual(data2.length);\n });\n \n it('should allow functions in the object literal', function () {\n var data = tbd.from({\n a: 1,\n b: function () { return 'hello'; },\n c: tbd.utils.range(1, 10),\n d: tbd.utils.random('a', 'b', 'c'),\n e: tbd.utils.sequential(1)\n }).make(1);\n \n expect(data.length).toEqual(1);\n expect(data[0].a).toEqual(1);\n expect(data[0].b).toEqual('hello');\n expect(data[0].c).toBeInNumericalRange(1, 10);\n expect(data[0].d).toBeInArray('a', 'b', 'c');\n expect(data[0].e).toEqual(1);\n });\n});"]],"start1":0,"start2":0,"length1":0,"length2":1927}]],"length":1927}
-{"ts":1342738524631,"patch":[[{"diffs":[[0,"on(array) {\n"],[1," debugger;\n"],[0," "]],"start1":162,"start2":162,"length1":24,"length2":50}]],"length":1953,"saved":false}
-{"ts":1342738601200,"patch":[[{"diffs":[[0,"unction("],[-1,"array"],[0,") {\n "]],"start1":157,"start2":157,"length1":21,"length2":16},{"diffs":[[0," "],[-1,"debugger"],[1,"var array = []"],[0,";\n "]],"start1":181,"start2":181,"length1":16,"length2":44}]],"length":1976,"saved":false}
2  .c9revisions/tests/until-sequential-spec.js.c9save
@@ -1,2 +0,0 @@
-{"ts":1342738670209,"silentsave":true,"restoring":false,"patch":[[{"diffs":[[1,"describe('tbd-util-sequantial', function() {\n var tbd = require('../lib/');\n \n it('should generate a sequential value for each record', function () {\n var data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(0))\n .make(2);\n \n expect(data[0].foo).toBe(0);\n expect(data[1].foo).toBe(1);\n });\n \n it('should handle letters', function () {\n var data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential('a'))\n .make(2);\n \n expect(data[0].foo).toBe('a');\n expect(data[1].foo).toBe('b');\n });\n \n it('should append a new letter to sequential words', function () {\n var data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential('hello'))\n .make(2);\n \n expect(data[0].foo).toBe('hello');\n expect(data[1].foo).toBe('helloa');\n });\n \n it('should not blow up when starting a sequence at the end of the char list', function () {\n var data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential('z'))\n .make(2);\n \n expect(data[0].foo).toBe('z');\n expect(data[1].foo).toBe('a');\n });\n \n it('should handle sequential dates', function () {\n var start = new Date(),\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start))\n .make(2);\n \n expect(data[0].foo).toEqual(start);\n expect(data[1].foo).not.toEqual(start);\n });\n \n it('should increment by year when specified', function () {\n var start = new Date(),\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start, 'y'))\n .make(2);\n \n expect(data[0].foo.getFullYear()).toEqual(start.getFullYear());\n expect(data[1].foo.getFullYear()).toEqual(start.getFullYear() + 1);\n });\n \n it('should increment by month when specified', function () {\n var start = new Date(),\n month = start.getMonth() == 11 ? 0 : start.getMonth + 1,\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start, 'M'))\n .make(2);\n \n expect(data[0].foo.getMonth()).toEqual(start.getMonth());\n expect(data[1].foo.getMonth()).toEqual(month);\n });\n \n it('should increment by day when specified', function () {\n var start = new Date(),\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start, 'd'))\n .make(2);\n \n expect(data[0].foo.getDate()).toEqual(start.getDate());\n expect(data[1].foo.getDate()).toEqual(start.getDate() + 1);\n });\n \n it('should increment by hour when specified', function () {\n var start = new Date(),\n hours = start.getHours() === 23 ? 0 : start.getHours() + 1,\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start, 'h'))\n .make(2);\n\n expect(data[0].foo.getHours()).toEqual(start.getHours());\n expect(data[1].foo.getHours()).toEqual(hours);\n });\n \n it('should increment by minutes when specified', function () {\n var start = new Date(),\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start, 'm'))\n .make(2);\n \n expect(data[0].foo.getMinutes()).toEqual(start.getMinutes());\n expect(data[1].foo.getMinutes()).toEqual(start.getMinutes() + 1);\n });\n \n it('should increment by seconds when specified', function () {\n var start = new Date(),\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start, 's'))\n .make(2);\n \n expect(data[0].foo.getSeconds()).toEqual(start.getSeconds());\n expect(data[1].foo.getSeconds()).toEqual(start.getSeconds() + 1);\n });\n \n it('should know that going past the end of a month rolls over to a new month', function () {\n var start = new Date(2011, 2, 1),\n data = tbd.from({})\n .prop('foo').use(tbd.utils.sequential(start, 'd'))\n .make(30);\n\n //just of note you have to +1 the month as it returns a 0-based month index\n expect(data[29].foo.getMonth() + 1).not.toEqual(2);\n expect(data[29].foo.getMonth() + 1).toEqual(3);\n });\n});"]],"start1":0,"start2":0,"length1":0,"length2":4672}]],"length":4672}
-{"contributors":[],"silentsave":false,"ts":1342738729116,"patch":[[{"diffs":[[0,"getMonth"],[1,"()"],[0," + 1,\n "]],"start1":2235,"start2":2235,"length1":16,"length2":18}]],"length":4674,"saved":false}
Please sign in to comment.
Something went wrong with that request. Please try again.