NAME
Data::ObjectGenerator - The great new Data::ObjectGenerator!
VERSION
Version 0.0.1
SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
use Data::ObjectGenerator;
my $Tmp = Data::ObjectGenerator->Template;
my $template = {
"user_id" => $Tmp->Number(50, 100),
"user_name" => $Tmp->String('Cccnnnnn'),
"time" => $Tmp->Number(time - 3600 * 24 * 7, time),
"type" => $Tmp->Enum('hoge', 'fuga', 'piyo'),
"tag" => "sample",
"register_hour" => $Tmp->Number(time - 3600 * 24 * 7, time, 3600),
"average" => $Tmp->Number(100, 500, undef, 1),
};
my $generator = new Data::ObjectGenerator->new(template => $template);
# or
my $generator = new Data::ObjectGenerator->new(file => "./template.json");
my $onedata = $generator->one();
my $data = $generator->gen(1000);
$data = $generator->pat({"user_id" => [1, 2, 3, 4, 5, 6], "type" => ["hoge", "fuga", "piyo"]});
SUBROUTINES/METHODS
CLASS METHODS
Data::ObjectGenerator->new( %args ) :Data::ObjectGenerator
Creates and return a new data generator with template described by %args:
my $generator = new Data::ObjectGenerator->new(template => $template);
# or
my $generator = new Data::ObjectGenerator->new(file => "./template.json");
INSTANCE METHODS
$generator->one() :HashRef
Generate sample data objects
my $onedata = $generator->one();
or
my $onedata = $generator->one({"user_id" => 3});
$generator->gen( $num ) :ArrayRef
Generate sample data objects
my $data = $generator->gen(1000);
$generator->pat( $num ) :ArrayRef
Generate sample data objects by all pattern
my $data = $generator->pat({"user_id" => [1, 2], "type" => ["hoge", "fuga", "piyo"]});
on above samples:
{ "user_id" => 1, "type" => "hoge", ...}
{ "user_id" => 2, "type" => "hoge", ...}
{ "user_id" => 1, "type" => "fuga", ...}
{ "user_id" => 2, "type" => "fuga", ...}
{ "user_id" => 1, "type" => "piyo", ...}
{ "user_id" => 2, "type" => "piyo", ...}
AUTHOR
muddydixon, <muddydixon@gmail.com>
BUGS
Please report any bugs or feature requests to bug-nifty-nirvana-samplegen at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=NIFTY-Nirvana-SampleGen. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Data::ObjectGenerator
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=NIFTY-Nirvana-SampleGen
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2012 muddydixon.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.