From 1bd091cfa6530b32677cb8026e2bc44a9e7e8fd4 Mon Sep 17 00:00:00 2001 From: ajlopez Date: Sun, 21 Oct 2012 11:48:30 -0300 Subject: [PATCH] Initial commit --- .gitignore | 1 + .npmignore | 1 + README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 16 ++++++++++++++++ test.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 README.md create mode 100644 package.json create mode 100644 test.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08b2553 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..11f47ed --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +/samples diff --git a/README.md b/README.md new file mode 100644 index 0000000..5409a2e --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# Cellular + +Simple Cellular Automata processing in Javascript for browser and Node.js + +## Installation + +Via npm on Node: + +``` +npm install cellular +``` + + +## Usage + +Reference in your program: + +```js +var cellular = require('cellular'); +``` + +TBD + +## Development + +``` +git clone git://github.com/ajlopez/Cellular.git +cd Cellular +npm install +npm test +``` + +## Samples + +TBD + +## To do + +- Samples +- Distributed Sample +- Browser Sample + +## Contribution + +Feel free to [file issues](https://github.com/ajlopez/Cellular) and submit +[pull requests](https://github.com/ajlopez/Cellular/pulls) — contributions are +welcome. + +If you submit a pull request, please be sure to add or update corresponding +test cases, and ensure that `npm test` continues to pass. + +(Thanks to [JSON5](https://github.com/aseemk/json5) by [aseemk](https://github.com/aseemk). +This file is based on that project README.md). \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..f2d3dfa --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ "name": "cellular" +, "description": "Simple Cellular Automata processing in Javascript for browser and Node.js" +, "keywords": [ "cellular", "automata", "game of life", "nodejs", "javascript" ] +, "version": "0.0.1alpha" +, "author": "Angel 'Java' Lopez (http://www.ajlopez.com)" +, "repository": { "type": "git", "url": "git://github.com/ajlopez/Cellular.git" } +, "main": "./lib/cellular.js" +, "engines": { "node": ">= 0.6.0 && < 0.9.0" } +, "scripts": { + "test": "node ./test.js" + } +, "dependencies": { + } +, "devDependencies": { + } +} diff --git a/test.js b/test.js new file mode 100644 index 0000000..fd80fa6 --- /dev/null +++ b/test.js @@ -0,0 +1,54 @@ +#!/usr/bin/env node + +// Based on https://github.com/laverdet/node-fibers/blob/master/test.js + +var fs = require('fs'); +var spawn = require('child_process').spawn; +var path = require('path'); + +function runTest(test, cb) { + var proc = spawn(process.execPath, [path.join('test', test)], {env: {NODE_PATH: __dirname}}); + proc.stdout.setEncoding('utf8'); + proc.stderr.setEncoding('utf8'); + + var stdout = '', stderr = ''; + proc.stdout.on('data', function(data) { + stdout += data; + }); + proc.stderr.on('data', function(data) { + stderr += data; + }); + proc.stdin.end(); + + proc.on('exit', function(code) { + if ((stdout !== 'pass\n' && stdout !== '') || stderr !== '') { + return cb(new Error( + 'Test `'+ test+ '` failed.\n'+ + 'code: '+ code+ '\n'+ + 'stderr: '+ stderr+ '\n'+ + 'stdout: '+ stdout)); + } + console.log(test+ ': '+ 'pass'); + cb(); + }); +} + +var cb = function(err) { + if (err) { + console.error(String(err)); + process.exit(1); + } +}; +fs.readdirSync('./test').reverse().forEach(function(file) { + var stats = fs.lstatSync(path.join('./test',file)); + if (!stats.isFile()) + return; + + cb = new function(cb, file) { + return function(err) { + if (err) return cb(err); + runTest(file, cb); + }; + }(cb, file); +}); +cb();