faker 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jshintignore +3 -0
- package/.jshintrc +87 -0
- package/.npmignore +16 -0
- package/.travis.yml +5 -0
- package/BUILD/BUILD.js +139 -0
- package/BUILD/Mustache.js +296 -0
- package/BUILD/docs.js +62 -0
- package/BUILD/main.js +60 -0
- package/MIT-LICENSE.txt +20 -0
- package/Makefile +26 -0
- package/Readme.md +46 -0
- package/examples/bigDataSet.json +1 -0
- package/examples/browser_test.html +40 -0
- package/examples/dataSet.json +1 -0
- package/examples/index.html +77 -0
- package/examples/js/faker.js +730 -0
- package/examples/js/jquery.js +154 -0
- package/examples/js/prettyPrint.js +712 -0
- package/examples/library_test.js +9 -0
- package/examples/node_generateSet.js +20 -0
- package/examples/node_min_test.js +9 -0
- package/faker.js +730 -0
- package/index.js +31 -0
- package/lib/address.js +100 -0
- package/lib/company.js +36 -0
- package/lib/date.js +42 -0
- package/lib/definitions.js +1398 -0
- package/lib/helpers.js +124 -0
- package/lib/image.js +58 -0
- package/lib/internet.js +53 -0
- package/lib/lorem.js +45 -0
- package/lib/name.js +34 -0
- package/lib/phone_number.js +16 -0
- package/lib/random.js +106 -0
- package/lib/tree.js +69 -0
- package/lib/version.js +0 -0
- package/logo.png +0 -0
- package/minfaker.js +35 -0
- package/package.json +25 -0
- package/test/address.unit.js +293 -0
- package/test/all.functional.js +47 -0
- package/test/browser.unit.html +28 -0
- package/test/company.unit.js +110 -0
- package/test/date.unit.js +65 -0
- package/test/helpers.unit.js +62 -0
- package/test/image.unit.js +108 -0
- package/test/internet.unit.js +92 -0
- package/test/lorem.unit.js +178 -0
- package/test/mocha.opts +5 -0
- package/test/name.unit.js +87 -0
- package/test/phone_number.unit.js +29 -0
- package/test/run.js +68 -0
- package/test/support/chai.js +3403 -0
- package/test/support/sinon-1.5.2.js +4153 -0
- package/test/support/walk_dir.js +43 -0
- package/test/tree.unit.js +108 -0
package/.jshintignore
ADDED
package/.jshintrc
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
{
|
2
|
+
// Settings
|
3
|
+
"passfail" : false, // Stop on first error.
|
4
|
+
"maxerr" : 500, // Maximum errors before stopping.
|
5
|
+
"multistr" : true,
|
6
|
+
|
7
|
+
|
8
|
+
// Predefined globals whom JSHint will ignore.
|
9
|
+
"browser" : true, // Standard browser globals e.g. `window`, `document`.
|
10
|
+
|
11
|
+
"node" : false,
|
12
|
+
"rhino" : false,
|
13
|
+
"couch" : false,
|
14
|
+
"wsh" : true, // Windows Scripting Host.
|
15
|
+
|
16
|
+
"jquery" : true,
|
17
|
+
"prototypejs" : false,
|
18
|
+
"mootools" : false,
|
19
|
+
"dojo" : false,
|
20
|
+
|
21
|
+
"predef" : [ // Extra globals.
|
22
|
+
"__dirname",
|
23
|
+
"Buffer",
|
24
|
+
"event",
|
25
|
+
"exports",
|
26
|
+
"global",
|
27
|
+
"logger",
|
28
|
+
"module",
|
29
|
+
"process",
|
30
|
+
"require",
|
31
|
+
|
32
|
+
"after",
|
33
|
+
"afterEach",
|
34
|
+
"before",
|
35
|
+
"beforeEach",
|
36
|
+
"context",
|
37
|
+
"describe",
|
38
|
+
"it"
|
39
|
+
],
|
40
|
+
|
41
|
+
// Development.
|
42
|
+
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
|
43
|
+
"devel" : true, // Allow development statements e.g. `console.log();`.
|
44
|
+
|
45
|
+
|
46
|
+
// EcmaScript 5.
|
47
|
+
"es5" : false, // Allow EcmaScript 5 syntax.
|
48
|
+
"strict" : false, // Require `use strict` pragma in every file.
|
49
|
+
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
|
50
|
+
|
51
|
+
|
52
|
+
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
|
53
|
+
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
54
|
+
"bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
|
55
|
+
"boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
56
|
+
"curly" : true, // Require {} for every new block or scope.
|
57
|
+
"eqeqeq" : false, // Require triple equals i.e. `===`.
|
58
|
+
"eqnull" : false, // Tolerate use of `== null`.
|
59
|
+
"evil" : false, // Tolerate use of `eval`.
|
60
|
+
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
61
|
+
"forin" : false, // Tolerate `for in` loops without `hasOwnProperty`.
|
62
|
+
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
63
|
+
"latedef" : true, // Prohibit variable use before definition.
|
64
|
+
"loopfunc" : true, // Allow functions to be defined within loops.
|
65
|
+
//"maxparams" : 4,
|
66
|
+
//"maxdepth" : 5,
|
67
|
+
//"maxcomplexity" : 10,
|
68
|
+
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
69
|
+
"regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
|
70
|
+
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
|
71
|
+
"scripturl" : true, // Tolerate script-targeted URLs.
|
72
|
+
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
73
|
+
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
74
|
+
"undef" : true, // Require all non-global variables be declared before they are used.
|
75
|
+
|
76
|
+
|
77
|
+
"newcap" : false, // Require capitalization of all constructor functions e.g. `new F()`.
|
78
|
+
"noempty" : true, // Prohibit use of empty blocks.
|
79
|
+
"nonew" : false, // Prohibit use of constructors for side-effects.
|
80
|
+
"nomen" : false, // Prohibit use of initial or trailing underbars in names.
|
81
|
+
"onevar" : false, // Allow only one `var` statement per function.
|
82
|
+
"plusplus" : false, // Prohibit use of `++` & `--`.
|
83
|
+
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
84
|
+
"trailing" : true, // Prohibit trailing whitespaces. (only works if white is 'true')
|
85
|
+
"white" : true, // Check against strict whitespace and indentation rules.
|
86
|
+
"indent" : 4 //
|
87
|
+
}
|
package/.npmignore
ADDED
package/.travis.yml
ADDED
package/BUILD/BUILD.js
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
var sys = require('sys')
|
4
|
+
, fs = require('fs')
|
5
|
+
, M = require('./Mustache')
|
6
|
+
, compressor = require('node-minify');
|
7
|
+
|
8
|
+
var package = require('../package.json');
|
9
|
+
var code = '';
|
10
|
+
var docs = {};
|
11
|
+
|
12
|
+
docs.main = '';
|
13
|
+
docs.API = '';
|
14
|
+
docs.copyrightYear = new Date().getFullYear();
|
15
|
+
|
16
|
+
// read in the the main.js file as our main boilerplate code
|
17
|
+
code += fs.readFileSync('./main.js', encoding = 'utf8');
|
18
|
+
code = M.Mustache.to_html(code, {'today': new Date().getTime(), 'version': package.version});
|
19
|
+
|
20
|
+
docs.main += fs.readFileSync('./docs.js', encoding = 'utf8');
|
21
|
+
|
22
|
+
// parse entire lib directory and concat it into one file for the browser
|
23
|
+
var lib = paths('./lib');
|
24
|
+
|
25
|
+
var faker = require('../index');
|
26
|
+
|
27
|
+
// generate bundle for code on the browser
|
28
|
+
for (var module in faker) {
|
29
|
+
code += ( '\n' + 'faker.' + module + ' = {};');
|
30
|
+
for (var method in faker[module]) {
|
31
|
+
code += ( '\n' + 'faker.' + module);
|
32
|
+
code += ( '.' + method + ' = ');
|
33
|
+
|
34
|
+
// serialize arrays as JSON, otherwise use simple string conversion
|
35
|
+
var methodValue = faker[module][method];
|
36
|
+
if (Array.isArray(methodValue)) {
|
37
|
+
code += JSON.stringify(methodValue) + ';\n';
|
38
|
+
} else {
|
39
|
+
code += (methodValue.toString() + ';\n');
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
// generate nice tree of api for docs
|
45
|
+
docs.API += '<ul>';
|
46
|
+
for (var module in faker) {
|
47
|
+
docs.API += '<li>' + module;
|
48
|
+
docs.API += '<ul>';
|
49
|
+
for (var method in faker[module]) {
|
50
|
+
docs.API += '<li>' + method + '</li>';
|
51
|
+
}
|
52
|
+
docs.API += '</ul>';
|
53
|
+
docs.API += '</li>';
|
54
|
+
}
|
55
|
+
docs.API += '</ul>';
|
56
|
+
|
57
|
+
// definitions hack
|
58
|
+
code += 'var definitions = faker.definitions;\n';
|
59
|
+
code += 'var Helpers = faker.Helpers;\n';
|
60
|
+
|
61
|
+
// if we are running in a CommonJS env, export everything out
|
62
|
+
code +=["\nif (typeof define == 'function'){",
|
63
|
+
" define(function(){",
|
64
|
+
" return faker;",
|
65
|
+
" });",
|
66
|
+
"}",
|
67
|
+
"else if(typeof module !== 'undefined' && module.exports) {",
|
68
|
+
" module.exports = faker;",
|
69
|
+
"}",
|
70
|
+
"else {",
|
71
|
+
" window.faker = faker;",
|
72
|
+
"}",
|
73
|
+
"",
|
74
|
+
"}()); // end faker closure"].join('\n');
|
75
|
+
|
76
|
+
// generate core library
|
77
|
+
fs.writeFile('../faker.js', code, function() {
|
78
|
+
sys.puts("faker.js generated successfully!");
|
79
|
+
});
|
80
|
+
|
81
|
+
// generate example js file as well
|
82
|
+
fs.writeFile('../examples/js/faker.js', code, function() {
|
83
|
+
sys.puts("faker.js generated successfully!");
|
84
|
+
});
|
85
|
+
|
86
|
+
var docOutput = M.Mustache.to_html(docs.main, {"API": docs.API, "copyrightYear": docs.copyrightYear});
|
87
|
+
|
88
|
+
// generate some samples sets (move this code to another section)
|
89
|
+
fs.writeFile('../Readme.md', docOutput, function() {
|
90
|
+
sys.puts("Docs generated successfully!");
|
91
|
+
});
|
92
|
+
|
93
|
+
// generates minified version Using Google Closure
|
94
|
+
new compressor.minify({
|
95
|
+
type: 'gcc',
|
96
|
+
fileIn: '../faker.js',
|
97
|
+
fileOut: '../minfaker.js',
|
98
|
+
callback: function(err){
|
99
|
+
if(err) {
|
100
|
+
console.log(err);
|
101
|
+
}
|
102
|
+
else sys.puts("Minified version generated successfully!");
|
103
|
+
}
|
104
|
+
});
|
105
|
+
|
106
|
+
|
107
|
+
/*********************** BUILD HELPER METHODS *********************/
|
108
|
+
|
109
|
+
// Recursively traverse a hierarchy, returning a list of all relevant .js files.
|
110
|
+
function paths(dir) {
|
111
|
+
var paths = [];
|
112
|
+
|
113
|
+
try {
|
114
|
+
fs.statSync(dir);
|
115
|
+
}
|
116
|
+
catch (e) {
|
117
|
+
return e;
|
118
|
+
}
|
119
|
+
|
120
|
+
(function traverse(dir, stack) {
|
121
|
+
stack.push(dir);
|
122
|
+
fs.readdirSync(stack.join('/')).forEach(function(file) {
|
123
|
+
var path = stack.concat([file]).join('/'),
|
124
|
+
stat = fs.statSync(path);
|
125
|
+
|
126
|
+
if (file[0] == '.' || file === 'vendor') {
|
127
|
+
return;
|
128
|
+
} else if (stat.isFile() && /\.js$/.test(file)) {
|
129
|
+
paths.push(path);
|
130
|
+
} else if (stat.isDirectory()) {
|
131
|
+
paths.push(path);
|
132
|
+
traverse(file, stack);
|
133
|
+
}
|
134
|
+
});
|
135
|
+
stack.pop();
|
136
|
+
})(dir || '.', []);
|
137
|
+
|
138
|
+
return paths;
|
139
|
+
}
|
@@ -0,0 +1,296 @@
|
|
1
|
+
/*
|
2
|
+
mustache.js — Logic-less templates in JavaScript
|
3
|
+
|
4
|
+
See http://mustache.github.com/ for more info.
|
5
|
+
*/
|
6
|
+
|
7
|
+
var Mustache = exports.Mustache = function() {
|
8
|
+
var Renderer = function() {};
|
9
|
+
|
10
|
+
Renderer.prototype = {
|
11
|
+
otag: "{{",
|
12
|
+
ctag: "}}",
|
13
|
+
pragmas: {},
|
14
|
+
buffer: [],
|
15
|
+
pragmas_implemented: {
|
16
|
+
"IMPLICIT-ITERATOR": true
|
17
|
+
},
|
18
|
+
|
19
|
+
render: function(template, context, partials, in_recursion) {
|
20
|
+
// fail fast
|
21
|
+
if(template.indexOf(this.otag) == -1) {
|
22
|
+
if(in_recursion) {
|
23
|
+
return template;
|
24
|
+
} else {
|
25
|
+
this.send(template);
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
if(!in_recursion) {
|
31
|
+
this.buffer = [];
|
32
|
+
}
|
33
|
+
|
34
|
+
template = this.render_pragmas(template);
|
35
|
+
var html = this.render_section(template, context, partials);
|
36
|
+
if(in_recursion) {
|
37
|
+
return this.render_tags(html, context, partials, in_recursion);
|
38
|
+
}
|
39
|
+
|
40
|
+
this.render_tags(html, context, partials, in_recursion);
|
41
|
+
},
|
42
|
+
|
43
|
+
/*
|
44
|
+
Sends parsed lines
|
45
|
+
*/
|
46
|
+
send: function(line) {
|
47
|
+
if(line != "") {
|
48
|
+
this.buffer.push(line);
|
49
|
+
}
|
50
|
+
},
|
51
|
+
|
52
|
+
/*
|
53
|
+
Looks for %PRAGMAS
|
54
|
+
*/
|
55
|
+
render_pragmas: function(template) {
|
56
|
+
// no pragmas
|
57
|
+
if(template.indexOf(this.otag + "%") == -1) {
|
58
|
+
return template;
|
59
|
+
}
|
60
|
+
|
61
|
+
var that = this;
|
62
|
+
var regex = new RegExp(this.otag + "%([\\w_-]+) ?([\\w]+=[\\w]+)?"
|
63
|
+
+ this.ctag);
|
64
|
+
return template.replace(regex, function(match, pragma, options) {
|
65
|
+
if(!that.pragmas_implemented[pragma]) {
|
66
|
+
throw({message: "This implementation of mustache doesn't understand the '"
|
67
|
+
+ pragma + "' pragma"});
|
68
|
+
}
|
69
|
+
that.pragmas[pragma] = {};
|
70
|
+
if(options) {
|
71
|
+
var opts = options.split("=");
|
72
|
+
that.pragmas[pragma][opts[0]] = opts[1];
|
73
|
+
}
|
74
|
+
return "";
|
75
|
+
// ignore unknown pragmas silently
|
76
|
+
});
|
77
|
+
},
|
78
|
+
|
79
|
+
/*
|
80
|
+
Tries to find a partial in the global scope and render it
|
81
|
+
*/
|
82
|
+
render_partial: function(name, context, partials) {
|
83
|
+
if(!partials || !partials[name]) {
|
84
|
+
throw({message: "unknown_partial '" + name + "'"});
|
85
|
+
}
|
86
|
+
if(typeof(context[name]) != "object") {
|
87
|
+
return partials[name];
|
88
|
+
}
|
89
|
+
return this.render(partials[name], context[name], partials, true);
|
90
|
+
},
|
91
|
+
|
92
|
+
/*
|
93
|
+
Renders boolean and enumerable sections
|
94
|
+
*/
|
95
|
+
render_section: function(template, context, partials) {
|
96
|
+
if(template.indexOf(this.otag + "#") == -1) {
|
97
|
+
return template;
|
98
|
+
}
|
99
|
+
var that = this;
|
100
|
+
// CSW - Added "+?" so it finds the tighest bound, not the widest
|
101
|
+
var regex = new RegExp(this.otag + "\\#(.+)" + this.ctag +
|
102
|
+
"\\s*([\\s\\S]+?)" + this.otag + "\\/\\1" + this.ctag + "\\s*", "mg");
|
103
|
+
|
104
|
+
// for each {{#foo}}{{/foo}} section do...
|
105
|
+
return template.replace(regex, function(match, name, content) {
|
106
|
+
var value = that.find(name, context);
|
107
|
+
if(that.is_array(value)) { // Enumerable, Let's loop!
|
108
|
+
return that.map(value, function(row) {
|
109
|
+
return that.render(content, that.merge(context,
|
110
|
+
that.create_context(row)), partials, true);
|
111
|
+
}).join("");
|
112
|
+
} else if(value) { // boolean section
|
113
|
+
return that.render(content, context, partials, true);
|
114
|
+
} else {
|
115
|
+
return "";
|
116
|
+
}
|
117
|
+
});
|
118
|
+
},
|
119
|
+
|
120
|
+
/*
|
121
|
+
Replace {{foo}} and friends with values from our view
|
122
|
+
*/
|
123
|
+
render_tags: function(template, context, partials, in_recursion) {
|
124
|
+
// tit for tat
|
125
|
+
var that = this;
|
126
|
+
|
127
|
+
var new_regex = function() {
|
128
|
+
return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\/#]+?)\\1?" +
|
129
|
+
that.ctag + "+", "g");
|
130
|
+
};
|
131
|
+
|
132
|
+
var regex = new_regex();
|
133
|
+
var lines = template.split("\n");
|
134
|
+
for (var i=0; i < lines.length; i++) {
|
135
|
+
lines[i] = lines[i].replace(regex, function(match, operator, name) {
|
136
|
+
switch(operator) {
|
137
|
+
case "!": // ignore comments
|
138
|
+
return match;
|
139
|
+
case "=": // set new delimiters, rebuild the replace regexp
|
140
|
+
that.set_delimiters(name);
|
141
|
+
regex = new_regex();
|
142
|
+
return "";
|
143
|
+
case ">": // render partial
|
144
|
+
return that.render_partial(name, context, partials);
|
145
|
+
case "{": // the triple mustache is unescaped
|
146
|
+
return that.find(name, context);
|
147
|
+
default: // escape the value
|
148
|
+
return that.escape(that.find(name, context));
|
149
|
+
}
|
150
|
+
}, this);
|
151
|
+
if(!in_recursion) {
|
152
|
+
this.send(lines[i]);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
if(in_recursion) {
|
157
|
+
return lines.join("\n");
|
158
|
+
}
|
159
|
+
},
|
160
|
+
|
161
|
+
set_delimiters: function(delimiters) {
|
162
|
+
var dels = delimiters.split(" ");
|
163
|
+
this.otag = this.escape_regex(dels[0]);
|
164
|
+
this.ctag = this.escape_regex(dels[1]);
|
165
|
+
},
|
166
|
+
|
167
|
+
escape_regex: function(text) {
|
168
|
+
// thank you Simon Willison
|
169
|
+
if(!arguments.callee.sRE) {
|
170
|
+
var specials = [
|
171
|
+
'/', '.', '*', '+', '?', '|',
|
172
|
+
'(', ')', '[', ']', '{', '}', '\\'
|
173
|
+
];
|
174
|
+
arguments.callee.sRE = new RegExp(
|
175
|
+
'(\\' + specials.join('|\\') + ')', 'g'
|
176
|
+
);
|
177
|
+
}
|
178
|
+
return text.replace(arguments.callee.sRE, '\\$1');
|
179
|
+
},
|
180
|
+
|
181
|
+
/*
|
182
|
+
find `name` in current `context`. That is find me a value
|
183
|
+
from the view object
|
184
|
+
*/
|
185
|
+
find: function(name, context) {
|
186
|
+
name = this.trim(name);
|
187
|
+
if(typeof context[name] === "function") {
|
188
|
+
return context[name].apply(context);
|
189
|
+
}
|
190
|
+
if(context[name] !== undefined) {
|
191
|
+
return context[name];
|
192
|
+
}
|
193
|
+
// silently ignore unkown variables
|
194
|
+
return "";
|
195
|
+
},
|
196
|
+
|
197
|
+
// Utility methods
|
198
|
+
|
199
|
+
/*
|
200
|
+
Does away with nasty characters
|
201
|
+
*/
|
202
|
+
escape: function(s) {
|
203
|
+
return ((s == null) ? "" : s).toString().replace(/[&"<>\\]/g, function(s) {
|
204
|
+
switch(s) {
|
205
|
+
case "&": return "&";
|
206
|
+
case "\\": return "\\\\";;
|
207
|
+
case '"': return '\"';;
|
208
|
+
case "<": return "<";
|
209
|
+
case ">": return ">";
|
210
|
+
default: return s;
|
211
|
+
}
|
212
|
+
});
|
213
|
+
},
|
214
|
+
|
215
|
+
/*
|
216
|
+
Merges all properties of object `b` into object `a`.
|
217
|
+
`b.property` overwrites a.property`
|
218
|
+
*/
|
219
|
+
merge: function(a, b) {
|
220
|
+
var _new = {};
|
221
|
+
for(var name in a) {
|
222
|
+
if(a.hasOwnProperty(name)) {
|
223
|
+
_new[name] = a[name];
|
224
|
+
}
|
225
|
+
};
|
226
|
+
for(var name in b) {
|
227
|
+
if(b.hasOwnProperty(name)) {
|
228
|
+
_new[name] = b[name];
|
229
|
+
}
|
230
|
+
};
|
231
|
+
return _new;
|
232
|
+
},
|
233
|
+
|
234
|
+
// by @langalex, support for arrays of strings
|
235
|
+
create_context: function(_context) {
|
236
|
+
if(this.is_object(_context)) {
|
237
|
+
return _context;
|
238
|
+
} else if(this.pragmas["IMPLICIT-ITERATOR"]) {
|
239
|
+
var iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator || ".";
|
240
|
+
var ctx = {};
|
241
|
+
ctx[iterator] = _context;
|
242
|
+
return ctx;
|
243
|
+
}
|
244
|
+
},
|
245
|
+
|
246
|
+
is_object: function(a) {
|
247
|
+
return a && typeof a == "object";
|
248
|
+
},
|
249
|
+
|
250
|
+
is_array: function(a) {
|
251
|
+
return Object.prototype.toString.call(a) === '[object Array]';
|
252
|
+
},
|
253
|
+
|
254
|
+
/*
|
255
|
+
Gets rid of leading and trailing whitespace
|
256
|
+
*/
|
257
|
+
trim: function(s) {
|
258
|
+
return s.replace(/^\s*|\s*$/g, "");
|
259
|
+
},
|
260
|
+
|
261
|
+
/*
|
262
|
+
Why, why, why? Because IE. Cry, cry cry.
|
263
|
+
*/
|
264
|
+
map: function(array, fn) {
|
265
|
+
if (typeof array.map == "function") {
|
266
|
+
return array.map(fn);
|
267
|
+
} else {
|
268
|
+
var r = [];
|
269
|
+
var l = array.length;
|
270
|
+
for(var i=0;i<l;i++) {
|
271
|
+
r.push(fn(array[i]));
|
272
|
+
}
|
273
|
+
return r;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
};
|
277
|
+
|
278
|
+
return({
|
279
|
+
name: "mustache.js",
|
280
|
+
version: "0.2.3",
|
281
|
+
|
282
|
+
/*
|
283
|
+
Turns a template and view into HTML
|
284
|
+
*/
|
285
|
+
to_html: function(template, view, partials, send_fun) {
|
286
|
+
var renderer = new Renderer();
|
287
|
+
if(send_fun) {
|
288
|
+
renderer.send = send_fun;
|
289
|
+
}
|
290
|
+
renderer.render(template, view, partials);
|
291
|
+
if(!send_fun) {
|
292
|
+
return renderer.buffer.join("\n");
|
293
|
+
}
|
294
|
+
}
|
295
|
+
});
|
296
|
+
}();
|
package/BUILD/docs.js
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# faker.js - generate massive amounts of fake data in the browser and node.js
|
2
|
+
<img src = "http://imgur.com/KiinQ.png" border = "0">
|
3
|
+
|
4
|
+
## USAGE
|
5
|
+
|
6
|
+
### browser -
|
7
|
+
|
8
|
+
<script src = "faker.js" type = "text/javascript"></script>
|
9
|
+
<script>
|
10
|
+
var randomName = faker.Name.findName(); // Caitlyn Kerluke
|
11
|
+
var randomEmail = faker.Internet.email(); // Rusty@arne.info
|
12
|
+
var randomCard = faker.Helpers.createCard(); // random contact card containing many properties
|
13
|
+
</script>
|
14
|
+
|
15
|
+
### node.js -
|
16
|
+
|
17
|
+
### usage
|
18
|
+
|
19
|
+
var faker = require('./faker');
|
20
|
+
|
21
|
+
var randomName = faker.Name.findName(); // Rowan Nikolaus
|
22
|
+
var randomEmail = faker.Internet.email(); // Kassandra.Haley@erich.biz
|
23
|
+
var randomCard = faker.Helpers.createCard(); // random contact card containing many properties
|
24
|
+
|
25
|
+
|
26
|
+
## API
|
27
|
+
|
28
|
+
{{{API}}}
|
29
|
+
|
30
|
+
## Tests
|
31
|
+
npm install .
|
32
|
+
make test
|
33
|
+
|
34
|
+
You can view a code coverage report generated in coverage/lcov-report/index.html.
|
35
|
+
|
36
|
+
## Authors
|
37
|
+
|
38
|
+
####Matthew Bergman & Marak Squires
|
39
|
+
|
40
|
+
Heavily inspired by Benjamin Curtis's Ruby Gem [faker](http://faker.rubyforge.org/) and Perl's [Data::faker](http://search.cpan.org/~jasonk/Data-faker-0.07/lib/Data/faker.pm)
|
41
|
+
|
42
|
+
<br/>
|
43
|
+
Copyright (c) {{copyrightYear}} Matthew Bergman & Marak Squires http://github.com/marak/faker.js/
|
44
|
+
<br/>
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
46
|
+
a copy of this software and associated documentation files (the
|
47
|
+
"Software"), to deal in the Software without restriction, including
|
48
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
49
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
50
|
+
permit persons to whom the Software is furnished to do so, subject to
|
51
|
+
the following conditions:
|
52
|
+
<br/>
|
53
|
+
The above copyright notice and this permission notice shall be
|
54
|
+
included in all copies or substantial portions of the Software.
|
55
|
+
<br/>
|
56
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
57
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
58
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
59
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
60
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
61
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
62
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/BUILD/main.js
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2010 Matthew Bergman & Marak Squires http://github.com/marak/faker.js/
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
|
24
|
+
/*************** AUTOGENERATED @ {{today}} ***************
|
25
|
+
|
26
|
+
WARNING: THIS FILE WAS AUTOGENERATED BY THE faker BUILD SCRIPT
|
27
|
+
MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING
|
28
|
+
THE LIBRARY DIRECTLY AND REGENERATING THIS FILE USING BUILD.js!!!!
|
29
|
+
|
30
|
+
|
31
|
+
faker.js - Written by Matthew Bergman and Marak Squires
|
32
|
+
|
33
|
+
## USAGE
|
34
|
+
|
35
|
+
### browser -
|
36
|
+
|
37
|
+
<script src = "faker.js" type = "text/javascript"></script>
|
38
|
+
<script>
|
39
|
+
var randomName = faker.Name.findName(); // Caitlyn Kerluke
|
40
|
+
var randomEmail = faker.Internet.email(); // Rusty@arne.info
|
41
|
+
var randomCard = faker.Helpers.createCard(); // random contact card containing many properties
|
42
|
+
</script>
|
43
|
+
|
44
|
+
### node.js -
|
45
|
+
|
46
|
+
var faker = require('./faker');
|
47
|
+
|
48
|
+
var randomName = faker.Name.findName(); // Rowan Nikolaus
|
49
|
+
var randomEmail = faker.Internet.email(); // Kassandra.Haley@erich.biz
|
50
|
+
var randomCard = faker.Helpers.createCard(); // random contact card containing many properties
|
51
|
+
|
52
|
+
*/
|
53
|
+
!(function(){
|
54
|
+
|
55
|
+
'use strict';
|
56
|
+
|
57
|
+
// exported module
|
58
|
+
var faker = {};
|
59
|
+
|
60
|
+
faker.version = "{{version}}";
|
package/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Matthew Bergman & Marak Squires http://github.com/marak/faker.js/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|