Project

faker-cli

0.0
No commit activity in last 3 years
No release in over 3 years
This tool helps to create a json array of json objects having certain fields and faked values in them.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.6

Runtime

~> 1.4
 Project Readme

Faker::Cli

This tool uses Faker to generate a json array of json objects with special fields and faked values.

Installation

Add this line to your application's Gemfile:

gem 'faker-cli'

And then execute:

$ bundle

Or install it yourself as:

$ gem install faker-cli

Usage

faker-cli [-n NUM-ENTRIES] DEF1 DEF2 ... DEFN

The value for -n defaults to 10. The above command will create -n entries with fields defined by DEF1 to DEFN.

DEF

A DEF has the form

<name>:<Faker-Module>.<Faker-Method>

or

<name>:<Faker-Module>.<Faker-Method>(param1, param2)
  • name is the name of the objects key
  • Faker-Module is the name of the Faker module (e.g. Lorem)
  • Faker-Method is the method of that module (e.g. word)

The string after the : is basically "applied" to the Faker module. So id:Number.positive would actually call Faker::Number.positive() to generate an id-field for one entry.

Other DEFs:

"id:Number.positive(5, 100)"
"text:Lorem.words(5)"
"created_at:Date.forward"

Usage Examples

faker-cli 50 "id:Number.positive"\
  "filename:Lorem.words(2)"\
  "filesize:Number.between(150, 700)"\
  "created_at:Date.backward"\
  "modified_at:Date.backward"\
  "directory_id:Number.positive(2, 6)"

Will output a json array of 50 json objects that look like:

{
    "id": 1136,
    "filename": "rem necessitatibus",
    "filesize": 300,
    "directory_id": 4,
    "created_at": "2013-09-25",
    "modified_at": "2014-07-14"
}

Contributing

  1. Fork it ( https://github.com/ohcibi/faker-cli/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request