Browse files

Release 0.5.3

  • Loading branch information...
1 parent 64fc4f8 commit eb8b1c271090ab7715dc85888ada9d89800a18b7 @gabrieleds gabrieleds committed Jul 2, 2012
Showing with 49 additions and 30 deletions.
  1. +1 −5 Makefile
  2. +19 −8 bike.js
  3. +1 −1 bike.min.js
  4. +7 −6 docs/bike.json
  5. +1 −1 docs/bike.md
  6. +1 −1 package.json
  7. +19 −8 runtime.js
View
6 Makefile
@@ -6,7 +6,7 @@ BROWSERBUILD = $(shell find node_modules -name "browserbuild" -type f)
BROWSERBUILD_FLAGS =-b lib/ -g bike -m bike.js
REPORTER = dot
-all: clean runtime.js bike.min.js test docs copy-to-repo
+all: clean runtime.js bike.min.js test docs
clean:
@rm -rf docs
@@ -32,8 +32,4 @@ docs:
@mkdir -p docs/bike
@node ./support/docs
-copy-to-repo:
- @cp bike.js ../../repository/behere/wrap-klass/debug/wrap-klass.debug.js
- @cp bike.min.js ../../repository/behere/wrap-klass/min/wrap-klass.min.js
-
.PHONY: clean test docs
View
27 bike.js
@@ -74,7 +74,7 @@ var Bike = exports = module.exports = function Bike(){
* @api public
*/
-Bike.version = '0.5.1';
+Bike.version = '0.5.3';
/**
* Delimiter used among namespaces.
@@ -127,13 +127,17 @@ Bike.base = require('./bike/base');;
* @api public
*/
-Bike.attach = function(target){
+Bike.attach = Bike.extend = function(target, namespaces){
if(target){
target.define = Bike.define;
target.create = Bike.create;
target.namespace = Bike.namespace;
}
+ if(namespaces){
+ Bike.namespace(namespaces);
+ }
+
return Bike;
};
@@ -457,13 +461,20 @@ require.register("bike/namespace.js", function(module, exports, require){
*/
var Namespace = function Namespace(name, value){
- if(!value && name){
- value = Namespace.get(name);
- return value ? value.target : null;
- }else if(value && name){
- return Namespace.set.apply(this, arguments);
+ if(_.isString(name)){
+ //single
+ if(!value && name){
+ value = Namespace.get(name);
+ return value ? value.target : null;
+ }else if(value && name){
+ return Namespace.set.apply(this, arguments);
+ }
+ }else{
+ //multiple
+ for(var i in name){
+ Namespace(i, name[i]);
+ }
}
-
return Namespace.items;
};
View
2 bike.min.js
@@ -1 +1 @@
-(function(){function e(t){var n=e.resolve(t),r=e.modules[n];if(!r)throw new Error('failed to require "'+t+'"');return r.exports||(r.exports={},r.call(r.exports,r,r.exports,e.relative(n))),r.exports}e.modules={},e.resolve=function(t){var n=t,r=t+".js",i=t+"/index.js";return e.modules[r]&&r||e.modules[i]&&i||n},e.register=function(t,n){e.modules[t]=n},e.relative=function(t){return function(n){if("."!=n.charAt(0))return e(n);var r=t.split("/"),i=n.split("/");r.pop();for(var s=0;s<i.length;s++){var o=i[s];".."==o?r.pop():"."!=o&&r.push(o)}return e(r.join("/"))}},e.register("bike.js",function(e,t,n){var r=t=e.exports=function i(){return i.attach.apply(i,arguments)};r.version="0.5.1",r.delimiter=".",r.namespace=n("./bike/namespace"),r.cache=n("./bike/cache"),r.base=n("./bike/base"),r.attach=function(e){return e&&(e.define=r.define,e.create=r.create,e.namespace=r.namespace),r},r.define=function(e,t,n,i){var s=null;return _.isBoolean(t)||(i=n,n=t,t=!1),t?s=n:(n&&n.extend?(s=r.cache.get(n.extend),delete n.extend):s=r.base,n&&(s=r.base.extend(n,s)),n&&n.mixins&&(n.mixins.forEach(function(e){e=r.cache.get(e),s=r.base.mixin(e,s)}),delete n.mixins)),r.cache.set(e,s),i&&i.apply(s,[e,n]),s},r.create=function(e,t,n,i){var s=r.cache.get(e),o=!1;_.isBoolean(t)||(i=n,n=t,t=!1);if(!t){if(s&&s.hasOwnProperty("singleton")&&s.singleton||n&&n.singleton)o=!0;n&&(s=r.base.extend(n,s)),o?_.has(r.cache.singletons,e)?s=r.cache.singletons[e]:(s=r.cache.singletons[e]=r.base.create.call(s,n||{}),i&&i.apply(s,[e,n])):(s=r.base.create.call(s,n||{}),i&&i.apply(s,[e,n]))}else s=new s;return s}}),e.register("bike/proto.js",function(e,t,n){typeof Object.create!="function"&&(Object.create=function(e){function t(){}if(arguments.length>1)throw new Error("Object.create implementation only accepts the first parameter.");return t.prototype=e,new t}),typeof Object.getPrototypeOf!="function"&&(typeof "test".__proto__=="object"?Object.getPrototypeOf=function(e){return e.__proto__}:Object.getPrototypeOf=function(e){return e.constructor.prototype});var r=t=e.exports={create:function(){var e=Object.create(this),t=_.isString(e.__init)?e.__init:"init";return _.isFunction(e[t])&&e[t].apply(e,arguments),e},mixin:function(e,t){var n=t||this,r=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,i=Object.getPrototypeOf(n)||n.prototype,s;for(var o in e)s=n[o],n[o]=_.isFunction(e[o])&&_.isFunction(i[o])&&r.test(e[o])||_.isFunction(s)&&_.isFunction(e[o])?function(e,t,n){return function(){var r=this._super;this._super=_.isFunction(e)?e:i[t];var s=n.apply(this,arguments);return this._super=r,s}}(s,o,e[o]):e[o],(o==n.__init||o==e.__init)&&_.isFunction(n[o])&&(n[o]=n[o]);return n},extend:function(e,t){return this.mixin(e,Object.create(t||this))},proxy:function(e,t){var n=t||this;return function(){return n[e].apply(n,arguments)}}}}),e.register("bike/base.js",function(e,t,n){var r=n("./proto"),i=t=e.exports=r.extend({})}),e.register("bike/namespace.js",function(e,t,n){var r=function i(e,t){return!t&&e?(t=i.get(e),t?t.target:null):t&&e?i.set.apply(this,arguments):i.items};r.items=[],r.get=function(e){return _.find(r.items.sort(function(e,t){return t.name.length-e.name.length}),function(t){return e.indexOf(t.name)!=-1})},r.set=function(e,t){var n;return _.find(r.items,function(t){return t.name===e})?(n=r.get(e),n.target=t):n=r.items[r.items.push({name:e,target:t})-1],n},r.remove=function(e){return r.items=_.reject(r.items,function(t){return t.name==e})},r.clear=function(){return r.items=[]},t=e.exports=r}),e.register("bike/cache.js",function(e,t,n){var r=n("../bike"),i=n("./namespace"),s=function o(e,t){return!t&&e?(t=o.get(e),t):t&&e?o.set.apply(this,arguments):o.items};s.singletons={},s.items=window,s.get=function(e){if(!_.isString(e))return e;var t=s.items,n=null,i=e.split(r.delimiter),e=_.last(i);for(var o=0;o<i.length-1;o++)n=i[o],t[n]||s.require(i,0),t=t[n];return t[e]||s.require(i,1),t[e]?t[e].$bike:null},s.set=function(e,t){var n=s.items,i=null,o=e.split(r.delimiter),e=_.last(o);for(var u=0;u<o.length-1;u++)i=o[u],n[i]||(n[i]={}),n=n[i];return n[e]?(n[e].$name=e,n[e].$bike=t):n[e]={$name:e,$bike:t},n[e].$bike},s.remove=function(e){return s.items},s.clear=function(){return s.items={}},s.require=function(e,t){var s=null,o=null;_.isArray(e)?(s=e,e=e.join(r.delimiter)):s=e.split(r.delimiter),o=i.get(e);if(!o)return!1;var u;try{u=n(o.target+"/"+_.last(s,s.length-o.name.split(r.delimiter).length).join("/"))}catch(a){if(s.length<=2)u=n(e.replace(".","-"));else{u=[];for(var f=0;f<s.length;f++)f===0?u.push(s[f]):f===1?(u[0]+="-"+s[f],u.push("lib",s[f])):u.push(s[f]);u=n(u.join("/"))}}return u},t=e.exports=s}),window.bike=e("bike")})();
+(function(){function e(t){var n=e.resolve(t),r=e.modules[n];if(!r)throw new Error('failed to require "'+t+'"');return r.exports||(r.exports={},r.call(r.exports,r,r.exports,e.relative(n))),r.exports}e.modules={},e.resolve=function(t){var n=t,r=t+".js",i=t+"/index.js";return e.modules[r]&&r||e.modules[i]&&i||n},e.register=function(t,n){e.modules[t]=n},e.relative=function(t){return function(n){if("."!=n.charAt(0))return e(n);var r=t.split("/"),i=n.split("/");r.pop();for(var s=0;s<i.length;s++){var o=i[s];".."==o?r.pop():"."!=o&&r.push(o)}return e(r.join("/"))}},e.register("bike.js",function(e,t,n){var r=t=e.exports=function i(){return i.attach.apply(i,arguments)};r.version="0.5.3",r.delimiter=".",r.namespace=n("./bike/namespace"),r.cache=n("./bike/cache"),r.base=n("./bike/base"),r.attach=r.extend=function(e,t){return e&&(e.define=r.define,e.create=r.create,e.namespace=r.namespace),t&&r.namespace(t),r},r.define=function(e,t,n,i){var s=null;return _.isBoolean(t)||(i=n,n=t,t=!1),t?s=n:(n&&n.extend?(s=r.cache.get(n.extend),delete n.extend):s=r.base,n&&(s=r.base.extend(n,s)),n&&n.mixins&&(n.mixins.forEach(function(e){e=r.cache.get(e),s=r.base.mixin(e,s)}),delete n.mixins)),r.cache.set(e,s),i&&i.apply(s,[e,n]),s},r.create=function(e,t,n,i){var s=r.cache.get(e),o=!1;_.isBoolean(t)||(i=n,n=t,t=!1);if(!t){if(s&&s.hasOwnProperty("singleton")&&s.singleton||n&&n.singleton)o=!0;n&&(s=r.base.extend(n,s)),o?_.has(r.cache.singletons,e)?s=r.cache.singletons[e]:(s=r.cache.singletons[e]=r.base.create.call(s,n||{}),i&&i.apply(s,[e,n])):(s=r.base.create.call(s,n||{}),i&&i.apply(s,[e,n]))}else s=new s;return s}}),e.register("bike/proto.js",function(e,t,n){typeof Object.create!="function"&&(Object.create=function(e){function t(){}if(arguments.length>1)throw new Error("Object.create implementation only accepts the first parameter.");return t.prototype=e,new t}),typeof Object.getPrototypeOf!="function"&&(typeof "test".__proto__=="object"?Object.getPrototypeOf=function(e){return e.__proto__}:Object.getPrototypeOf=function(e){return e.constructor.prototype});var r=t=e.exports={create:function(){var e=Object.create(this),t=_.isString(e.__init)?e.__init:"init";return _.isFunction(e[t])&&e[t].apply(e,arguments),e},mixin:function(e,t){var n=t||this,r=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,i=Object.getPrototypeOf(n)||n.prototype,s;for(var o in e)s=n[o],n[o]=_.isFunction(e[o])&&_.isFunction(i[o])&&r.test(e[o])||_.isFunction(s)&&_.isFunction(e[o])?function(e,t,n){return function(){var r=this._super;this._super=_.isFunction(e)?e:i[t];var s=n.apply(this,arguments);return this._super=r,s}}(s,o,e[o]):e[o],(o==n.__init||o==e.__init)&&_.isFunction(n[o])&&(n[o]=n[o]);return n},extend:function(e,t){return this.mixin(e,Object.create(t||this))},proxy:function(e,t){var n=t||this;return function(){return n[e].apply(n,arguments)}}}}),e.register("bike/base.js",function(e,t,n){var r=n("./proto"),i=t=e.exports=r.extend({})}),e.register("bike/namespace.js",function(e,t,n){var r=function i(e,t){if(_.isString(e)){if(!t&&e)return t=i.get(e),t?t.target:null;if(t&&e)return i.set.apply(this,arguments)}else for(var n in e)i(n,e[n]);return i.items};r.items=[],r.get=function(e){return _.find(r.items.sort(function(e,t){return t.name.length-e.name.length}),function(t){return e.indexOf(t.name)!=-1})},r.set=function(e,t){var n;return _.find(r.items,function(t){return t.name===e})?(n=r.get(e),n.target=t):n=r.items[r.items.push({name:e,target:t})-1],n},r.remove=function(e){return r.items=_.reject(r.items,function(t){return t.name==e})},r.clear=function(){return r.items=[]},t=e.exports=r}),e.register("bike/cache.js",function(e,t,n){var r=n("../bike"),i=n("./namespace"),s=function o(e,t){return!t&&e?(t=o.get(e),t):t&&e?o.set.apply(this,arguments):o.items};s.singletons={},s.items=window,s.get=function(e){if(!_.isString(e))return e;var t=s.items,n=null,i=e.split(r.delimiter),e=_.last(i);for(var o=0;o<i.length-1;o++)n=i[o],t[n]||s.require(i,0),t=t[n];return t[e]||s.require(i,1),t[e]?t[e].$bike:null},s.set=function(e,t){var n=s.items,i=null,o=e.split(r.delimiter),e=_.last(o);for(var u=0;u<o.length-1;u++)i=o[u],n[i]||(n[i]={}),n=n[i];return n[e]?(n[e].$name=e,n[e].$bike=t):n[e]={$name:e,$bike:t},n[e].$bike},s.remove=function(e){return s.items},s.clear=function(){return s.items={}},s.require=function(e,t){var s=null,o=null;_.isArray(e)?(s=e,e=e.join(r.delimiter)):s=e.split(r.delimiter),o=i.get(e);if(!o)return!1;var u;try{u=n(o.target+"/"+_.last(s,s.length-o.name.split(r.delimiter).length).join("/"))}catch(a){if(s.length<=2)u=n(e.replace(".","-"));else{u=[];for(var f=0;f<s.length;f++)f===0?u.push(s[f]):f===1?(u[0]+="-"+s[f],u.push("lib",s[f])):u.push(s[f]);u=n(u.join("/"))}}return u},t=e.exports=s}),window.bike=e("bike")})();
View
13 docs/bike.json
@@ -55,12 +55,12 @@
},
"isPrivate": false,
"ignore": false,
- "code": "Bike.version = '0.5.1';",
+ "code": "Bike.version = '0.5.3';",
"ctx": {
"type": "property",
"receiver": "Bike",
"name": "version",
- "value": "'0.5.1'",
+ "value": "'0.5.3'",
"string": "Bike.version"
}
},
@@ -227,12 +227,13 @@
},
"isPrivate": false,
"ignore": false,
- "code": "Bike.attach = function(target){\n if(target){\n target.define = Bike.define;\n target.create = Bike.create;\n target.namespace = Bike.namespace;\n }\n \n return Bike;\n};",
+ "code": "Bike.attach = Bike.extend = function(target, namespaces){\n if(target){\n target.define = Bike.define;\n target.create = Bike.create;\n target.namespace = Bike.namespace;\n }\n \n if(namespaces){\n Bike.namespace(namespaces);\n }\n \n return Bike;\n};",
"ctx": {
- "type": "method",
+ "type": "property",
"receiver": "Bike",
"name": "attach",
- "string": "Bike.attach()"
+ "value": "Bike.extend = function(target, namespaces){",
+ "string": "Bike.attach"
}
},
{
@@ -587,7 +588,7 @@
},
"isPrivate": false,
"ignore": false,
- "code": "var Namespace = function Namespace(name, value){\n if(!value && name){\n value = Namespace.get(name);\n return value ? value.target : null;\n }else if(value && name){\n return Namespace.set.apply(this, arguments);\n }\n \n return Namespace.items;\n};",
+ "code": "var Namespace = function Namespace(name, value){\n if(_.isString(name)){\n //single\n if(!value && name){\n value = Namespace.get(name);\n return value ? value.target : null;\n }else if(value && name){\n return Namespace.set.apply(this, arguments);\n }\n }else{\n //multiple\n for(var i in name){\n Namespace(i, name[i]);\n }\n }\n return Namespace.items;\n};",
"ctx": {
"type": "function",
"name": "Namespace",
View
2 docs/bike.md
@@ -19,7 +19,7 @@
Cache manager reference.
-# Bike.attach()
+# Bike.attach
Attaches methods `define` and `create` on a given object.
View
2 package.json
@@ -5,7 +5,7 @@
},
"name": "bike",
"description": "Class System - define, create, extend, mixin, super()...",
- "version": "0.5.4",
+ "version": "0.5.3",
"repository": {
"type": "git",
"url": "git://github.com/behere/bike.git"
View
27 runtime.js
@@ -29,7 +29,7 @@ var Bike = exports = module.exports = function Bike(){
* @api public
*/
-Bike.version = '0.5.1';
+Bike.version = '0.5.3';
/**
* Delimiter used among namespaces.
@@ -82,13 +82,17 @@ Bike.base = require('./bike/base');;
* @api public
*/
-Bike.attach = function(target){
+Bike.attach = Bike.extend = function(target, namespaces){
if(target){
target.define = Bike.define;
target.create = Bike.create;
target.namespace = Bike.namespace;
}
+ if(namespaces){
+ Bike.namespace(namespaces);
+ }
+
return Bike;
};
@@ -418,13 +422,20 @@ var Base = exports = module.exports = Proto.extend({
*/
var Namespace = function Namespace(name, value){
- if(!value && name){
- value = Namespace.get(name);
- return value ? value.target : null;
- }else if(value && name){
- return Namespace.set.apply(this, arguments);
+ if(_.isString(name)){
+ //single
+ if(!value && name){
+ value = Namespace.get(name);
+ return value ? value.target : null;
+ }else if(value && name){
+ return Namespace.set.apply(this, arguments);
+ }
+ }else{
+ //multiple
+ for(var i in name){
+ Namespace(i, name[i]);
+ }
}
-
return Namespace.items;
};

0 comments on commit eb8b1c2

Please sign in to comment.