Sign in to edit and +1 items.
Login required
Download

Faker Plugin

(1)
Author(s) Eric Berry
Current Release 0.5   (2 weeks ago)
Grails Version 2.0 > *
License(s) Apache License 2.0
Tags
Dependency
compile ":faker:0.5"
Brief summary/description of the plugin.
Last updated by cavneb 2 years ago
grails install-plugin faker
Last updated by cavneb 2 years ago

faker

Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc. This plugin is a port developed in ruby, found at http://faker.rubyforge.org.

Installation

Execute the following from your application directory:

$ grails install-plugin faker

Usage

def fakerService // instanciate the service

fakerService.name() => "Bob Hope"

Available service methods

/* -- HELPERS -- */
println fakerService.numerify('#####')         => 22415
println fakerService.letterify('??? ???')      => cfo mpu
println fakerService.bothify('##? ?##')        => 40h l06

/* -- NAME -- */ println fakerService.name() => Matilde Deckow println fakerService.firstName() => Ernest println fakerService.lastName() => Gutkowski

/* -- ADDRESS -- */ println fakerService.streetAddress() => 237 Ludwig Station println fakerService.streetName() => Candido Dale println fakerService.secondaryAddress() => Apt. 589 println fakerService.city() => Lake Buster println fakerService.usState() => West Virginia println fakerService.usStateAbbr() => MI println fakerService.zipCode() => 31685 println fakerService.ukCounty() => West Sussex println fakerService.ukCountry() => Northern Ireland println fakerService.ukPostcode() => JJ40 9EW

/* -- COMPANY -- */ println fakerService.companyName() => Eichmann-Marks println fakerService.companyCatchPhrase() => Expanded contextually-based paradigm println fakerService.companyBS() => visualize cross-media schemas println fakerService.occupation() => Gynecologist

/* -- INTERNET -- */ println fakerService.email() => malinda_bartoletti@veum-toy.uk println fakerService.email('Joe Blow') => joe_blow@kuhn-fahey.info println fakerService.freeEmail() => nova_kovacek@gmail.com println fakerService.freeEmail('Joe Blow') => joe.blow@gmail.com println fakerService.userName() => odessa println fakerService.userName('Joe Blow') => joe_blow println fakerService.domainName() => orn.info

/* -- LOREM -- */ println fakerService.sentence(3) => Quas dolor culpa rerum tempora autem. println fakerService.paragraph(3) => Et sint aliquid cum quas tempore tempora labore fuga. Voluptatem et saepe eaque illum. Voluptas eius explicabo eos at qui in saepe quis.

/* -- PHONE -- */ println fakerService.phoneNumber() => (535)286-9804 x571 println fakerService.phoneNumber('##########') => 1698340636

/* -- VERSION -- */ println fakerService.version() => 3.2.1

License

This code is free to use under the terms of the MIT license.

Contact

Comments are welcome. Send an email to eric at teachmetocode.com.

Version History

  • 0.2 - Fixed bug with domain names including commas and apostrophes. Thanks to Mike Hugo for the fix code.
  • 0.1 - Initial Release
Last updated by admin 2 years ago
Last updated by admin 2 years ago