Skip to content

Commit

Permalink
Got rid of scheme builders
Browse files Browse the repository at this point in the history
The `node.getLevelNamingScheme` and the `node.setLevelNamingScheme`
methods will be removed in `enb@2.0.0`.
  • Loading branch information
blond committed Mar 30, 2016
1 parent d62cb0c commit e9aa853
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 173 deletions.
99 changes: 0 additions & 99 deletions lib/levels/level-builder.js

This file was deleted.

50 changes: 0 additions & 50 deletions lib/levels/level-plain.js

This file was deleted.

34 changes: 12 additions & 22 deletions lib/levels/level.js
@@ -1,22 +1,19 @@
var inherit = require('inherit'),
fs = require('fs'),
vow = require('vow'),
path = require('path'),
LevelBuilder = require('./level-builder');
path = require('path');

module.exports = inherit(/** @lends Level.prototype */{
/**
* @constructs Level
* @classdesc Model of level.
*
* @param {String} levelPath — path to level.
* @param {Function} [schemeBuilder]
*/
__constructor: function (levelPath, schemeBuilder) {
__constructor: function (levelPath) {
this._path = levelPath;
this.blocks = {};
this._loadDeferred = vow.defer();
this._schemeBuilder = schemeBuilder;
},

/**
Expand Down Expand Up @@ -200,23 +197,16 @@ module.exports = inherit(/** @lends Level.prototype */{
return promise;
}

var _this = this;
if (this._schemeBuilder) {
var levelBuilder = new LevelBuilder();
vow.when(this._schemeBuilder.buildLevel(this._path, levelBuilder)).then(function () {
_this.blocks = levelBuilder.getBlocks();
deferred.resolve(_this);
});
} else {
var levelPath = this._path;
filterFiles(fs.readdirSync(levelPath)).forEach(function (blockDir) {
var blockDirPath = path.join(levelPath, blockDir);
if (fs.statSync(blockDirPath).isDirectory()) {
_this._loadElement(null, blockDir, blockDirPath, true);
}
});
deferred.resolve(this);
}
var _this = this,
levelPath = this._path;

filterFiles(fs.readdirSync(levelPath)).forEach(function (blockDir) {
var blockDirPath = path.join(levelPath, blockDir);
if (fs.statSync(blockDirPath).isDirectory()) {
_this._loadElement(null, blockDir, blockDirPath, true);
}
});
deferred.resolve(this);

return promise;
}
Expand Down
4 changes: 2 additions & 2 deletions techs/levels.js
Expand Up @@ -78,7 +78,7 @@ module.exports = inherit(BaseTech, {
}
levelsIndex[levelPath] = true;
if (!this.node.buildState[levelKey]) {
var level = new Level(levelPath, this.node.getLevelNamingScheme(levelPath));
var level = new Level(levelPath);
if (levelInfo.check === false) {
var blocks = cache.get(levelPath);
if (blocks) {
Expand All @@ -103,7 +103,7 @@ module.exports = inherit(BaseTech, {
var sublevelPath = _this.node.resolvePath(path);
if (!levelsIndex[sublevelPath]) {
levelsIndex[sublevelPath] = true;
levelList.push(new Level(sublevelPath, _this.node.getLevelNamingScheme(sublevelPath)));
levelList.push(new Level(sublevelPath));
}
}));
})
Expand Down

0 comments on commit e9aa853

Please sign in to comment.