| 1 | package Faker::Plugin::ColorHexCode; | ||
| 2 | |||
| 3 | use 5.014; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | use registry; | ||
| 9 | use routines; | ||
| 10 | |||
| 11 | use Data::Object::Class; | ||
| 12 | use Data::Object::ClassHas; | ||
| 13 | |||
| 14 | extends 'Data::Object::Plugin'; | ||
| 15 | |||
| 16 | our $VERSION = '1.03'; # VERSION | ||
| 17 | |||
| 18 | # ATTRIBUTES | ||
| 19 | |||
| 20 | has 'faker' => ( | ||
| 21 | is => 'ro', | ||
| 22 | isa => 'ConsumerOf["Faker::Maker"]', | ||
| 23 | req => 1, | ||
| 24 | ); | ||
| 25 | |||
| 26 | # METHODS | ||
| 27 | |||
| 28 | method execute() { | ||
| 29 | my $faker = $self->faker; | ||
| 30 | my $number = $faker->random_between(1, 16777215); | ||
| 31 | |||
| 32 | return '#' . sprintf('%06s', sprintf('%02x', $number)); | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; | ||
| 36 | |||
| 37 | =encoding utf8 | ||
| 38 | |||
| 39 | =head1 NAME | ||
| 40 | |||
| 41 | Faker::Plugin::ColorHexCode | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | =head1 ABSTRACT | ||
| 46 | |||
| 47 | Color Hex Code Plugin for Faker | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | =head1 SYNOPSIS | ||
| 52 | |||
| 53 | package main; | ||
| 54 | |||
| 55 | use Faker; | ||
| 56 | use Faker::Plugin::ColorHexCode; | ||
| 57 | |||
| 58 | my $f = Faker->new; | ||
| 59 | my $p = Faker::Plugin::ColorHexCode->new(faker => $f); | ||
| 60 | |||
| 61 | my $plugin = $p; | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | =head1 DESCRIPTION | ||
| 66 | |||
| 67 | This package provides methods for generating fake color hex code data. | ||
| 68 | |||
| 69 | =cut | ||
| 70 | |||
| 71 | =head1 INHERITS | ||
| 72 | |||
| 73 | This package inherits behaviors from: | ||
| 74 | |||
| 75 | L<Data::Object::Plugin> | ||
| 76 | |||
| 77 | =cut | ||
| 78 | |||
| 79 | =head1 LIBRARIES | ||
| 80 | |||
| 81 | This package uses type constraints from: | ||
| 82 | |||
| 83 | L<Types::Standard> | ||
| 84 | |||
| 85 | =cut | ||
| 86 | |||
| 87 | =head1 ATTRIBUTES | ||
| 88 | |||
| 89 | This package has the following attributes: | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | =head2 faker | ||
| 94 | |||
| 95 | faker(ConsumerOf["Faker::Maker"]) | ||
| 96 | |||
| 97 | This attribute is read-only, accepts C<(ConsumerOf["Faker::Maker"])> values, and is required. | ||
| 98 | |||
| 99 | =cut | ||
| 100 | |||
| 101 | =head1 METHODS | ||
| 102 | |||
| 103 | This package implements the following methods: | ||
| 104 | |||
| 105 | =cut | ||
| 106 | |||
| 107 | =head2 execute | ||
| 108 | |||
| 109 | execute() : Str | ||
| 110 | |||
| 111 | The execute method returns a random fake color hex code. | ||
| 112 | |||
| 113 | =over 4 | ||
| 114 | |||
| 115 | =item execute example #1 | ||
| 116 | |||
| 117 | # given: synopsis | ||
| 118 | |||
| 119 | $p->execute; | ||
| 120 | |||
| 121 | =back | ||
| 122 | |||
| 123 | =cut | ||
| 124 | |||
| 125 | =head1 AUTHOR | ||
| 126 | |||
| 127 | Al Newkirk, C<awncorp@cpan.org> | ||
| 128 | |||
| 129 | =head1 LICENSE | ||
| 130 | |||
| 131 | Copyright (C) 2011-2019, Al Newkirk, et al. | ||
| 132 | |||
| 133 | This is free software; you can redistribute it and/or modify it under the terms | ||
| 134 | of the The Apache License, Version 2.0, as elucidated in the L<"license | ||
| 135 | file"|https://github.com/iamalnewkirk/faker/blob/master/LICENSE>. | ||
| 136 | |||
| 137 | =head1 ACKNOWLEDGEMENTS | ||
| 138 | |||
| 139 | Parts of this library were inspired by the following implementations: | ||
| 140 | |||
| 141 | L<PHP Faker|https://github.com/fzaninotto/Faker> | ||
| 142 | |||
| 143 | L<Ruby Faker|https://github.com/stympy/faker> | ||
| 144 | |||
| 145 | L<Python Faker|https://github.com/joke2k/faker> | ||
| 146 | |||
| 147 | L<JS Faker|https://github.com/Marak/faker.js> | ||
| 148 | |||
| 149 | L<Elixir Faker|https://github.com/elixirs/faker> | ||
| 150 | |||
| 151 | =head1 PROJECT | ||
| 152 | |||
| 153 | L<Wiki|https://github.com/iamalnewkirk/faker/wiki> | ||
| 154 | |||
| 155 | L<Project|https://github.com/iamalnewkirk/faker> | ||
| 156 | |||
| 157 | L<Initiatives|https://github.com/iamalnewkirk/faker/projects> | ||
| 158 | |||
| 159 | L<Milestones|https://github.com/iamalnewkirk/faker/milestones> | ||
| 160 | |||
| 161 | L<Contributing|https://github.com/iamalnewkirk/faker/blob/master/CONTRIBUTE.md> | ||
| 162 | |||
| 163 | L<Issues|https://github.com/iamalnewkirk/faker/issues> | ||
| 164 | |||
| 165 | =cut |