Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 32eef51076e7c47990a13ab301b3b763dbdc6d55 @jgallen23 committed Sep 20, 2012
@@ -0,0 +1 @@
+node_modules/
22 LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2012 Greg Allen
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
146 README.md
@@ -0,0 +1,146 @@
+#fakeson (pronounced FAKE-SON)
+
+fakeson is a library to create fake json documents for rapid prototyping.
+
+##Installation
+
+```
+npm install fakeson
+```
+
+##Usage
+```
+$ fakeson --help
+
+fakeson 0.0.1
+Usage: fakeson [options] [file]
+
+Options:
+ -p, --pretty Pretty print json output [boolean] [default: false]
+
+$ fakeson user.fakeson --pretty > user.json
+```
+
+##Example
+
+###Input
+user.fakeson
+```js
+{
+ "name": name(),
+ "bio": sentences(5, 10, 3, 8), //(min/max number of sentences, min/max length of words)
+ "username": chars(5, 9),
+ "joined": date({ yearRange: -1 }),
+ "title": title(3, 4),
+ "paid": bool(),
+ "status": range(0, 5)
+}
+```
+
+###Command
+```
+fakeson user.fakeson --pretty > user.json
+```
+
+###Output
+user.json
+```js
+{
+ "name": "Patrick",
+ "bio": "The heard time if right usually. Until above work. See study off me out. Sure if different. Many world big. ",
+ "username": "wswcyv",
+ "joined": "2012-08-30T12:21:34.427Z",
+ "title": "Go When Put",
+ "paid": false,
+ "status": 0
+}
+```
+
+##Array Example
+
+###Input
+user.fakeson (same as above)
+
+list.fakeson
+```js
+{
+ "users": array(5, 20, 'user.fakeson')
+}
+```
+
+###Command
+```
+fakeson user.fakeson --pretty > user.json
+```
+
+###Output
+```js
+{
+ "users": [
+ {
+ "name": "Garth",
+ "bio": "Them day does such one own. Around might you whole no give her. Four would to looked following. Important most what place. So are good are now. That sound best don't room. Himself ever near. There important paper under tell animals far. Under more soon if she as. ",
+ "username": "ianowcjdb",
+ "joined": "2012-07-14T16:29:36.295Z",
+ "title": "Following Go We",
+ "paid": false,
+ "status": 5
+ },
+ {
+ "name": "Conrad",
+ "bio": "Under keep would know ways. Turned some have even need be make. Going called they as great was. Took another found ways. Will see today. Part called small. ",
+ "username": "ikwqem",
+ "joined": "2012-02-01T10:11:17.603Z",
+ "title": "Other Water About Night",
+ "paid": true,
+ "status": 5
+ },
+ {
+ "name": "Louise",
+ "bio": "In then not should used he without next. Parts some but may. I have used without make white. Good out left light read us ever. Eyes see I work room. Same so earth out their got. While end parts sound see. Which may example need try children. ",
+ "username": "lfhobou",
+ "joined": "2011-12-17T23:12:27.959Z",
+ "title": "My Four For",
+ "paid": false,
+ "status": 5
+ },
+ ...
+ ]
+}
+```
+
+##Available Fake Data Functions
+
+Anything that is in [mockdata](https://github.com/jgallen23/mockdata) is available in fakeson.
+```js
+{
+ "chars": chars(5, 9),
+ "name": name(),
+ "num": n(10),
+ "bigNumber": bignumber(5),
+ "site": site(),
+ "url": url(),
+ "date": date({ delimiter: '/' }),
+ "title": title(3, 4),
+ "sentences": sentences(5, 10, 3, 8),
+ "bool": bool(),
+ "color": color(),
+ "word": word(),
+ "range": range(5, 7)
+}
+```
+
+##API
+
+```js
+var fakeson = require('fakeson');
+
+//return string
+var jsonString = fakeson('user.fakeson');
+
+//return json object
+var json = fakeson('user.fakeson', false);
+
+//return pretty string
+var json = fakeson('user.fakeson', true, true);
+```
@@ -0,0 +1,42 @@
+#!/usr/bin/env node
+
+var fs = require('fs');
+var version = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version
+
+var opt = require('optimist')
+ .usage('fakeson '+ version +'\nUsage: $0 [options] [file]')
+ .options('p', {
+ alias: 'pretty',
+ describe: 'Pretty print json output',
+ type: 'boolean',
+ default: false
+ })
+ //.option('m', {
+ //alias: 'minify',
+ //describe: 'Minify output',
+ //type: 'boolean'
+ //})
+ //.options('l', {
+ //alias: 'ls',
+ //describe: 'List available modules',
+ //type: 'boolean'
+ //})
+ .options('h', {
+ alias: 'help',
+ descripe: 'Show help info'
+ });
+
+var argv = opt.argv;
+
+if (argv.help) {
+ return opt.showHelp();
+}
+
+if (argv._.length == 1) {
+ var fakeson = require('../lib/fakeson');
+ var file = argv._[0];
+
+ var json = fakeson(file, true, argv.pretty);
+ process.stdout.write(json);
+
+}
@@ -0,0 +1,3 @@
+{
+ "users": array(5, 20, 'user.fakeson')
+}
@@ -0,0 +1,148 @@
+{
+ "users": [
+ {
+ "name": "Garth",
+ "bio": "Them day does such one own. Around might you whole no give her. Four would to looked following. Important most what place. So are good are now. That sound best don't room. Himself ever near. There important paper under tell animals far. Under more soon if she as. ",
+ "username": "ianowcjdb",
+ "joined": "2012-07-14T16:29:36.295Z",
+ "title": "Following Go We",
+ "paid": false,
+ "status": 5
+ },
+ {
+ "name": "Conrad",
+ "bio": "Under keep would know ways. Turned some have even need be make. Going called they as great was. Took another found ways. Will see today. Part called small. ",
+ "username": "ikwqem",
+ "joined": "2012-02-01T10:11:17.603Z",
+ "title": "Other Water About Night",
+ "paid": true,
+ "status": 5
+ },
+ {
+ "name": "Louise",
+ "bio": "In then not should used he without next. Parts some but may. I have used without make white. Good out left light read us ever. Eyes see I work room. Same so earth out their got. While end parts sound see. Which may example need try children. ",
+ "username": "lfhobou",
+ "joined": "2011-12-17T23:12:27.959Z",
+ "title": "My Four For",
+ "paid": false,
+ "status": 5
+ },
+ {
+ "name": "Lynn",
+ "bio": "Both was is near let big. Enough thought who up three. Since through here so ever an she say. Help off young these line feet like. Made its such means. Both well she use as between this. ",
+ "username": "fqkyecr",
+ "joined": "2012-04-23T12:33:15.475Z",
+ "title": "At Through Second No",
+ "paid": false,
+ "status": 1
+ },
+ {
+ "name": "Gayle",
+ "bio": "No parts could by first most mother. Years always got. Find we help read answer off many. Soon see life. Called heard by. Enough from life get then was. Asked boy find find began out study. Left of them if it. And paper has no side using. Who there now even following hand. ",
+ "username": "awsqf",
+ "joined": "2012-05-16T01:44:12.411Z",
+ "title": "Up May Following Old",
+ "paid": false,
+ "status": 5
+ },
+ {
+ "name": "Allen",
+ "bio": "Does knew day two whole no show the. Looked the most try told. Without thought it days. One keep below no new. Night may city to new called said a. Think know give sure. Man eyes into most. Another it an sure men. ",
+ "username": "ktnuflm",
+ "joined": "2012-04-22T06:06:19.148Z",
+ "title": "Study How Than Does",
+ "paid": false,
+ "status": 2
+ },
+ {
+ "name": "Tyler",
+ "bio": "Large not any thought every while. Or big important may. Its were why. Large to hear. Enough never years. But up tell. Sometimes into went once year three read. ",
+ "username": "hqdrwdb",
+ "joined": "2012-05-11T02:45:54.858Z",
+ "title": "Sometimes During Way",
+ "paid": true,
+ "status": 2
+ },
+ {
+ "name": "Ruth",
+ "bio": "Above before out a. It come went find himself school many. Since being would still almost him now. Also now than think show feet city under. See set children say can too. Us miles might. Again sentence put no made through. Why without was more almost well here. ",
+ "username": "mlfowffx",
+ "joined": "2011-11-01T00:44:12.936Z",
+ "title": "Way Need Boy",
+ "paid": true,
+ "status": 3
+ },
+ {
+ "name": "Quinn",
+ "bio": "Out come feet. Large must took together these. Being go toward example. Give in over head almost. Heard sure I hear. Across be its or sentence sea got why. Tell off would. Between try these let line more. ",
+ "username": "sxwhf",
+ "joined": "2012-01-09T06:59:48.650Z",
+ "title": "Left Write Here",
+ "paid": false,
+ "status": 2
+ },
+ {
+ "name": "Tracy",
+ "bio": "Other first work got large at my. Different are together the soon. Miles better those long change new use. Are going high always. Boy sea being if. However better man also. ",
+ "username": "rrgqdwug",
+ "joined": "2012-06-27T10:31:57.948Z",
+ "title": "Parts Time The Right",
+ "paid": true,
+ "status": 1
+ },
+ {
+ "name": "Willard",
+ "bio": "Need who go children both. For made white him with night said out. Used below below important. By go got second has. Keep end few. Find she five had line until very. Year a better people which most no. He of come ever. ",
+ "username": "tsloomkr",
+ "joined": "2012-05-16T00:18:25.421Z",
+ "title": "White Light Times Got",
+ "paid": true,
+ "status": 1
+ },
+ {
+ "name": "Willard",
+ "bio": "City up could saw. There to sometimes. Out big his and out. Father form enough use in. Own than because the days father set. ",
+ "username": "gxhsm",
+ "joined": "2012-05-24T05:40:53.504Z",
+ "title": "Hear City Get",
+ "paid": false,
+ "status": 4
+ },
+ {
+ "name": "Allen",
+ "bio": "Too five school after. Far sure young parts used heard. Second all keep which. Last well about means side been. What we also. Don't try school little often were help. ",
+ "username": "weencvw",
+ "joined": "2011-10-12T04:56:26.707Z",
+ "title": "Today Which Answer",
+ "paid": false,
+ "status": 0
+ },
+ {
+ "name": "Ray",
+ "bio": "Change just two day new knew do even. Need try without miles who since year. As as country. Few days was. If old in. What should don't. Saw show a may. ",
+ "username": "earoxacn",
+ "joined": "2011-12-21T10:47:18.967Z",
+ "title": "Himself Example Boy Man",
+ "paid": false,
+ "status": 2
+ },
+ {
+ "name": "Murray",
+ "bio": "Keep could food. These like has. Men sound animals but. Good second again say back. Did almost side turned sun from whole. I feet your if they before. ",
+ "username": "zeqrtmvc",
+ "joined": "2012-07-28T08:06:49.503Z",
+ "title": "End Light Different Best",
+ "paid": false,
+ "status": 2
+ },
+ {
+ "name": "Harry",
+ "bio": "Your his since far their. Home such another. Sun picture next all when went find years. Make two keep my went. Up paper the was paper his many need. Set following across. Should words high small. Left things study but. Tell such world since used great. ",
+ "username": "uudmq",
+ "joined": "2011-11-05T05:39:00.179Z",
+ "title": "Took Most Read",
+ "paid": false,
+ "status": 2
+ }
+ ]
+}
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+node ../bin/fakeson.js user.fakeson --pretty > user.json
+node ../bin/fakeson.js list.fakeson --pretty > list.json
@@ -0,0 +1,9 @@
+{
+ "name": name(),
+ "bio": sentences(5, 10, 3, 8), //(min/max number of sentences, min/max length of words)
+ "username": chars(5, 9),
+ "joined": date({ yearRange: -1 }),
+ "title": title(3, 4),
+ "paid": bool(),
+ "status": range(0, 5)
+}
@@ -0,0 +1,9 @@
+{
+ "name": "Patrick",
+ "bio": "The heard time if right usually. Until above work. See study off me out. Sure if different. Many world big. ",
+ "username": "wswcyv",
+ "joined": "2012-08-30T12:21:34.427Z",
+ "title": "Go When Put",
+ "paid": false,
+ "status": 0
+}
No changes.
Oops, something went wrong.

0 comments on commit 32eef51

Please sign in to comment.