2015-05-18 17:52:01 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-14 13:56:52 +00:00
|
|
|
var Steppy = require('twostep').Steppy,
|
|
|
|
inherits = require('util').inherits,
|
2015-05-18 17:52:01 +00:00
|
|
|
ParentReader = require('./base').Reader,
|
2015-06-14 13:56:52 +00:00
|
|
|
path = require('path'),
|
|
|
|
fs = require('fs');
|
2015-05-18 17:52:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
function Reader() {
|
|
|
|
ParentReader.call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(Reader, ParentReader);
|
|
|
|
|
|
|
|
exports.Reader = Reader;
|
|
|
|
|
|
|
|
Reader.prototype.ext = 'json';
|
|
|
|
|
|
|
|
Reader.prototype._load = function(dir, name, callback) {
|
2015-06-14 13:56:52 +00:00
|
|
|
var self = this;
|
|
|
|
Steppy(
|
|
|
|
function() {
|
|
|
|
fs.readFile(path.join(dir, name + '.' + self.ext), 'utf8', this.slot())
|
|
|
|
},
|
|
|
|
function(err, content) {
|
|
|
|
this.pass(JSON.parse(content));
|
|
|
|
},
|
|
|
|
callback
|
|
|
|
);
|
2015-05-18 17:52:01 +00:00
|
|
|
};
|