0.2.1 • Published 9 years ago

gennifer v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Deps

  npm install

Usage & installation

As a module

  npm install gennifer --save
  var gennifer = require( 'gennifer' )();
  var tweetTmpl = function() {
    return {
      user: '@recursivefunk',
      text: 'I am the one'
    };
  };

  gennifer.registerTemplate( 'tweet', tweetTmpl );

  // generate a data item
  var item = gennifer.generate( 'tweet' );

  // use a stream

  gennifer
    // optional
    .channel( anEventEmitter )
    // will return the genrated data and automatically emit the new data
    .pipeGen( 'tweet' );

Loading templates from a file

  // in templates.js

  // casual is the preferred underlying data generator but you can generate
  // data with your templates in any manner you wish
  var casual = require('casual');

  module.exports = {
    aTemplate: function() {
      return {
        dateFoo: casual.date,
        aName: casual.name
      }
    }
  }

  // later...
  gennifer.loadTemplates( './templates.js' );
  var templates = gennifer.templates();
  console.log( templates );
  // { aTemplate: [Function] }

As a standalone-socket server

  [sudo] npm install -g gennifer
  genneifer [ -f 1000 -v 1 -p 8080 -t ]

Just type

  genneifer -h

For available options

Streams

Gennifer is also a native nodejs stream.

    gennifer
      .on('data', function( items ){
        // do something perhaps
      })
      .pipeGen( 'tmpl1' )
      .pipe( process.stdout );    

Run Tests

You'll need to have redis running locally for all tests to pass

  npm test

To Do

Check the issues section

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago