Comparing version 0.0.2 to 0.1.0
@@ -5,2 +5,9 @@ # Change Log | ||
## v0.1.0 - 2015-06-29 | ||
### Update | ||
- Engines are now expected to return an object `{ defaultConfig: object, preprocessConfig: function, run: function }` | ||
- Expose I/O-helper functions as `require('customize/helpers-io')`. | ||
- More rigid parameter validation in `Customizer#registerEngines(id,engine)` | ||
## v0.0.2 - 2015-06-28 | ||
@@ -7,0 +14,0 @@ ### Fix |
36
index.js
/*! | ||
* ride-over <https://github.com/nknapp/ride-over> | ||
* customize <https://github.com/nknapp/ride-over> | ||
* | ||
@@ -25,3 +25,3 @@ * Copyright (c) 2015 Nils Knappmeier. | ||
*/ | ||
function RideOver (config, parentConfig, engines) { | ||
function Customize (config, parentConfig, engines) { | ||
var _config = _.merge({}, parentConfig, config, customOverrider) | ||
@@ -35,2 +35,9 @@ | ||
this.registerEngine = function (id, engine) { | ||
if (!_.isString(id)) { | ||
throw new Error("Engine-id must be a string, but is "+id); | ||
} | ||
if(_.isUndefined(engine["run"])) { | ||
throw new Error("Engine needs a run method"); | ||
} | ||
// This is only allowed if now engine with the same id exists. | ||
@@ -48,3 +55,3 @@ if (!(_.isUndefined(engines[id]) && _.isUndefined(_config[id]))) { | ||
_defaultConfig[id] = engine.defaultConfig | ||
return new RideOver(_defaultConfig, _config, _engines) | ||
return new Customize(_defaultConfig, _config, _engines) | ||
@@ -57,3 +64,3 @@ } | ||
* @param {object} config config overriding the config of this builder | ||
* @return {RideOver} new Builder instance | ||
* @return {Customize} new Builder instance | ||
*/ | ||
@@ -78,3 +85,3 @@ this.merge = function (config) { | ||
}) | ||
return new RideOver(preprocessedConfig, _config, engines) | ||
return new Customize(preprocessedConfig, _config, engines) | ||
} | ||
@@ -90,3 +97,3 @@ | ||
* and returns a RideOver with changed configuration. | ||
* @return {RideOver} the result of the builderFunction | ||
* @return {Customize} the result of the builderFunction | ||
*/ | ||
@@ -114,3 +121,3 @@ this.load = function (builderFunction) { | ||
return deep(_.mapValues(engines, function (engine, key) { | ||
return engine(resolvedConfig[key]) | ||
return engine.run(resolvedConfig[key]) | ||
})) | ||
@@ -124,9 +131,16 @@ }) | ||
* Create a new RideOver object with | ||
* @returns {RideOver} | ||
* @returns {Customize} | ||
*/ | ||
module.exports = function () { | ||
return new RideOver({}, {}, {}) | ||
return new Customize({}, {}, {}) | ||
} | ||
/** | ||
* @readonly | ||
*/ | ||
module.exports.withParent = require('./lib/withParent') | ||
/** | ||
* @readonly | ||
*/ | ||
module.exports.leaf = require('./lib/leaf') | ||
@@ -154,4 +168,4 @@ | ||
// Some objects have custom overriders | ||
if (_.isFunction(b._ro_custom_overrider)) { | ||
return b._ro_custom_overrider(a, b, propertyName) | ||
if (_.isFunction(b._customize_custom_overrider)) { | ||
return b._customize_custom_overrider(a, b, propertyName) | ||
} | ||
@@ -158,0 +172,0 @@ |
@@ -17,3 +17,3 @@ /*! | ||
var result = Q(promiseOrValue) | ||
result._ro_custom_overrider = function (a, b) { | ||
result._customize_custom_overrider = function (a, b) { | ||
// Leafs are overridden completely by the newer version | ||
@@ -20,0 +20,0 @@ return b |
@@ -17,3 +17,3 @@ /*! | ||
// Misuse of `_.partial` so that we have dedicated function object on which we can set properties | ||
result._ro_custom_overrider = function (a, b) { | ||
result._customize_custom_overrider = function (a, b) { | ||
return b.bind({ | ||
@@ -20,0 +20,0 @@ parent: a |
{ | ||
"name": "customize", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "A simple framework to create customizable engines", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
15449
15
308