dependency-injection
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -13,2 +13,6 @@ // Generated by CoffeeScript 1.6.3 | ||
DI.prototype.parameters = null; | ||
DI.prototype.config = null; | ||
DI.prototype.paths = null; | ||
@@ -33,2 +37,9 @@ | ||
DI.prototype.getParameter = function(parameter) { | ||
if (this.config === null) { | ||
throw new Error('DI container was not created with DIConfigurator.'); | ||
} | ||
return this.config.getParameter(parameter); | ||
}; | ||
DI.prototype.getPath = function(name) { | ||
@@ -35,0 +46,0 @@ return (this.basePath === null ? '' : this.basePath + '/') + name; |
@@ -12,2 +12,4 @@ // Generated by CoffeeScript 1.6.3 | ||
DIConfigurator.prototype.config = null; | ||
DIConfigurator.prototype.path = null; | ||
@@ -34,7 +36,7 @@ | ||
DIConfigurator.prototype.create = function() { | ||
var config, configuration, defaultService, defaultSetup, di, expose, method, name, run, s, service, _i, _len, _ref, _ref1; | ||
config = new Configuration(this.path); | ||
var configuration, defaultService, defaultSetup, di, expose, method, name, run, s, service, _i, _len, _ref, _ref1; | ||
this.config = new Configuration(this.path); | ||
defaultService = this.defaultService; | ||
config.addSection('services').loadConfiguration = function() { | ||
var name; | ||
this.config.addSection('services').loadConfiguration = function() { | ||
var config, name; | ||
config = this.getConfig(); | ||
@@ -49,7 +51,9 @@ for (name in config) { | ||
defaultSetup = this.defaultSetup; | ||
config.addSection('setup').loadConfiguration = function() { | ||
this.config.addSection('setup').loadConfiguration = function() { | ||
return this.getConfig(defaultSetup); | ||
}; | ||
configuration = config.load(); | ||
configuration = this.config.load(); | ||
di = new DI; | ||
di.config = this.config; | ||
di.parameters = this.config.parameters; | ||
if (configuration.setup.windowExpose !== null) { | ||
@@ -59,3 +63,3 @@ console.log('Option windowExpose is deprecated. Please use expose.'); | ||
} | ||
expose = configuration.setup.wxpose; | ||
expose = configuration.setup.expose; | ||
if (expose !== false) { | ||
@@ -62,0 +66,0 @@ name = typeof expose === 'string' ? expose : DIConfigurator.EXPOSE_NAME; |
{ | ||
"name": "dependency-injection", | ||
"description": "Dependency injection with configuration and autowire for node js and browser", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"author": { | ||
@@ -29,5 +29,5 @@ "name": "David Kudera", | ||
"chai": "1.8.1", | ||
"mocha": "1.15.1", | ||
"mocha-phantomjs": "3.2.0", | ||
"phantomjs": "1.9.2-5" | ||
"mocha": "1.16.2", | ||
"mocha-phantomjs": "3.3.0", | ||
"phantomjs": "1.9.2-6" | ||
}, | ||
@@ -34,0 +34,0 @@ "scripts": { |
@@ -344,2 +344,39 @@ [![NPM version](https://badge.fury.io/js/dependency-injection.png)](http://badge.fury.io/js/dependency-injection) | ||
## Parameters | ||
In documentation of [easy-configuration](https://github.com/sakren/node-easy-configuration) you can see that you can use | ||
also parameters. This is useful for example for setting your services. | ||
``` | ||
{ | ||
"parameters": { | ||
"database": { | ||
"user": "root", | ||
"password": "toor" | ||
} | ||
}, | ||
"services": { | ||
"database": { | ||
"service": "database/connection", | ||
"arguments": [ | ||
"%database.user%", | ||
"%database.password%" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
Credentials for database connection will be root and toor. | ||
Or you can access these parameters from di object. | ||
``` | ||
console.log(di.parameters); // whole object of expanded parameters | ||
console.log(di.getParameter('database.user'); // root | ||
``` | ||
`getParameter()` method is just shortcut to [getParameter](https://github.com/sakren/node-easy-configuration/blob/master/src/EasyConfiguration.coffee#L173) | ||
method in [easy-configuration](https://github.com/sakren/node-easy-configuration). | ||
## Without configuration | ||
@@ -399,2 +436,8 @@ | ||
* 2.1.0 | ||
+ Added [config](https://github.com/sakren/node-easy-configuration) object do DIConfigurator | ||
+ Bug with exposing | ||
+ Accessing parameters from di instance | ||
+ Updated dependencies | ||
* 2.0.1 | ||
@@ -401,0 +444,0 @@ + Injecting by arguments and hints was not working |
@@ -9,7 +9,8 @@ { | ||
"./lib/*.js", | ||
"./test/data/*.coffee" | ||
"./test/data/*.<(coffee|json)$>" | ||
], | ||
"run": [ | ||
"/test/browser/tests/Helpers", | ||
"/test/browser/tests/DI" | ||
"/test/browser/tests/DI", | ||
"/test/browser/tests/DIConfigurator" | ||
] | ||
@@ -16,0 +17,0 @@ } |
@@ -17,6 +17,6 @@ // Generated by CoffeeScript 1.6.3 | ||
dir = path.resolve(__dirname + '/../data'); | ||
di = null; | ||
dir = path.resolve(__dirname + '/../data'); | ||
describe('DI', function() { | ||
@@ -23,0 +23,0 @@ beforeEach(function() { |
@@ -7,2 +7,4 @@ // Generated by CoffeeScript 1.6.3 | ||
require('./DIConfigurator'); | ||
}).call(this); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
157352
38
2719
537