diff --git a/BUILD.js b/BUILD.js deleted file mode 100644 index 50050bff..00000000 --- a/BUILD.js +++ /dev/null @@ -1,4 +0,0 @@ -// create exports wrapper - -// parse entire lib directory and concat it into one file for the browser - diff --git a/BUILD/BUILD.js b/BUILD/BUILD.js new file mode 100644 index 00000000..f7c7a106 --- /dev/null +++ b/BUILD/BUILD.js @@ -0,0 +1,45 @@ +var sys = require('sys') + , fs = require('fs'); + +var code = ''; + +// read in the the main.js file as our main boilerplate code +code += fs.readFileSync('./main.js', encoding='utf8'); + +// parse entire lib directory and concat it into one file for the browser +var lib = paths('./lib'); + +sys.puts(JSON.stringify(lib)); + +// generate some samples sets (move this code to another section) + +/*********************** BUILD HELPER METHODS *********************/ + + // Recursively traverse a hierarchy, returning a list of all relevant .js files. + function paths(dir) { + var paths = []; + + try { fs.statSync(dir) } + catch (e) { return e } + + (function traverse(dir, stack) { + stack.push(dir); + fs.readdirSync(stack.join('/')).forEach(function (file) { + var path = stack.concat([file]).join('/'), + stat = fs.statSync(path); + + if (file[0] == '.' || file === 'vendor') { + return; + } else if (stat.isFile() && /\.js$/.test(file)) { + paths.push(path); + } else if (stat.isDirectory()) { + paths.push(path); + traverse(file, stack); + } + }); + stack.pop(); + })(dir || '.', []); + + return paths; + } + diff --git a/BUILD/main.js b/BUILD/main.js new file mode 100644 index 00000000..bd1dc117 --- /dev/null +++ b/BUILD/main.js @@ -0,0 +1,4 @@ +// this is just boilerplate code for generating the actual mustache-rides.js file, do not use this outside of node_builder.js +var Faker = {}; + +Faker.version = "0.0.1"; diff --git a/index.js b/index.js index 92e3f85d..47331d56 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ Faker.Company = require('./lib/company'); Faker.Lorem = require('./lib/lorem'); -var Helper = require('helper');; +var Helper = require('./lib/helper');; sys.puts(JSON.stringify(Faker.Name.first_name())); sys.puts(JSON.stringify(Faker.Name.findName())); diff --git a/lib/address.js b/lib/address.js index bfd786b6..1b96819f 100644 --- a/lib/address.js +++ b/lib/address.js @@ -1,4 +1,4 @@ -var Helper = require('../helper'); +var Helper = require('./helper'); var definitions = require('../lib/definitions'); exports.zipCode = function() { diff --git a/lib/company.js b/lib/company.js index 3cd31594..d01eace6 100644 --- a/lib/company.js +++ b/lib/company.js @@ -1,4 +1,4 @@ -var Helper = require('../helper'); +var Helper = require('./helper'); var definitions = require('../lib/definitions'); exports.companyName = function() { diff --git a/helper.js b/lib/helper.js similarity index 100% rename from helper.js rename to lib/helper.js diff --git a/lib/internet.js b/lib/internet.js index 9e7a8539..046ffa42 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -1,4 +1,4 @@ -var Helper = require('../helper'); +var Helper = require('./helper'); var definitions = require('./definitions'); exports.email = function() { diff --git a/lib/lorem.js b/lib/lorem.js index 7ba1b118..d9101e2c 100644 --- a/lib/lorem.js +++ b/lib/lorem.js @@ -1,4 +1,4 @@ -var Helper = require('../helper'); +var Helper = require('./helper'); var definitions = require('../lib/definitions'); exports.words = function(num){ diff --git a/lib/name.js b/lib/name.js index 37d92511..fa32d6e6 100644 --- a/lib/name.js +++ b/lib/name.js @@ -1,4 +1,4 @@ -var Helper = require('../helper'); +var Helper = require('./helper'); var definitions = require('./definitions'); exports.first_name = function(){ diff --git a/lib/phone_number.js b/lib/phone_number.js index 5537ff7e..975e47ad 100644 --- a/lib/phone_number.js +++ b/lib/phone_number.js @@ -1,4 +1,4 @@ -var Helper = require('../helper'); +var Helper = require('./helper'); var definitions = require('./definitions'); exports.phoneNumber = function(){ diff --git a/generateSet.js b/sampleSets/test.js similarity index 100% rename from generateSet.js rename to sampleSets/test.js