mongodb-fixtures
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -18,3 +18,4 @@ { | ||
"family": "Chardonnay", | ||
"winery": ["sunnyside._id", "sunnyside._id"] | ||
"winery": ["sunnyside._id", "sunnyside._id"], | ||
"productionDate": "<%= new Date().toISOString() %>" | ||
}, | ||
@@ -21,0 +22,0 @@ "elzas": { |
var lingo = require('lingo') | ||
, fs = require('fs') | ||
, path = require('path') | ||
, _ = require('underscore'), | ||
eco = require('eco'); | ||
, _ = require('underscore') | ||
, eco = require('eco'); | ||
@@ -11,2 +11,4 @@ // To be exported ... | ||
var ISO8601_DATE_FORMAT = /^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?([zZ]|([\+-])([01]\d|2[0-3])\D?([0-5]\d)?)?)?$/ | ||
/** @ignore */ | ||
@@ -100,3 +102,9 @@ var get = function (obj, path) { | ||
collections.push(collectionName); | ||
fixtures[collectionName] = JSON.parse(eco.render(""+fs.readFileSync(path.join(fixture_path||"./fixtures",file)), {})); | ||
fixtures[collectionName] = JSON.parse(eco.render(""+fs.readFileSync(path.join(fixture_path||"./fixtures",file)), {}) , function(key, value) { | ||
var result = value; | ||
if (typeof value === 'string' && value.match(ISO8601_DATE_FORMAT)) { | ||
result = new Date(Date.parse(value)); | ||
} | ||
return result; | ||
}); | ||
} | ||
@@ -103,0 +111,0 @@ }); |
{ | ||
"name": "mongodb-fixtures", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "JSON based fixtures for mongodb", | ||
@@ -5,0 +5,0 @@ "keywords": ["mongodb", "mongo", "json", "fixtures"], |
8463
208