diff --git a/README.md b/README.md index da98b18..f0d1736 100644 --- a/README.md +++ b/README.md @@ -41,23 +41,11 @@ While Marionette is not a dependency, if you're already using Marionette, your d ### Getting Geppetto -**Note about 0.7.0 Release Candidate**: +*Latest Stable Release: 0.7.0* -Geppetto recently introduced a dependency injection (DI) system for promoting even better loose-coupling. This feature is targeted for version 0.7.0. - -The docs are not quite up to date yet, and the API might undergo some minor changes. Version 0.7.0 is in "release candidate" stage, and will be released once the docs and API are finalized. If you would prefer to work with a fully-documented API, and don't need the DI, [please use 0.6.3](https://github.com/ModelN/backbone.geppetto/tree/0.6.3) for the time being. - -*Latest Stable Release: 0.6.3* - -* Minified: [backbone.geppetto.min.js](https://github.com/ModelN/backbone.geppetto/blob/0.6.3/dist/backbone.geppetto.min.js) -* Development (Uncompressed, Comments): [backbone.geppetto.js](https://raw.github.com/ModelN/backbone.geppetto/0.6.3/backbone.geppetto.js) -* Full Release (Tests, Examples): [0.6.3.zip](https://github.com/ModelN/backbone.geppetto/archive/0.6.3.zip). - -*Latest Dependency Injection Release Candidate: 0.7.0-rc5* - -* Minified: [backbone.geppetto.min.js](https://github.com/ModelN/backbone.geppetto/blob/0.7.0-rc5/dist/backbone.geppetto.min.js) -* Development (Uncompressed, Comments): [backbone.geppetto.js](https://raw.github.com/ModelN/backbone.geppetto/0.7.0-rc5/backbone.geppetto.js) -* Full Release (Tests, Examples): [0.6.3.zip](https://github.com/ModelN/backbone.geppetto/archive/0.7.0-rc5.zip). +* Minified: [backbone.geppetto.min.js](https://github.com/ModelN/backbone.geppetto/blob/0.7.0/dist/backbone.geppetto.min.js) +* Development (Uncompressed, Comments): [backbone.geppetto.js](https://raw.github.com/ModelN/backbone.geppetto/0.7.0/backbone.geppetto.js) +* Full Release (Tests, Examples): [0.7.0.zip](https://github.com/ModelN/backbone.geppetto/archive/0.7.0.zip). *Unreleased Edge Version (master)* @@ -659,6 +647,13 @@ To add your logo, please open an issue. Include a link to a hosted .png image o ## Version History +### 0.7.0 +*Released 29 Apr 2014* + +* Official release for DI features +* Fix bower config +* Happy 2-year Geppettiversary! + ### 0.7.0 RC5 *Released 18 Jan 2014* diff --git a/backbone.geppetto.js b/backbone.geppetto.js index 721d4d3..bcc4ea8 100755 --- a/backbone.geppetto.js +++ b/backbone.geppetto.js @@ -1,4 +1,4 @@ -// backbone.geppetto 0.7.0-rc5 +// backbone.geppetto 0.7.0 // // Copyright (C) 2013 Dave Cadwallader, Model N, Inc. // Distributed under the MIT License @@ -69,14 +69,12 @@ var context = this._context; - var WrappedConstructor = OriginalConstructor.extend({ + return OriginalConstructor.extend({ initialize: function() { context.resolver.resolve(this, wiring); OriginalConstructor.prototype.initialize.call(this, arguments); } }); - - return WrappedConstructor; }, createChildResolver: function() { @@ -166,7 +164,7 @@ var Geppetto = {}; - Geppetto.version = '0.7.0-rc5'; + Geppetto.version = '0.7.0'; Geppetto.EVENT_CONTEXT_SHUTDOWN = "Geppetto:contextShutdown"; @@ -322,7 +320,7 @@ Geppetto.Context.prototype.dispatchGlobally = function dispatchGlobally(eventName, eventData) { - _.each(contexts, function(context, contextId) { + _.each(contexts, function(context) { context.vent.trigger(eventName, eventData); }); }; diff --git a/bower.json b/bower.json index 413fcbf..072ddb8 100644 --- a/bower.json +++ b/bower.json @@ -1,26 +1,47 @@ { "name": "backbone.geppetto", - "version": "0.7.0-rc5", + "description": "Bring your Backbone applications to life with an event-driven Command framework.", + "homepage": "https://github.com/ModelN/backbone.geppetto", + "version": "0.7.0", "main": "backbone.geppetto.js", + "keywords": [ + "backbone", + "plugin", + "command", + "mvc" + ], + "author": { + "name": "Dave Cadwallader", + "email": "dcadwallader@gmail.com" + }, "ignore": [ "**/.*", "node_modules", - "components" + "components", + "examples", + "Gruntfile.js", + ".gitignore", + "travis.yml", + "beautify.json", + "documentup.min.js", + "index.html", + "version.json" ], - "dependencies": { + "devDependencies": { "jquery": "~2.0.3", - "backbone": "~1.1.0", - "underscore": "~1.5.1", "requirejs": "~2.1.9", "requirejs-text": "~2.0.10", "mocha": "~1.12.1", "chai": "~1.8.1", "sinon-chai": "~2.4.0", "blanket": "~1.1.5", - "sinon.js": "~1.7.3", "sinonjs": "~1.7.3", "marionette": "~1.4.1", "handlebars": "1.3.0", "jquery-mockjax": "1.5.3" + }, + "dependencies": { + "backbone": "~1.1.0", + "underscore": "~1.5.2" } } diff --git a/dist/backbone.geppetto.min.js b/dist/backbone.geppetto.min.js index 4af3f7f..1b8296b 100644 --- a/dist/backbone.geppetto.min.js +++ b/dist/backbone.geppetto.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["underscore","backbone"],a):a(_,Backbone)}(function(a,b){"use strict";if(!b)throw"Please include Backbone before Geppetto";var c="no mapping found for key: ",d={SINGLETON:"singleton",VIEW:"view",OTHER:"other"},e=function(a){this._mappings={},this._context=a,this.parent=void 0};e.prototype={_createAndSetupInstance:function(a,b){var c=new a;return this.resolve(c,b),c},_retrieveFromCacheOrCreate:function(a,b){var e;if(this._mappings.hasOwnProperty(a)){var f=this._mappings[a];b||f.type!==d.SINGLETON?f.type===d.VIEW?e=f.clazz:f.clazz&&(e=this._createAndSetupInstance(f.clazz,f.wiring)):(f.object||(f.object=this._createAndSetupInstance(f.clazz,f.wiring)),e=f.object)}else{if(!this.parent||!this.parent.hasWiring(a))throw new Error(c+a);e=this.parent._retrieveFromCacheOrCreate(a,b)}return e},_wrapConstructor:function(a,b){var c=this._context,d=a.extend({initialize:function(){c.resolver.resolve(this,b),a.prototype.initialize.call(this,arguments)}});return d},createChildResolver:function(){var a=new e(this._context);return a.parent=this,a},getObject:function(a){return this._retrieveFromCacheOrCreate(a,!1)},wireValue:function(a,b){return this._mappings[a]={clazz:null,object:b,type:d.SINGLETON},this},hasWiring:function(a){return this._mappings.hasOwnProperty(a)||!!this.parent&&this.parent.hasWiring(a)},wireClass:function(a,b,c){return this._mappings[a]={clazz:b,object:null,type:d.OTHER,wiring:c},this},wireView:function(a,b,c){return this._mappings[a]={clazz:this._wrapConstructor(b,c),object:null,type:d.VIEW},this},wireSingleton:function(a,b,c){var e=b.prototype.initialize?this._wrapConstructor(b,c):b;return this._mappings[a]={clazz:e,object:null,type:d.SINGLETON,wiring:c},this},instantiate:function(a){return this._retrieveFromCacheOrCreate(a,!0)},resolve:function(b,c){if(c=c||b.wiring){var d=Number(!a.isArray(c));a.each(c,function(a){b[arguments[d]]=this.getObject(a)},this)}return this.addPubSub(b),this},addPubSub:function(b){b.listen=a.bind(this._context.listen,this._context),b.dispatch=a.bind(this._context.dispatch,this._context)},release:function(a){return delete this._mappings[a],this},releaseAll:function(){return this._mappings={},this}};var f={};f.version="0.7.0-rc5",f.EVENT_CONTEXT_SHUTDOWN="Geppetto:contextShutdown",f.Resolver=e;var g={};f.Context=function(c){this.options=c||{},this.parentContext=this.options.parentContext,this.options.resolver?this.resolver=this.options.resolver:this.parentContext?this.resolver=this.parentContext.resolver.createChildResolver():this.resolver||(this.resolver=new e(this)),this.vent={},a.extend(this.vent,b.Events),a.isFunction(this.initialize)&&this.initialize.apply(this,arguments),this._contextId=a.uniqueId("Context"),g[this._contextId]=this;var d=this.wiring||this.options.wiring;d&&this._configureWirings(d)},f.bindContext=function(b){this.options=b||{};var c=this.options.view,d=null;"function"==typeof this.options.context?(d=new this.options.context(this.options),c.close||(c.close=function(){c.trigger("close"),c.remove()}),c.on("close",function(){c.off("close"),d.destroy()})):"object"==typeof this.options.context&&(d=this.options.context),d.resolver.resolve(c),a.each(c.contextEvents,function(b,e){a.isFunction(b)?d.listen(c,e,b):a.isString(b)&&d.listen(c,e,c[b])});var e;return c.wiring||(c.context=d,e=d),e};var h=function(a,b){var c,d;return a.hasOwnProperty("ctor")?(c=a.ctor,d=a.wiring):c=a,[b,c,d]};f.Context.prototype._configureWirings=function(b){a.each(b.singletons,function(a,b){this.wireSingleton.apply(this,h(a,b))},this),a.each(b.classes,function(a,b){this.wireClass.apply(this,h(a,b))},this),a.each(b.values,function(a,b){this.wireValue(b,a)},this),a.each(b.views,function(a,b){this.wireView.apply(this,h(a,b))},this),this.wireCommands(b.commands)};var i=function(b,c,d){if(!a.isObject(b)||!a.isFunction(b.listenTo)||!a.isFunction(b.stopListening))throw"Target for listen() must define a 'listenTo' and 'stopListening' function";if(!a.isString(c))throw"eventName must be a String";if(!a.isFunction(d))throw"callback must be a function"};f.Context.prototype.listen=function(a,b,c){return i(a,b,c),a.listenTo(this.vent,b,c,a)},f.Context.prototype.listenToOnce=function(a,b,c){return i(a,b,c),a.listenToOnce(this.vent,b,c,a)},f.Context.prototype.dispatch=function(b,c){if(!a.isUndefined(c)&&!a.isObject(c))throw"Event payload must be an object";c=c||{},c.eventName=b,this.vent.trigger(b,c)},f.Context.prototype.dispatchToParent=function(a,b){this.parentContext&&this.parentContext.vent.trigger(a,b)},f.Context.prototype.dispatchGlobally=function(b,c){a.each(g,function(a){a.vent.trigger(b,c)})},f.Context.prototype.wireCommand=function(b,c,d){var e=this;if(!a.isFunction(c))throw"Command must be constructable";this.vent.listenTo(this.vent,b,function(f){var g=new c;g.context=e,g.eventName=b,g.eventData=f,e.resolver.resolve(g,d),a.isFunction(g.execute)&&g.execute()},this)},f.Context.prototype.wireCommands=function(b){var c=this;a.each(b,function(b,d){a.isArray(b)?a.each(b,function(a){c.wireCommand(d,a)}):c.wireCommand(d,b)})},f.Context.prototype.wireView=function(a,b,c){return this.resolver.wireView(a,b,c),this},f.Context.prototype.wireSingleton=function(a,b,c){return this.resolver.wireSingleton(a,b,c),this},f.Context.prototype.wireValue=function(a,b){return this.resolver.wireValue(a,b),this},f.Context.prototype.wireClass=function(a,b,c){return this.resolver.wireClass(a,b,c),this},f.Context.prototype.hasWiring=function(a){return this.resolver.hasWiring(a)},f.Context.prototype.getObject=function(a){return this.resolver.getObject(a)},f.Context.prototype.instantiate=function(a){return this.resolver.instantiate(a)},f.Context.prototype.resolve=function(a,b){return this.resolver.resolve(a,b),this},f.Context.prototype.release=function(a){return this.resolver.release(a),this},f.Context.prototype.releaseAll=function(){return this.resolver.releaseAll(),this},f.Context.prototype.destroy=function(){this.vent.stopListening(),this.resolver.releaseAll(),delete g[this._contextId],this.dispatchToParent(f.EVENT_CONTEXT_SHUTDOWN)},f.Context.extend=b.View.extend;var j={contexts:g,countEvents:function(){var b=0;return a.each(g,function(c,d){g.hasOwnProperty(d)&&(b+=a.size(c.vent._events))}),b},countContexts:function(){var b=0;return a.each(g,function(a,c){g.hasOwnProperty(c)&&b++}),b}};return f.setDebug=function(a){return this.debug=a?j:void 0,this.debug},b.Geppetto=f,f}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["underscore","backbone"],a):a(_,Backbone)}(function(a,b){"use strict";if(!b)throw"Please include Backbone before Geppetto";var c="no mapping found for key: ",d={SINGLETON:"singleton",VIEW:"view",OTHER:"other"},e=function(a){this._mappings={},this._context=a,this.parent=void 0};e.prototype={_createAndSetupInstance:function(a,b){var c=new a;return this.resolve(c,b),c},_retrieveFromCacheOrCreate:function(a,b){var e;if(this._mappings.hasOwnProperty(a)){var f=this._mappings[a];b||f.type!==d.SINGLETON?f.type===d.VIEW?e=f.clazz:f.clazz&&(e=this._createAndSetupInstance(f.clazz,f.wiring)):(f.object||(f.object=this._createAndSetupInstance(f.clazz,f.wiring)),e=f.object)}else{if(!this.parent||!this.parent.hasWiring(a))throw new Error(c+a);e=this.parent._retrieveFromCacheOrCreate(a,b)}return e},_wrapConstructor:function(a,b){var c=this._context;return a.extend({initialize:function(){c.resolver.resolve(this,b),a.prototype.initialize.call(this,arguments)}})},createChildResolver:function(){var a=new e(this._context);return a.parent=this,a},getObject:function(a){return this._retrieveFromCacheOrCreate(a,!1)},wireValue:function(a,b){return this._mappings[a]={clazz:null,object:b,type:d.SINGLETON},this},hasWiring:function(a){return this._mappings.hasOwnProperty(a)||!!this.parent&&this.parent.hasWiring(a)},wireClass:function(a,b,c){return this._mappings[a]={clazz:b,object:null,type:d.OTHER,wiring:c},this},wireView:function(a,b,c){return this._mappings[a]={clazz:this._wrapConstructor(b,c),object:null,type:d.VIEW},this},wireSingleton:function(a,b,c){var e=b.prototype.initialize?this._wrapConstructor(b,c):b;return this._mappings[a]={clazz:e,object:null,type:d.SINGLETON,wiring:c},this},instantiate:function(a){return this._retrieveFromCacheOrCreate(a,!0)},resolve:function(b,c){if(c=c||b.wiring){var d=Number(!a.isArray(c));a.each(c,function(a){b[arguments[d]]=this.getObject(a)},this)}return this.addPubSub(b),this},addPubSub:function(b){b.listen=a.bind(this._context.listen,this._context),b.dispatch=a.bind(this._context.dispatch,this._context)},release:function(a){return delete this._mappings[a],this},releaseAll:function(){return this._mappings={},this}};var f={};f.version="0.7.0",f.EVENT_CONTEXT_SHUTDOWN="Geppetto:contextShutdown",f.Resolver=e;var g={};f.Context=function(c){this.options=c||{},this.parentContext=this.options.parentContext,this.options.resolver?this.resolver=this.options.resolver:this.parentContext?this.resolver=this.parentContext.resolver.createChildResolver():this.resolver||(this.resolver=new e(this)),this.vent={},a.extend(this.vent,b.Events),a.isFunction(this.initialize)&&this.initialize.apply(this,arguments),this._contextId=a.uniqueId("Context"),g[this._contextId]=this;var d=this.wiring||this.options.wiring;d&&this._configureWirings(d)},f.bindContext=function(b){this.options=b||{};var c=this.options.view,d=null;"function"==typeof this.options.context?(d=new this.options.context(this.options),c.close||(c.close=function(){c.trigger("close"),c.remove()}),c.on("close",function(){c.off("close"),d.destroy()})):"object"==typeof this.options.context&&(d=this.options.context),d.resolver.resolve(c),a.each(c.contextEvents,function(b,e){a.isFunction(b)?d.listen(c,e,b):a.isString(b)&&d.listen(c,e,c[b])});var e;return c.wiring||(c.context=d,e=d),e};var h=function(a,b){var c,d;return a.hasOwnProperty("ctor")?(c=a.ctor,d=a.wiring):c=a,[b,c,d]};f.Context.prototype._configureWirings=function(b){a.each(b.singletons,function(a,b){this.wireSingleton.apply(this,h(a,b))},this),a.each(b.classes,function(a,b){this.wireClass.apply(this,h(a,b))},this),a.each(b.values,function(a,b){this.wireValue(b,a)},this),a.each(b.views,function(a,b){this.wireView.apply(this,h(a,b))},this),this.wireCommands(b.commands)};var i=function(b,c,d){if(!a.isObject(b)||!a.isFunction(b.listenTo)||!a.isFunction(b.stopListening))throw"Target for listen() must define a 'listenTo' and 'stopListening' function";if(!a.isString(c))throw"eventName must be a String";if(!a.isFunction(d))throw"callback must be a function"};f.Context.prototype.listen=function(a,b,c){return i(a,b,c),a.listenTo(this.vent,b,c,a)},f.Context.prototype.listenToOnce=function(a,b,c){return i(a,b,c),a.listenToOnce(this.vent,b,c,a)},f.Context.prototype.dispatch=function(b,c){if(!a.isUndefined(c)&&!a.isObject(c))throw"Event payload must be an object";c=c||{},c.eventName=b,this.vent.trigger(b,c)},f.Context.prototype.dispatchToParent=function(a,b){this.parentContext&&this.parentContext.vent.trigger(a,b)},f.Context.prototype.dispatchGlobally=function(b,c){a.each(g,function(a){a.vent.trigger(b,c)})},f.Context.prototype.wireCommand=function(b,c,d){var e=this;if(!a.isFunction(c))throw"Command must be constructable";this.vent.listenTo(this.vent,b,function(f){var g=new c;g.context=e,g.eventName=b,g.eventData=f,e.resolver.resolve(g,d),a.isFunction(g.execute)&&g.execute()},this)},f.Context.prototype.wireCommands=function(b){var c=this;a.each(b,function(b,d){a.isArray(b)?a.each(b,function(a){c.wireCommand(d,a)}):c.wireCommand(d,b)})},f.Context.prototype.wireView=function(a,b,c){return this.resolver.wireView(a,b,c),this},f.Context.prototype.wireSingleton=function(a,b,c){return this.resolver.wireSingleton(a,b,c),this},f.Context.prototype.wireValue=function(a,b){return this.resolver.wireValue(a,b),this},f.Context.prototype.wireClass=function(a,b,c){return this.resolver.wireClass(a,b,c),this},f.Context.prototype.hasWiring=function(a){return this.resolver.hasWiring(a)},f.Context.prototype.getObject=function(a){return this.resolver.getObject(a)},f.Context.prototype.instantiate=function(a){return this.resolver.instantiate(a)},f.Context.prototype.resolve=function(a,b){return this.resolver.resolve(a,b),this},f.Context.prototype.release=function(a){return this.resolver.release(a),this},f.Context.prototype.releaseAll=function(){return this.resolver.releaseAll(),this},f.Context.prototype.destroy=function(){this.vent.stopListening(),this.resolver.releaseAll(),delete g[this._contextId],this.dispatchToParent(f.EVENT_CONTEXT_SHUTDOWN)},f.Context.extend=b.View.extend;var j={contexts:g,countEvents:function(){var b=0;return a.each(g,function(c,d){g.hasOwnProperty(d)&&(b+=a.size(c.vent._events))}),b},countContexts:function(){var b=0;return a.each(g,function(a,c){g.hasOwnProperty(c)&&b++}),b}};return f.setDebug=function(a){return this.debug=a?j:void 0,this.debug},b.Geppetto=f,f}); \ No newline at end of file diff --git a/package.json b/package.json index 1c115c8..4172753 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "backbone.geppetto", "description": "Bring your Backbone applications to life with an event-driven Command framework.", - "version": "0.7.0-rc5", + "version": "0.7.0", "homepage": "https://github.com/ModelN/backbone.geppetto", "author": { "name": "Dave Cadwallader", @@ -30,19 +30,19 @@ "test": "grunt travis --verbose" }, "devDependencies": { + "backbone": "~1.1.0", "grunt": "~0.4.1", - "grunt-blanket-mocha": "~0.3.1", - "grunt-contrib-jshint": "~0.8.0", - "grunt-contrib-uglify": "~0.2.2", - "grunt-version": "~0.2.2", - "mocha-unfunk-reporter": "~0.4.0", - "grunt-contrib-connect": "~0.6.0", - "grunt-concurrent": "~0.4.0", - "grunt-open": "~0.2.2", + "grunt-blanket-mocha": "^0.4.0", + "grunt-concurrent": "^0.5.0", + "grunt-contrib-connect": "^0.7.1", + "grunt-contrib-jshint": "^0.10.0", + "grunt-contrib-uglify": "^0.4.0", "grunt-jsbeautifier": "~0.2.2", - "grunt-saucelabs": "~4.1.2", - "backbone": "~1.1.0", - "jquery": "~1.8.3" + "grunt-open": "~0.2.2", + "grunt-saucelabs": "^5.1.2", + "grunt-version": "0.2.2", + "jquery": "^2.1.0", + "mocha-unfunk-reporter": "~0.4.0" }, "keywords": [ "backbone", diff --git a/version.json b/version.json index 0d5e937..3be8083 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "0.7.0-rc5" + "version": "0.7.0" } \ No newline at end of file