dependency-injection
Advanced tools
Comparing version 1.3.3 to 1.4.0
@@ -10,4 +10,10 @@ // Generated by CoffeeScript 1.6.3 | ||
DIConfigurator = (function() { | ||
DIConfigurator.EXPOSE_NAME = 'di'; | ||
DIConfigurator.prototype.path = null; | ||
DIConfigurator.prototype.defaultSetup = { | ||
windowExpose: false | ||
}; | ||
DIConfigurator.prototype.defaultService = { | ||
@@ -27,25 +33,34 @@ service: null, | ||
DIConfigurator.prototype.create = function() { | ||
var config, data, defaults, di, method, name, run, s, service, services, _i, _len, _ref; | ||
var config, configuration, defaultService, defaultSetup, di, expose, method, name, run, s, service, _i, _len, _ref, _ref1; | ||
config = new Configuration(this.path); | ||
defaults = this.defaultService; | ||
services = config.addSection('services'); | ||
services.loadConfiguration = function() { | ||
defaultService = this.defaultService; | ||
config.addSection('services').loadConfiguration = function() { | ||
var name; | ||
config = this.getConfig(); | ||
for (name in config) { | ||
config[name] = this.configurator.merge(config[name], defaults); | ||
config[name] = this.configurator.merge(config[name], defaultService); | ||
} | ||
return config; | ||
}; | ||
data = config.load().services; | ||
defaultSetup = this.defaultSetup; | ||
config.addSetup('setup').loadConfiguration = function() { | ||
return this.getConfig(defaultSetup); | ||
}; | ||
configuration = config.load(); | ||
di = new DI; | ||
expose = configuration.setup.windowExpose; | ||
if (expose !== false && typeof window !== 'undefined') { | ||
name = typeof expose === 'string' ? expose : DIConfigurator.EXPOSE_NAME; | ||
window[name] = di; | ||
} | ||
run = []; | ||
for (name in data) { | ||
service = data[name]; | ||
_ref = configuration.services; | ||
for (name in _ref) { | ||
service = _ref[name]; | ||
s = di.addService(name, service.service, service["arguments"]); | ||
s.setInstantiate(service.instantiate); | ||
s.setAutowired(service.autowired); | ||
_ref = service.setup; | ||
for (method in _ref) { | ||
arguments = _ref[method]; | ||
_ref1 = service.setup; | ||
for (method in _ref1) { | ||
arguments = _ref1[method]; | ||
s.addSetup(method, arguments); | ||
@@ -52,0 +67,0 @@ } |
{ | ||
"name": "dependency-injection", | ||
"description": "Dependency injection with configuration and autowire for node js and browser", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "David Kudera", |
@@ -64,2 +64,24 @@ # Dependency injection | ||
## Auto exposing into window | ||
DI can be automatically exposed into window object (when on browser). Default name for this object is `di`. | ||
``` | ||
{ | ||
"setup": { | ||
"windowExpose": true | ||
} | ||
} | ||
``` | ||
Custom name: | ||
``` | ||
{ | ||
"setup": { | ||
"windowExpose": "configurator" | ||
} | ||
} | ||
``` | ||
### getByName | ||
@@ -216,2 +238,5 @@ | ||
* 1.4.0 | ||
+ Option for exposing di into | ||
* 1.3.2 - 1.3.3 | ||
@@ -218,0 +243,0 @@ + Bug with run option |
Sorry, the diff of this file is not supported yet
35316
450
278