Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
code coverage & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skenqbx committed Sep 25, 2012
1 parent eebc9d4 commit 8c19861
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,2 +1,5 @@
node_modules
npm-debug.log
coverage.html
lib-cov
node-jscoverage
3 changes: 3 additions & 0 deletions .jshintignore
@@ -0,0 +1,3 @@
node_modules
lib-cov
node-jscoverage
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
(The MIT License)

Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
31 changes: 27 additions & 4 deletions Makefile
Expand Up @@ -2,14 +2,37 @@
# node-caster Makefile
# @author skenqbx@gmail.com (Malte-Thorben Bruns)
#
REPORTER ?= spec
REPORTER ?= list

all: jshint test
@

jshint:
@node_modules/.bin/jshint lib/ index.js
@node_modules/.bin/jshint ./

test:
@node_modules/.bin/mocha --reporter $(REPORTER) test/*.js
@node_modules/.bin/mocha -R ${REPORTER}

.PHONY: jshint test
test-cov: lib-cov
@CASTER_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html

lib-cov:
@rm -rf lib-cov/
@./node-jscoverage/jscoverage lib lib-cov

install: node_modules node-jscoverage
@

node-jscoverage:
@git clone git://github.com/visionmedia/node-jscoverage.git
@cd node-jscoverage/ && ./configure && make

node_modules:
@npm install

clean:
@rm -rf node-jscoverage/
@rm -rf node_modules/
@rm -rf lib-cov/

.PHONY: jshint test lib-cov
34 changes: 34 additions & 0 deletions README.markdown
Expand Up @@ -263,3 +263,37 @@ Emitted when a remote node _disappeared_.
`function(remote)`

`remote` is the object just removed from [node.nodes](#nodenodes).

## tests
```
make install
make jshint
make test
make test-cov
```

## license
```
(The MIT License)
Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
8 changes: 4 additions & 4 deletions index.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,8 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';

module.exports = require('./lib');
module.exports = process.env.CASTER_COV ?
require('./lib-cov') :
require('./lib');
4 changes: 1 addition & 3 deletions lib/caster.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,6 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';

/* load node modules */
Expand Down
4 changes: 1 addition & 3 deletions lib/index.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,6 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';

/* load modules */
Expand Down
10 changes: 5 additions & 5 deletions lib/middleware/crypto.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,6 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';

/* load node modules */
Expand All @@ -35,9 +33,10 @@ function cryptoMiddleware(opt_options) {
var algorithm = opt_options.algorithm || 'aes256';

function tx(message, next) {
var msg;
try {
var cipher = crypto.createCipher(algorithm, key);
var msg = cipher.update(message.toString('binary'), 'binary', 'binary');
msg = cipher.update(message.toString('binary'), 'binary', 'binary');
msg += cipher.final('binary');
} catch (err) {
return next(err, null);
Expand All @@ -46,9 +45,10 @@ function cryptoMiddleware(opt_options) {
}

function rx(message, remote, next) {
var msg;
try {
var decipher = crypto.createDecipher(algorithm, key);
var msg = decipher.update(message.toString('binary'), 'binary', 'binary');
msg = decipher.update(message.toString('binary'), 'binary', 'binary');
msg += decipher.final('binary');
} catch (err) {
return next(err, null);
Expand Down
4 changes: 1 addition & 3 deletions lib/middleware/hash.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,6 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';

/* load node modules */
Expand Down
4 changes: 1 addition & 3 deletions lib/middleware/index.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,6 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';

/* export modules */
Expand Down
4 changes: 1 addition & 3 deletions lib/middleware/json.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,6 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';


Expand Down
4 changes: 1 addition & 3 deletions lib/node.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,8 +18,6 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* enable ECMA-262 strict mode */
'use strict';

/* load node modules */
Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts
@@ -1,3 +1,2 @@
--ui bdd
--timeout 2000
--verbose
8 changes: 5 additions & 3 deletions test/test-caster.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,12 +18,14 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
/*global describe it afterEach after*/

describe('Caster', function() {
var caster = require('../lib');
var caster = require('../');

var options = {
port: 43214
port: 43215
};

var socketA = caster.create(options);
Expand Down
6 changes: 4 additions & 2 deletions test/test-node.js
@@ -1,4 +1,4 @@
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@googlemail.com>
// Copyright (c) 2012 Malte-Thorben Bruns <skenqbx@gmail.com>

// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
Expand All @@ -18,9 +18,11 @@
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
/*global describe it afterEach after*/

describe('Node', function() {
var caster = require('../lib');
var caster = require('../');

var options = {
port: 43214
Expand Down

0 comments on commit 8c19861

Please sign in to comment.