Permalink
Browse files

Update Blueprint.

 * Change tests to use mocha
 * Add Gruntfile
 * Add Bower file
 * Fix hint
 * Update deps
 * Update API
  • Loading branch information...
1 parent aa3da5d commit d440290c9ab22d84ef4e1e0fa41fba080134f50c Couto committed Jun 18, 2013
Showing with 558 additions and 398 deletions.
  1. +2 −0 .gitignore
  2. +0 −4 .gitmodules
  3. +83 −0 .jshintrc
  4. +85 −0 Gruntfile.js
  5. +10 −0 bower.json
  6. +1 −0 dist/Blueprint.min.js
  7. +3 −0 index.js
  8. +15 −2 package.json
  9. +46 −33 src/Blueprint.js
  10. +0 −1 src/Blueprint.min.js
  11. +20 −0 test/config.js
  12. +83 −0 test/index.html
  13. +127 −0 test/instantiation.test.js
  14. +40 −0 test/parenting.test.js
  15. +43 −0 test/static.test.js
  16. +0 −174 tests/index.html
  17. +0 −183 tests/index_amd.html
  18. +0 −1 tests/vendor/qunit
View
@@ -2,3 +2,5 @@ _Store*
ehthumbs.db
Icon?
Thumbs.db
+node_modules
+coverage
View
@@ -1,4 +0,0 @@
-[submodule "tests/vendor/qunit"]
- path = tests/vendor/qunit
- url = git://github.com/jquery/qunit.git
-
View
@@ -0,0 +1,83 @@
+{
+
+
+ "bitwise" : true,
+ "camelcase" : true,
+ "curly" : true,
+ "eqeqeq" : true,
+ "forin" : true,
+ "immed" : true,
+ "indent" : 4,
+ "latedef" : true,
+ "newcap" : true,
+ "noarg" : true,
+ "noempty" : true,
+ "nonew" : true,
+ "plusplus" : true,
+ "quotmark" : "single",
+ "regexp" : true,
+ "undef" : true,
+ "unused" : true,
+ "strict" : false,
+ "trailing" : true,
+
+
+ "asi" : false,
+ "boss" : false,
+ "debug" : false,
+ "eqnull" : false,
+ "es5" : false,
+ "esnext" : false,
+ "evil" : false,
+ "expr" : false,
+ "funcscope" : false,
+ "globalstrict" : false,
+ "iterator" : false,
+ "lastsemic" : false,
+ "laxbreak" : false,
+ "laxcomma" : false,
+ "loopfunc" : false,
+ "multistr" : false,
+ "onecase" : false,
+ "proto" : false,
+ "regexdash" : false,
+ "scripturl" : false,
+ "smarttabs" : false,
+ "shadow" : false,
+ "sub" : false,
+ "supernew" : false,
+ "validthis" : false,
+
+
+ "browser" : true,
+ "couch" : false,
+ "devel" : false,
+ "dojo" : false,
+ "jquery" : false,
+ "mootools" : false,
+ "node" : true,
+ "nonstandard" : false,
+ "prototypejs" : false,
+ "rhino" : false,
+ "worker" : false,
+ "wsh" : false,
+
+
+ "nomen" : true,
+ "onevar" : true,
+ "passfail" : false,
+ "white" : true,
+
+ "predef" : [
+ "require",
+ "define",
+ "mocha",
+ "requirejs",
+ "describe",
+ "it",
+ "before",
+ "after",
+ "beforeAll",
+ "afterAll"
+ ]
+}
View
@@ -0,0 +1,85 @@
+module.exports = function (grunt) {
+ 'use strict';
+
+ grunt.initConfig({
+ files: {
+ src: ['index.js', 'src/**/*.js'],
+ test: ['test/**/*.js'],
+ all: ['README.md', 'index.js', 'src/**/*.js', 'test/**/*.js']
+ },
+
+ jshint: {
+ files: '<%= files.all %>',
+ options: {
+ jshintrc: '.jshintrc'
+ }
+ },
+
+ uglify: {
+ dist: {
+ files: {
+ 'dist/Blueprint.min.js': ['src/Blueprint.js']
+ }
+ }
+ },
+
+ clean: {
+ coverage: ['coverage']
+ },
+
+ cafemocha: {
+
+ unit: {
+ src: '<%= files.test %>',
+ options: {
+ ui: 'exports',
+ reporter: 'nyan'
+ }
+ },
+ coverage: {
+ src: '<%= files.test %>',
+ options: {
+ ui: 'exports',
+ reporter: 'html-cov',
+ coverage: {
+ output: 'coverage/index.html',
+ env: 'BLUEPRINT_COVERAGE'
+ }
+ }
+ }
+ },
+
+ coverage: {
+ test: {
+ files: { 'coverage': 'src' }
+ }
+ }
+ });
+
+ grunt.registerMultiTask('coverage', 'Create code coverage', function () {
+ var spawn = require('child_process').spawn,
+ done = this.async(),
+ coverage = spawn('jscoverage', [this.files[0].src, this.files[0].dest]),
+ error;
+
+ coverage.stdout.on('data', function (data) {
+ console.log(data.toString());
+ });
+
+ coverage.stderr.on('data', function (data) {
+ error = new Error(data.toString());
+ });
+
+ coverage.on('close', function (code) { done(error); });
+ });
+
+ // Load Grunt Tasks
+ Object.keys(require('./package.json').devDependencies).forEach(function (key) {
+ return (/^grunt-/).test(key) && grunt.loadNpmTasks(key);
+ });
+
+ grunt.registerTask('default', ['jshint', 'cafemocha:unit']);
+ grunt.registerTask('cov', ['clean:coverage', 'coverage:test', 'cafemocha:coverage']);
+ grunt.registerTask('dist', ['default', 'uglify']);
+
+};
View
@@ -0,0 +1,10 @@
+{
+ "name": "Blueprint",
+ "version": "0.0.2",
+ "main": "dist/Blueprint.min.js",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "components"
+ ]
+}
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,3 @@
+module.exports = (process.env.BLUEPRINT_COVERAGE) ?
+ require('./coverage/Blueprint.js') :
+ require('./src/Blueprint.js');
View
@@ -4,7 +4,11 @@
"description": "A simple Sugar for Prototypal Inheritance",
"version": "0.0.3",
"homepage": "http://github.com/Couto/Blueprint",
- "keywords": ["prototypal", "sugar", "blueprint"],
+ "keywords": [
+ "prototypal",
+ "sugar",
+ "blueprint"
+ ],
"repository": {
"type": "git",
"url": "git://github.com/Couto/Blueprint.git"
@@ -14,5 +18,14 @@
"node": "*"
},
"dependencies": {},
- "devDependencies": {}
+ "devDependencies": {
+ "mocha": "~1.11.0",
+ "requirejs": "~2.1.6",
+ "expect.js": "~0.2.0",
+ "grunt": "~0.4.1",
+ "grunt-cafe-mocha": "~0.1.6",
+ "grunt-contrib-clean": "~0.4.1",
+ "grunt-contrib-jshint": "~0.6.0",
+ "grunt-contrib-uglify": "~0.2.2"
+ }
}
View
@@ -33,11 +33,37 @@
* @param {Object} methods Object
* @returns Function
*/
-(function(root) {
+(function (root) {
'use strict';
- var Blueprint = {
+ var toString = Object.prototype.toString,
+ slice = Array.prototype.slice,
+
+ /**
+ * Helper method to fix the context (equivalent to ES5 Function.bind)
+ *
+ * @public
+ * @param {Function} fn Function that will be binded to the new context
+ * @param {Object} context Context
+ * @returns {Function} function proxied to the new context
+ */
+ proxy = (function () {
+ if (Function.prototype.bind) {
+ return function (fn, context) {
+ return fn.bind(context);
+ };
+ } else {
+ return function (fn, context) {
+ var args = slice.call(arguments, 2);
+ return function () {
+ return fn.apply(context, args.concat(slice.call(arguments)));
+ };
+ };
+ }
+ }()),
+
+ Blueprint = {
/**
* Creates a new instance of the current Blueprint
* if an object is given as a parameter, it will also extend
@@ -81,49 +107,36 @@
}
return this;
},
-
/**
- * Helper method to fix the context (equivalent to ES5 Function.bind)
+ * Describe what this method does
*
* @public
- * @param {Function} fn Function that will be binded to the new context
- * @param {Object} context Context
- * @returns {Function} function proxied to the new context
+ * @param {String|Object|Array|Boolean|Number} paramName Describe this parameter
+ * @returns Describe what it returns
+ * @type String|Object|Array|Boolean|Number
*/
- proxy : function(fn, context) {
- var isType = Object.prototype.toString,
- slice = Array.prototype.slice,
- tmp, args, proxy;
-
- if (isType.call(context) === '[object String]') {
- tmp = fn[context];
- context = fn;
- fn = tmp;
- }
+ bind: function (methods) {
+ var methds = toString.call(methods) !== '[object Array]' ? [methods] : methods,
+ i = methds.length - 1;
- if (isType.call(fn) !== '[object Function]') {
- return undefined;
+ for (i; i >= 0; i -= 1) {
+ this[methds[i]] = proxy(this[methds[i]], this);
}
- args = slice.call(arguments, 2);
- proxy = function () {
- return fn.apply(context, args.concat(slice.call(arguments)));
- };
-
- return proxy;
+ return this;
}
};
/**
* Expose Blueprint to the Global context with support for AMD and Node Modules
*/
- if (typeof define === "function" && define.amd) {
- define("Blueprint", [], function () { return Blueprint; } );
- } else if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports) {
- module.exports = Blueprint;
- } else {
- root.Blueprint = Blueprint;
- }
+ if (typeof define === 'function' && define.amd) {
+ define('Blueprint', [], function () { return Blueprint; });
+ } else if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports) {
+ module.exports = Blueprint;
+ } else {
+ root.Blueprint = Blueprint;
+ }
-}(this));
+}(this));
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,20 @@
+require.config({
+ paths: {
+ 'mocha' : '../node_modules/mocha/mocha',
+ 'expect': '../node_modules/expect.js/expect',
+ 'Blueprint' : '../index.js'
+ },
+ shim: {
+ 'mocha': { exports : 'mocha' },
+ 'expect': { exports : 'expect' }
+ },
+ urlArgs: 'cache=' + (+new Date())
+});
+
+require([
+ 'mocha',
+ 'expect',
+ 'instantiation.test',
+ 'parenting.test',
+ 'static.test'
+], function (mocha) { mocha.run(); });
Oops, something went wrong.

0 comments on commit d440290

Please sign in to comment.