Test repo can now be used to list entries

This commit is contained in:
Mathias Biilmann Christensen
2016-02-25 20:40:35 -08:00
parent 67cdd92bfb
commit 978b7290c5
17 changed files with 363 additions and 41 deletions

31
src/formats/yaml.js Normal file
View File

@ -0,0 +1,31 @@
import yaml from 'js-yaml';
import moment from 'moment';
const MomentType = new yaml.Type('date', {
kind: 'scalar',
predicate: function(value) {
return moment.isMoment(value);
},
represent: function(value) {
return value.format(value._f);
},
resolve: function(value) {
return moment.isMoment(value) && value._f;
}
});
const OutputSchema = new yaml.Schema({
include: yaml.DEFAULT_SAFE_SCHEMA.include,
implicit: [MomentType].concat(yaml.DEFAULT_SAFE_SCHEMA.implicit),
explicit: yaml.DEFAULT_SAFE_SCHEMA.explicit
});
export default class YAML {
fromFile(content) {
return yaml.safeLoad(content);
}
toFile(data) {
return yaml.safeDump(data, {schema: OutputSchema});
}
}