Initial commit

This commit is contained in:
deadprogram 2013-10-17 23:55:48 -07:00
commit 543123040c
10 changed files with 359 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/node_modules/
npm-debug.log

14
.jshintrc Normal file
View File

@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"node": true
}

4
.travis.yml Normal file
View File

@ -0,0 +1,4 @@
language: node_js
node_js:
- '0.10'
- '0.8'

157
Gruntfile.js Normal file
View File

@ -0,0 +1,157 @@
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(function(contrib) {
grunt.log.ok([contrib + " is loaded"]);
grunt.loadNpmTasks(contrib);
});
var config = {
dist: 'dist',
src: 'src',
distTest: 'test/dist',
srcTest: 'test/src'
};
// Project configuration.
grunt.initConfig({
config: config,
clean: {
dist: {
files: [
{
dot: true,
src: [
'<%= config.dist %>/*',
'<%= config.distTest %>/*',
'!<%= config.dist %>/.git*'
]
}
]
},
},
coffee: {
dist: {
files: [{
expand: true,
cwd: '<%= config.src %>',
src: '{,*/}*.coffee',
dest: '<%= config.dist %>',
ext: '.js'
}]
},
test: {
files: [{
expand: true,
cwd: '<%= config.srcTest %>',
src: '{,*/}*.spec.coffee',
dest: '<%= config.distTest %>',
ext: '.spec.js'
}]
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
dist: {
files: '<%= config.src %>/*',
tasks: ['coffee:dist', 'simplemocha:backend']
},
test: {
files: '<%= config.srcTest %>/specs/*',
tasks: ['coffee:test', 'simplemocha:backend']
}
},
simplemocha: {
options: {
globals: [
'sinon',
'chai',
'should',
'expect',
'assert',
'AssertionError',
],
timeout: 3000,
ignoreLeaks: false,
// grep: '*.spec',
ui: 'bdd',
reporter: 'spec'
},
backend: {
src: [
// add chai and sinon globally
'test/support/globals.js',
// tests
'test/dist/**/*.spec.js',
],
},
},
});
grunt.registerTask('coverageBackend', 'Test backend files as well as code coverage.', function () {
var done = this.async();
var path = './test/support/runner.js';
var options = {
cmd: 'istanbul',
grunt: false,
args: [
'cover',
'--default-excludes',
'-x', 'app/**',
'--report', 'lcov',
'--dir', './coverage/backend',
path
],
opts: {
// preserve colors for stdout in terminal
stdio: 'inherit',
},
};
function doneFunction(error, result) {
if (result && result.stderr) {
process.stderr.write(result.stderr);
}
if (result && result.stdout) {
grunt.log.writeln(result.stdout);
}
// abort tasks in queue if there's an error
done(error);
}
grunt.util.spawn(options, doneFunction);
});
// Default task.
grunt.registerTask('default', ['coffee', 'jshint']);
grunt.registerTask('test', [
'clean',
'coffee',
'simplemocha:backend',
]);
grunt.registerTask('coverage', [
'clean',
'coffee',
'coverageBackend'
])
};

31
README.md Normal file
View File

@ -0,0 +1,31 @@
# cylon [![Build Status](https://secure.travis-ci.org/deadprogram/cylon.png?branch=master)](http://travis-ci.org/deadprogram/cylon)
A small robotics framework based on nactor
## Getting Started
Install the module with: `npm install cylon`
```javascript
var cylon = require('cylon');
cylon.awesome(); // "awesome"
```
```coffee-script
cylon = require 'cylon'
cylon.awesome() // "awesome"
```
## Documentation
_(Coming soon)_
## Examples
_(Coming soon)_
## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
## Release History
_(Nothing yet)_
## License
Copyright (c) 2013 Ron Evans. Licensed under the Apache 2.0 license.

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "cylon",
"version": "0.0.0",
"main": "lib/cylon.js",
"description": "A small robotics framework based on nactor",
"homepage": "cylonjs.com",
"bugs": "https://github.com/deadprogram/cylon/issues",
"author": {
"name": "Ron Evans",
"email": "",
"url": "http://hybridgroup.com"
},
"repository": {
"type": "git",
"url": "https://github.com/deadprogram/cylon"
},
"licenses": [
{
"type": "Apache 2.0"
}
],
"devDependencies": {
"matchdep": "~0.1.1",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-watch": "~0.5.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-simple-mocha": "~0.4.0",
"grunt-contrib-clean": "~0.5.0",
"sinon-chai": "~2.4.0",
"chai": "~1.7.2",
"mocha": "~1.12.1",
"sinon": "~1.7.3"
}
}

12
src/cylon.coffee Normal file
View File

@ -0,0 +1,12 @@
###
* cylon
* cylonjs.com
*
* Copyright (c) 2013 Ron Evans
* Licensed under the Apache 2.0 license.
###
'use strict';
exports.awesome = ->
'awesome'

View File

@ -0,0 +1,36 @@
'use strict';
cylon = source("cylon")
describe "basic tests", ->
it "standard async test", (done) ->
bool = false
bool.should.be.false
setTimeout ->
bool.should.be.false
bool = true
bool.should.be.true
150
setTimeout ->
bool.should.be.true
done()
300
it "standard sync test", ->
data = []
obj = id: 5, name: 'test'
data.should.be.empty
data.push obj
data.should.have.length 1
# soft equal
data[0].should.be.eql obj
# hard equal
data[0].should.be.equal obj
# Now on to a `real` test
it "cylon should be awesome", ->
cylon.should.have.keys 'awesome'
cylon.awesome.should.be.a 'function'
cylon.awesome().should.be.equal 'awesome'

44
test/support/globals.js Normal file
View File

@ -0,0 +1,44 @@
'use strict';
// allow production modules to expose internal
// functions and properties for testing
process.env.NODE_ENV = 'test';
var path = require('path');
var chai = require('chai');
var sinonChai = require('sinon-chai');
global.chai = chai;
global.should = chai.should();
global.expect = chai.expect;
global.assert = chai.assert;
global.AssertionError = chai.AssertionError;
global.sinon = require('sinon');
// can be used by test modules to require production modules,
// relative to the base path (where the Gruntfile.js also lives)
global.source = function (src) {
console.log('source loading: ' + src)
var resource = path.normalize('../../dist/' + src);
return require(resource);
};
// can be used when you expect a function to throw an error
global.err = function (fn, msg) {
try {
fn();
throw new chai.AssertionError({ message: 'Expected an error' });
} catch (err) {
if ('string' === typeof msg) {
chai.expect(err.message).to.equal(msg);
} else {
chai.expect(err.message).to.match(msg);
}
}
};
chai.use(sinonChai);
// if you want a detailed error stack output
// chai.Assertion.includeStack = true;

25
test/support/runner.js Normal file
View File

@ -0,0 +1,25 @@
'use strict';
require('./globals');
var grunt = require('grunt');
var Mocha = require('mocha');
var mocha = new Mocha({ reporter: 'spec', ui: 'bdd'});
function run(cb) {
var files = grunt.file.expand(__dirname + '/../dist/**/*.spec.js');
console.log(files)
files.forEach(function (file) {
mocha.addFile(file);
});
cb();
}
run(function (err) {
if (err) { throw err; }
mocha.run(function (failures) {
process.exit(failures);
});
});