NAME
Faker::Maker
ABSTRACT
Abstract Base Class for Faker
SYNOPSIS
package Example;
use Data::Object::Class;
with 'Faker::Maker';
package main;
my $example = Example->new;
DESCRIPTION
This package provides provides methods for generating and selecting random data.
LIBRARIES
This package uses type constraints from:
METHODS
This package implements the following methods:
format_lex_markers
format_lex_markers(Str $string) : Str
The format_lex_markers method replaces each ?
character in the string with a random letter.
format_line_markers
format_line_markers(Str $string) : Str
The format_line_markers method replaces each escaped \n
(newline) character in the string with a proper newline character.
format_number_markers
format_number_markers(Str $string) : Str
The format_number_markers method replaces each #
in the string with a random digit, and each %
with a random non-zero digit.
parse_format
parse_format(Str $string) : Str
The parse_format method replaces each {{plugin.name}}
in the string with the result of the evaluation of the plugin specified in the token, e.g. {{person.name}}
is replaced with the result of executing the Faker::Plugin::PersonName plugin.
process
process(Tuple[Str, Str] $lookup, Maybe[HashRef[Int]] $options) : Str
The process method performs a lookup and replacement in the lookup results based on the options specified. Valid options are all_markers
, lex_markers
, line_markers
, and number_markers
.
- process example #1
-
# given: synopsis $example->process(['person', 'username'], { all_markers => 1 })
process_format
process_format(Str $format) : Str
The process_format method dispatches to a plugin or performs a lookup and returns the result.
process_lookup
process_lookup(Tuple[Str, Str] $lookup) : Str
The process_lookup method performs a lookup and returns the result.
process_markers
process_markers(Str $string) : Str
The process_markers method replaces all markers, e.g. ?
, #
, %
, with their random character counterparts.
random_array_item
random_array_item(ArrayRef $items) : Any
The random_array_item method returns a random element from the arrayref
provided.
random_between
random_between(Maybe[Int] $from, Maybe[Int] $to) : Int
The random_between method returns a random number between the integers provided, or between 0
and 2147483647
.
random_digit
random_digit() : Int
The random_digit method returns a random digit betwee 0
and 10
.
random_digit_not_zero
random_digit_not_zero() : Int
The random_digit_not_zero method returns a random digit betwee 1
and 10
.
random_float
random_float(Maybe[Int] $place, Maybe[Int] $min, Maybe[Int] $max) : Num
The random_float method returns a random floating-point number between the integers provided.
random_hash_item
random_hash_item(HashRef $items) : Any
The random_hash_item method returns a random element from the hashref
provided.
random_item
random_item(ArrayRef | HashRef $items) : Any
The random_item method returns a random element from the arrayref
or hashref
provided.
random_letter
random_letter() : Str
The random_letter method returns a random alphabetic character.
random_number
random_number() : Num
The random_number method returns a random number.
AUTHOR
Al Newkirk, awncorp@cpan.org
LICENSE
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
ACKNOWLEDGEMENTS
Parts of this library were inspired by the following implementations: