<commit_before># grunt-ipsum [![Build Status](https://travis-ci.org/timrwood/grunt-ipsum.png?branch=master)](https://travis-ci.org/timrwood/grunt-ipsum) [![Code Climate](https://codeclimate.com/github/timrwood/grunt-ipsum.png)](https://codeclimate.com/github/timrwood/grunt-ipsum)

> Generate lots of fake data.

## Getting Started
This plugin requires Grunt `~0.4.0`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-ipsum --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-contrib-less');
```

*This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.3.2](https://github.com/gruntjs/grunt-contrib-less/tree/grunt-0.3-stable).*

## Ipsum task
_Run this task with the `grunt ipsum` command._

Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.

### Options

#### dest `String`

Path to save output file.

#### template `Object|Array`

The schema of fake data to generate.

```js
grunt.config('ipsum.mytask', {
	template : {
		name : {
			first : '{%= ipsum.firstName %}',
			last : '{%= ipsum.lastName %}',
		},
		street : '{%= ipsum.streetName %}',
		city : '{%= ipsum.city %}',
		state : '{%= ipsum.usState %}',
	}
});
// Output
{
	"name": {
		"first": "Janie",
		"last": "Mertz"
	},
	"street": "Ardith Brook",
	"city": "Hertafurt",
	"state": "Rhode Island"
}
```

Each value is compiled with `_.template` using the `{%` and `%}` delimiters. Both the [grunt template](http://gruntjs.com/api/grunt.template#helpers) and [underscore.string](https://github.com/epeli/underscore.string) helpers are available in this context.

```js
grunt.config('ipsum.mytask', {
	template : {
		date : '{%= grunt.template.date(847602000000, "yyyy-mm-dd") %}',
		slug : '{%= _.slugify(ipsum.name) %}'
	}
});
// Output
{
	"date": "1996-11-09",
	"slug": "hobart-torp"
}
```

The current object is available via the `self` keyword. Note that this will only work after previous keys are set.

```js
grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}',
		slug : '{%= _.slugify(self.name) %}',
		notyetdefined : '{%= self.after %}',
		after : 'needs to be before notyetdefined'
	}
});
// Output
{
	"name": "<NAME>",
	"slug": "stephen-abshire",
	"notyetdefined": "",
	"after": "needs to be before notyetdefined"
}
```

The values available in the template context are based on [Faker.js](https://github.com/marak/Faker.js/).

<table>
	<tr>
		<th>Ipsum property</th>
		<th>Source</th>
	</tr>
	<tr>
		<td>ipsum.name</td>
		<td>Faker.Name.findName</td>
	</tr>
	<tr>
		<td>ipsum.firstName</td>
		<td>Faker.Name.firstName</td>
	</tr>
	<tr>
		<td>ipsum.lastName</td>
		<td>Faker.Name.lastName</td>
	</tr>

	<tr>
		<td>ipsum.zipCode</td>
		<td>Faker.Address.zipCode</td>
	</tr>
	<tr>
		<td>ipsum.zipCodeFormat</td>
		<td>Faker.Address.zipCodeFormat</td>
	</tr>
	<tr>
		<td>ipsum.city</td>
		<td>Faker.Address.city</td>
	</tr>
	<tr>
		<td>ipsum.streetAddress</td>
		<td>Faker.Address.streetAddress</td>
	</tr>
	<tr>
		<td>ipsum.streetAddress</td>
		<td>Faker.Address.streetAddress</td>
	</tr>
	<tr>
		<td>ipsum.secondaryAddress</td>
		<td>Faker.Address.secondaryAddress</td>
	</tr>
	<tr>
		<td>ipsum.brState</td>
		<td>Faker.Address.brState</td>
	</tr>
	<tr>
		<td>ipsum.ukCounty</td>
		<td>Faker.Address.ukCounty</td>
	</tr>
	<tr>
		<td>ipsum.ukCountry</td>
		<td>Faker.Address.ukCountry</td>
	</tr>
	<tr>
		<td>ipsum.usState</td>
		<td>Faker.Address.usState</td>
	</tr>
	<tr>
		<td>ipsum.latitude</td>
		<td>Faker.Address.latitude</td>
	</tr>
	<tr>
		<td>ipsum.longitude</td>
		<td>Faker.Address.longitude</td>
	</tr>
</table><commit_msg>Adding documentation on  and .<commit_after># grunt-ipsum [![Build Status](https://travis-ci.org/timrwood/grunt-ipsum.png?branch=master)](https://travis-ci.org/timrwood/grunt-ipsum) [![Code Climate](https://codeclimate.com/github/timrwood/grunt-ipsum.png)](https://codeclimate.com/github/timrwood/grunt-ipsum)

> Generate lots of fake data.

## Getting Started
This plugin requires Grunt `~0.4.0`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-ipsum --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-ipsum');
```

## Ipsum task
_Run this task with the `grunt ipsum` command._

Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.

### Options

#### dest `String`

Path to save output file.


```js
grunt.config('ipsum.mytask', {
	dest : 'path/to/file.json'
});
```

#### template `Object|Array`

The schema of fake data to generate.

```js
grunt.config('ipsum.mytask', {
	template : {
		name : {
			first : '{%= ipsum.firstName %}',
			last : '{%= ipsum.lastName %}',
		},
		street : '{%= ipsum.streetName %}',
		city : '{%= ipsum.city %}',
		state : '{%= ipsum.usState %}',
	}
});
// Output
{
	"name": {
		"first": "Janie",
		"last": "Mertz"
	},
	"street": "Ardith Brook",
	"city": "Hertafurt",
	"state": "Rhode Island"
}
```

Each value is compiled with `_.template` using the `{%` and `%}` delimiters. Both the [grunt template](http://gruntjs.com/api/grunt.template#helpers) and [underscore.string](https://github.com/epeli/underscore.string) helpers are available in this context.

```js
grunt.config('ipsum.mytask', {
	template : {
		date : '{%= grunt.template.date(847602000000, "yyyy-mm-dd") %}',
		slug : '{%= _.slugify(ipsum.name) %}'
	}
});
// Output
{
	"date": "1996-11-09",
	"slug": "hobart-torp"
}
```

The current object is available via the `self` keyword. Note that this will only work after previous keys are set.

```js
grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}',
		slug : '{%= _.slugify(self.name) %}',
		notyetdefined : '{%= self.after %}',
		after : 'needs to be before notyetdefined'
	}
});
// Output
{
	"name": "<NAME>",
	"slug": "stephen-abshire",
	"notyetdefined": "",
	"after": "needs to be before notyetdefined"
}
```

The values available in the template context are based on [Faker.js](https://github.com/marak/Faker.js/).

<table>
	<tr>
		<th>Ipsum property</th>
		<th>Source</th>
	</tr>
	<tr>
		<td>ipsum.name</td>
		<td>Faker.Name.findName</td>
	</tr>
	<tr>
		<td>ipsum.firstName</td>
		<td>Faker.Name.firstName</td>
	</tr>
	<tr>
		<td>ipsum.lastName</td>
		<td>Faker.Name.lastName</td>
	</tr>

	<tr>
		<td>ipsum.zipCode</td>
		<td>Faker.Address.zipCode</td>
	</tr>
	<tr>
		<td>ipsum.zipCodeFormat</td>
		<td>Faker.Address.zipCodeFormat</td>
	</tr>
	<tr>
		<td>ipsum.city</td>
		<td>Faker.Address.city</td>
	</tr>
	<tr>
		<td>ipsum.streetAddress</td>
		<td>Faker.Address.streetAddress</td>
	</tr>
	<tr>
		<td>ipsum.streetAddress</td>
		<td>Faker.Address.streetAddress</td>
	</tr>
	<tr>
		<td>ipsum.secondaryAddress</td>
		<td>Faker.Address.secondaryAddress</td>
	</tr>
	<tr>
		<td>ipsum.brState</td>
		<td>Faker.Address.brState</td>
	</tr>
	<tr>
		<td>ipsum.ukCounty</td>
		<td>Faker.Address.ukCounty</td>
	</tr>
	<tr>
		<td>ipsum.ukCountry</td>
		<td>Faker.Address.ukCountry</td>
	</tr>
	<tr>
		<td>ipsum.usState</td>
		<td>Faker.Address.usState</td>
	</tr>
	<tr>
		<td>ipsum.latitude</td>
		<td>Faker.Address.latitude</td>
	</tr>
	<tr>
		<td>ipsum.longitude</td>
		<td>Faker.Address.longitude</td>
	</tr>
</table>


#### repeat `Number|Array`

The number of times to repeat the template.

```
grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}'
	},
	repeat : 5
});
// Outputs
[
	{
		"name": "<NAME>"
	},
	{
		"name": "<NAME>"
	},
	{
		"name": "<NAME>"
	},
	{
		"name": "<NAME>"
	},
	{
		"name": "<NAME>"
	}
]
```

If the value is an array, the template will be repeated a random number of times between the two values.

```
grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}'
	},
	repeat : [1, 20]
});
// Outputs 1 to 20 results
[
	{
		"name": "<NAME>"
	},
	// ...
	{
		"name": "<NAME>"
	}
]
```



#### repetitions `Object`

The number of times to repeat nested items.

```
grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}',
		children : {
			name : '{%= ipsum.name %}'
		}
	},
	repetitions : {
		'children' : 3
	}
});
// Outputs
{
	"name": "<NAME>",
	"children": [
		{
			"name": "Mr. <NAME>"
		},
		{
			"name": "<NAME>"
		},
		{
			"name": "<NAME>"
		}
	]
}
```

This also works for deep nested paths.

```
grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}',
		children : {
			child_name : '{%= ipsum.name %}',
			friends : {
				friend_name : '{%= ipsum.name %}'
			}
		}
	},
	repetitions : {
		'children' : 2,
		'children.friends' : 3
	}
});
// Outputs
{
	"name": "<NAME>",
	"children": [
		{
			"child_name": "Ms. <NAME>",
			"friends": [
				{
					"friend_name": "<NAME>"
				},
				{
					"friend_name": "<NAME>"
				},
				{
					"friend_name": "<NAME>"
				}
			]
		},
		{
			"child_name": "<NAME>",
			"friends": [
				{
					"friend_name": "Mrs. <NAME>"
				},
				{
					"friend_name": "<NAME>"
				},
				{
					"friend_name": "<NAME>"
				}
			]
		}
	]
```

As with the `repeat` option, if the value is an array, a random number will be chosen between the two values.

```
grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}',
		children : {
			name : '{%= ipsum.name %}'
		}
	},
	repetitions : {
		'children' : [1, 10]
	}
});
// Outputs
{
	"name": "<NAME>",
	"children": [ // 1 to 10 children
		{
			"name": "Mr. <NAME>"
		},
		// ...
		{
			"name": "<NAME>"
		}
	]
}
```

{'fraction_non_alphanumeric': 0.20617367054524474, 'fraction_numerical': 0.007212231945379364, 'mean_word_length': 3.5454545454545454, 'pattern_counts': {'":': 52, '<': 224, '<?xml version=': 0, '>': 226, 'https://': 13, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1105645', 'n_tokens_mistral': 4545, 'n_tokens_neox': 4168, 'n_words': 857}