Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-ipsum

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-ipsum

Generate fake data, lorem ipsum, and placeholder images as JSON.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

grunt-ipsum Build Status Code Climate

Generate lots of fake data.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-ipsum --save-dev

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

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 guide.

Options

dest String

Path to save output file.

grunt.config('ipsum.mytask', {
	dest : 'path/to/file.json'
});
template Object|Array

The schema of fake data to generate.

For all available keys, see the docs below.

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 and underscore.string helpers are available in this context.

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.

grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}',
		slug : '{%= _.slugify(self.name) %}',
		notyetdefined : '{%= self.after %}',
		after : 'needs to be before notyetdefined'
	}
});
// Output
{
	"name": "Stephen Abshire",
	"slug": "stephen-abshire",
	"notyetdefined": "",
	"after": "needs to be before notyetdefined"
}
repeat Number|Array

The number of times to repeat the template.

grunt.config('ipsum.mytask', {
	template : {
		name : '{%= ipsum.name %}'
	},
	repeat : 5
});
// Outputs
[
	{
		"name": "Lori Hegmann"
	},
	{
		"name": "Vernie Deckow"
	},
	{
		"name": "Karlee Schowalter"
	},
	{
		"name": "Mya Hahn"
	},
	{
		"name": "Colin Strosin"
	}
]

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": "Lori Hegmann"
	},
	// ...
	{
		"name": "Colin Strosin"
	}
]
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": "Rosanna Predovic",
	"children": [
		{
			"name": "Mr. Karlie Jast"
		},
		{
			"name": "Sabina Hoppe"
		},
		{
			"name": "Jordon Friesen"
		}
	]
}

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": "Johnnie Kutch",
	"children": [
		{
			"child_name": "Ms. Charlene Jacobi",
			"friends": [
				{
					"friend_name": "Martin Hilpert"
				},
				{
					"friend_name": "Price Murray"
				},
				{
					"friend_name": "Jermain Mosciski"
				}
			]
		},
		{
			"child_name": "Barrett Connelly",
			"friends": [
				{
					"friend_name": "Mrs. Ethel Cremin"
				},
				{
					"friend_name": "Weldon Muller"
				},
				{
					"friend_name": "Aurelia Parisian"
				}
			]
		}
	]

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": "Rosanna Predovic",
	"children": [ // 1 to 10 children
		{
			"name": "Mr. Karlie Jast"
		},
		// ...
		{
			"name": "Jordon Friesen"
		}
	]
}

Template keys and examples

Much of the data here is generated by Marak/Faker.js.

Users

KeyExamples
nameMaeve Homenick, Owen Mraz, Bernardo Grimes
firstNameBraxton, Susana, Marcelle
lastNameKuphal, Hand, Effertz
phoneNumber003-273-1853 x1157, 847.322.7960, 357.014.4721
phoneNumberFormat(0)979-083-1591, 213-279-0050, 909-907-7814
phoneNumberFormat(1)(012)512-0615, (946)971-1172, (572)007-5316
phoneNumberFormat(2)1-976-102-1694, 1-961-173-9743, 1-247-057-0318
emailCarolyn@frederick.biz, Lukas@katarina.me, Reuben.Kuhlman@joesph.name
userNameAlek, Santina_Streich, Vallie.Morar

Companies

KeyExamples
domainNamebreanne.biz, flo.ca, susie.io
domainWordnayeli, ottilie, joany
ip70.107.229.179, 40.84.165.142, 200.31.231.91
companyNameErdman, Dietrich and Schamberger
Kulas-Moore
Dare-Pfeffer
companySuffixand Sons, Group, LLC
catchPhrasePersistent executive service-desk
Sharable motivating standardization
Face to face global knowledge base
bswhiteboard synergistic web-readiness
enhance web-enabled schemas
reintermediate wireless systems

Addresses

KeyExamples
streetAddress220 Marks Plain
928 Hyatt Place
46420 Cornell Row
secondaryAddressApt. 241, Suite 081, Apt. 883
cityLuciennetown, South Kiana, Gibsonstad
usStateNew Hampshire, Oklahoma, Kentucky
brStateCeará, Distrito Federal, Pernambuco
ukCountySurrey, Derbyshire, West Midlands
ukCountryScotland, England, Wales
zipCode39368-1361, 35290, 62938-6427
zipCodeFormat(0)10812, 37427, 17078
zipCodeFormat(1)49563-3194, 72511-9477, 40840-7183
latitude-56.8358, 79.0189, 28.3439
longitude14.0440, 137.2489, -108.3675

Images

Each of the image options can accept two parameters, width and height.

grunt.config('ipsum.mytask', {
	template : {
		thumb : '{%= ipsum.placeKitten(400, 300) %}'
	}
});
// Outputs
{
	"thumb": "http://placekitten.com/400/300"
}

If an array is used, a number will be chosen within that range.

grunt.config('ipsum.mytask', {
	template : {
		thumb : '{%= ipsum.placeKitten([10, 40], [500, 600]) %}'
	}
});
// Outputs
{
	"thumb": "http://placekitten.com/23/574"
}

The range defaults to [100, 500].

grunt.config('ipsum.mytask', {
	template : {
		thumb : '{%= ipsum.placeKitten %}'
	}
});
// Outputs
{
	"thumb": "http://placekitten.com/246/437"
}
KeyExamples
niceNicehttp://nicenicejpg.com/160/90
niceNiceMustanghttp://nicenicejpg.com/5.0/160/90
fillMurrayhttp://fillmurray.com/160/90
fillMurrayBwhttp://fillmurray.com/g/160/90
placeCagehttp://placecage.com/160/90
placeCageBwhttp://placecage.com/g/160/90
placeCageCrazyhttp://placecage.com/c/160/90
placeBearhttp://placebear.com/160/90
placeBearBwhttp://placebear.com/g/160/90
placeDoghttp://placedog.com/160/90
placeDogBwhttp://placedog.com/g/160/90
placeKittenhttp://placekitten.com/160/90
placeKittenBwhttp://placekitten.com/g/160/90
placeZombiehttp://placezombies.com/160x90
placeZombieBwhttp://placezombies.com/g/160x90
placeSheenhttp://placesheen.com/160/90
baconMockuphttp://baconmockup.com/160/90
loremPixelhttp://lorempixel.com/160/90
loremPixelAbstracthttp://lorempixel.com/160/90/abstract
loremPixelAnimalshttp://lorempixel.com/160/90/animals
loremPixelBusinesshttp://lorempixel.com/160/90/business
loremPixelCatshttp://lorempixel.com/160/90/cats
loremPixelCityhttp://lorempixel.com/160/90/city
loremPixelFoodhttp://lorempixel.com/160/90/food
loremPixelNightlifehttp://lorempixel.com/160/90/nightlife
loremPixelFashionhttp://lorempixel.com/160/90/fashion
loremPixelPeoplehttp://lorempixel.com/160/90/people
loremPixelNaturehttp://lorempixel.com/160/90/nature
loremPixelSportshttp://lorempixel.com/160/90/sports
loremPixelTechnicshttp://lorempixel.com/160/90/technics
loremPixelTransporthttp://lorempixel.com/160/90/transport
loremPixelBwhttp://lorempixel.com/g/160/90
loremPixelAbstractBwhttp://lorempixel.com/g/160/90/abstract
loremPixelAnimalsBwhttp://lorempixel.com/g/160/90/animals
loremPixelBusinessBwhttp://lorempixel.com/g/160/90/business
loremPixelCatsBwhttp://lorempixel.com/g/160/90/cats
loremPixelCityBwhttp://lorempixel.com/g/160/90/city
loremPixelFoodBwhttp://lorempixel.com/g/160/90/food
loremPixelNightlifeBwhttp://lorempixel.com/g/160/90/nightlife
loremPixelFashionBwhttp://lorempixel.com/g/160/90/fashion
loremPixelPeopleBwhttp://lorempixel.com/g/160/90/people
loremPixelNatureBwhttp://lorempixel.com/g/160/90/nature
loremPixelSportsBwhttp://lorempixel.com/g/160/90/sports
loremPixelTechnicsBwhttp://lorempixel.com/g/160/90/technics
loremPixelTransportBwhttp://lorempixel.com/g/160/90/transport

Keywords

FAQs

Package last updated on 19 Nov 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc