NAME
Mock::Data::Plugin::Text - Mock::Data plugin that provides text-related generators
SYNOPSIS
my $mockdata= Mock::Data->new(['Text']);
# Strings of /(\w+ )+/
$mockdata->words($len) # up to $size characters
# classic boilerplate
$mockdata->lorem_ipsum($len)
# Build strings of words
$mockdata->join({ source => '{lorem_ipsum}', sep => '<p>', count => 5 });
DESCRIPTION
This plugin for Mock::Data generates simple text patterns. It may be expanded to support multiple languages in the future.
GENERATORS
join
$mockdata->join( $sep, $source, $count ); # concatenate strings from generators
$mockdata->join( \%options );
This generator concatenates the output of other generators. If the generators return arrays, the elements will become part of the list to concatenate. The generator can either concatenate everything, or concatenate up to a size limit, calling the generators repeatedly until it reaches the goal.
- sep
-
The separator; defaults to a space.
- source
-
One or more generators. They will be coerced to generators if they are not already. If this is an arrayref, it will be considered as a list of generators and not coerced into a uniform_set.
- count
-
The number of times to call each generator. This defaults to 1.
- len
-
The string length goal. The generators will be called repeatedly until this lenth is reached.
- max_len
-
The string length maximum. If the output is longer than this, it will be truncated, and the final separator will be removed if the string would otherwise end with a separator.
word
$mockdata->word;
This generator returns one "word" which is roughly /\w{1,11}/a
but distributed more heavily around 5 characters.
words
$mockdata->words($max_len);
This is an alias for ->join({ source => '{word}', len => $max_len, max_len => $max_len })
. It takes the same named options as "join", but if a positional parameter is given, it specifies $len
and $max_len
.
lorem_ipsum
$mockdata->lorem_ipsum($len)
$mockdata->lorem_ipsum({ len => $len })
Repetitions of the classic 1500's Lorem Ipsum text up to length len
The default length is one iteration of the string.
AUTHOR
Michael Conrad <mike@nrdvana.net>
VERSION
version 0.04
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.