Faker::Plugin

Fake Data Plugin

Fake Data Plugin Base

method: new method: execute method: process method: process_format method: process_markers method: resolve

package main;

use Faker::Plugin;

my $plugin = Faker::Plugin->new;

# bless(..., "Faker::Plugin")

# my $result = $plugin->execute;

# ""

This distribution provides a library of fake data generators and a framework for extending the library via plugins.

+=encoding utf8

Venus::Role::Buildable Venus::Role::Optional

The faker attribute holds the Faker object.

faker(Object $data) (Object)

{ since => '1.10', }

=example-1 faker

# given: synopsis

package main;

my $faker = $plugin->faker;

# bless(..., "Faker")

The execute method should be overridden by a plugin subclass, and should generate and return a random string.

execute(HashRef $data) (Str)

{ since => '1.10', }

=example-1 execute

# given: synopsis

package main;

my $data = $plugin->execute;

# ""

The new method returns a new instance of the class.

new(HashRef $data) (Plugin)

{ since => '1.10', }

=example-1 new

package main;

use Faker::Plugin;

my $plugin = Faker::Plugin->new;

# bless(... "Faker::Plugin")

The process method accepts a data template and calls "process_format" and "process_markers" with the arguments provided and returns the result.

process(Str $data) (Str)

{ since => '1.10', }

=example-1 process

# given: synopsis

package main;

$plugin->faker->locales(['en-us']);

my $process = $plugin->process('@?{{person_last_name}}####');

# "\@ZWilkinson4226"

The process_format method accepts a data template replacing any tokens found with the return value from "resolve".

process_format(Str $data) (Str)

{ since => '1.10', }

=example-1 process_format

# given: synopsis

package main;

my $process_format = $plugin->process_format('Version {{software_version}}');

# "Version 0.78"

The process_markers method accepts a string with markers, replaces the markers (i.e. special symbols) and returns the result. This method also, optionally, accepts a list of the types of replacements to be performed. The markers are: # (see "digit" in Venus::Random), % (see "nonzero" in Venus::Random), ? (see "letter" in Venus::Random), and \n. The replacement types are: "letters", "numbers", and "newlines".

process_markers(Str $data, Str @types) (Str)

{ since => '1.10', }

=example-1 process_markers

# given: synopsis

package main;

my $process_markers = $plugin->process_markers('Version %##');

# "Version 342"

The resolve method replaces tokens from "process_format" with the return value from their corresponding plugins.

resolve(Str $name) (Str)

{ since => '1.10', }

=example-1 resolve

# given: synopsis

package main;

my $color_hex_code = $plugin->resolve('color_hex_code');

# "#adfc4b"

This package is meant to be subclassed.

t/Faker.t: pdml: authors t/Faker.t: pdml: license

40 POD Errors

The following errors were encountered while parsing the POD:

Around line 13:

Unknown directive: =name

Around line 21:

Unknown directive: =tagline

Around line 29:

Unknown directive: =abstract

Around line 37:

Unknown directive: =includes

Around line 50:

Unknown directive: =synopsis

Around line 74:

Unknown directive: =description

Around line 85:

Unknown directive: =integrates

Around line 94:

Unknown directive: =attribute

Around line 98:

Unknown directive: =signature

Around line 102:

Unknown directive: =metadata

Around line 138:

=cut found outside a pod block. Skipping to next block.

Around line 160:

=cut found outside a pod block. Skipping to next block.

Around line 170:

Unknown directive: =method

Around line 175:

Unknown directive: =signature

Around line 179:

Unknown directive: =metadata

Around line 204:

Unknown directive: =method

Around line 208:

Unknown directive: =signature

Around line 212:

Unknown directive: =metadata

Around line 249:

=cut found outside a pod block. Skipping to next block.

Around line 273:

=cut found outside a pod block. Skipping to next block.

Around line 286:

Unknown directive: =method

Around line 291:

Unknown directive: =signature

Around line 295:

Unknown directive: =metadata

Around line 322:

Unknown directive: =method

Around line 327:

Unknown directive: =signature

Around line 331:

Unknown directive: =metadata

Around line 356:

Unknown directive: =method

Around line 365:

Unknown directive: =signature

Around line 369:

Unknown directive: =metadata

Around line 404:

=cut found outside a pod block. Skipping to next block.

Around line 423:

=cut found outside a pod block. Skipping to next block.

Around line 442:

=cut found outside a pod block. Skipping to next block.

Around line 451:

Unknown directive: =method

Around line 456:

Unknown directive: =signature

Around line 460:

Unknown directive: =metadata

Around line 495:

=cut found outside a pod block. Skipping to next block.

Around line 514:

=cut found outside a pod block. Skipping to next block.

Around line 523:

Unknown directive: =feature

Around line 553:

=cut found outside a pod block. Skipping to next block.

Around line 562:

Unknown directive: =partials