Skip to content

Commit

Permalink
test, node and grunt
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusmaso committed Aug 5, 2014
1 parent 998aab8 commit faeb2ea
Show file tree
Hide file tree
Showing 15 changed files with 206 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
npm-debug.log
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git*
src/
spec/
.travis.yml
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
before_install:
- npm install -g grunt-cli
52 changes: 52 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
version: '<%= pkg.version %>',
banner:
'// <%= pkg.name %>\n' +
'// -------------------\n' +
'// v<%= pkg.version %>\n' +
'//\n' +
'// Copyright (c) 2013-<%= grunt.template.today("yyyy") %> Mateus Maso\n' +
'// Distributed under MIT license\n' +
'//\n' +
'// <%= pkg.repository.url %>\n' +
'\n'
},
uglify: {
options: {
banner: '<%= meta.banner %>'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
concat: {
options: {
banner: '<%= meta.banner %>'
},
dist: {
src: ['src/**/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
mochaTest: {
test: {
options: {
reporter: 'spec',
mocha: require('mocha')
},
src: ['spec/**/*.js']
}
},
clean: ['dist']
});

grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('default', ['uglify', 'concat', 'mochaTest']);
};
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012-2014 Mateus Maso
Copyright (c) 2013-2014 Mateus Maso

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
underscore.catenate
===================

This library is an extension for Underscore which allows chaining functions into a single method that executes them in sequence.

## Features
Expand All @@ -11,6 +10,13 @@ This library is an extension for Underscore which allows chaining functions into

* underscore.js (>= 1.5)

## Node

```javascript
var _ = require('underscore');
_.mixin(require('underscore.catenate'));
```

## Examples

```javascript
Expand Down
43 changes: 43 additions & 0 deletions dist/underscore.catenate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// underscore.catenate
// -------------------
// v0.1.0
//
// Copyright (c) 2013-2014 Mateus Maso
// Distributed under MIT license
//
// http://github.com/mateusmaso/underscore.catenate

(function(root, factory) {

if (typeof exports !== 'undefined') {
var _ = require('underscore');
if (typeof module !== 'undefined' && module.exports)
module.exports = factory(_);
exports = factory(_);
} else {
root._.mixin(factory(root._));
}

}(this, function(_) {

return {
catenate: function() {
var methods = arguments;

return function() {
var output;
var context = this;
var catenateArguments = arguments;

_.each(methods, function(method) {
if (method) {
output = method.apply(context, catenateArguments);
}
});

return output;
}
}
};

}));
10 changes: 10 additions & 0 deletions dist/underscore.catenate.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// underscore.catenate
// -------------------
// v0.1.0
//
// Copyright (c) 2013-2014 Mateus Maso
// Distributed under MIT license
//
// http://github.com/mateusmaso/underscore.catenate

!function(a,b){if("undefined"!=typeof exports){var c=require("underscore");"undefined"!=typeof module&&module.exports&&(module.exports=b(c)),exports=b(c)}else a._.mixin(b(a._))}(this,function(a){return{catenate:function(){var b=arguments;return function(){var c,d=this,e=arguments;return a.each(b,function(a){a&&(c=a.apply(d,e))}),c}}}});
19 changes: 0 additions & 19 deletions lib/underscore.catenate.js

This file was deleted.

Empty file removed lib/underscore.catenate.min.js
Empty file.
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "underscore.catenate",
"description": "Underscore helper for merging functions in the same context",
"version": "0.1.0",
"author": "mateusmaso",
"keywords": ["underscore", "javascript", "catenate"],
"devDependencies": {
"chai": "*",
"mocha": "*",
"underscore": "~1.5.0",
"grunt": "~0.4.5",
"grunt-mocha-test": "~0.11.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-uglify": "~0.5.0"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/mateusmaso/underscore.catenate/blob/master/LICENSE.txt"
}],
"repository": {
"type" : "git",
"url": "http://github.com/mateusmaso/underscore.catenate"
},
"dependencies": {
"underscore": "~1.5.0"
},
"scripts": {
"test": "grunt mochaTest"
},
"main": "dist/underscore.catenate.js"
}
Empty file removed script/build.txt
Empty file.
Empty file removed script/test.txt
Empty file.
17 changes: 17 additions & 0 deletions spec/underscore.catenate.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var chai = require("chai");
var _ = require("underscore");
_.mixin(require('../src/underscore.catenate'));

describe("underscore.catenate", function() {
it("should catenate methods", function() {
var value = "";

var fooBar = _.catenate(function() {
return value += "foo";
}, function() {
return value += "Bar";
});

chai.expect(fooBar()).to.equal("fooBar");
});
});
34 changes: 34 additions & 0 deletions src/underscore.catenate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function(root, factory) {

if (typeof exports !== 'undefined') {
var _ = require('underscore');
if (typeof module !== 'undefined' && module.exports)
module.exports = factory(_);
exports = factory(_);
} else {
root._.mixin(factory(root._));
}

}(this, function(_) {

return {
catenate: function() {
var methods = arguments;

return function() {
var output;
var context = this;
var catenateArguments = arguments;

_.each(methods, function(method) {
if (method) {
output = method.apply(context, catenateArguments);
}
});

return output;
}
}
};

}));

0 comments on commit faeb2ea

Please sign in to comment.