File Coverage

blib/lib/Color/Palette/Schema.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package Color::Palette::Schema 0.100004;
2 1     1   732 use Moose;
  1         2  
  1         9  
3             # ABSTRACT: requirements for a palette
4              
5 1     1   6965 use Color::Palette;
  1         2  
  1         41  
6 1     1   7 use Color::Palette::Types qw(ColorName);
  1         11  
  1         11  
7 1     1   2589 use MooseX::Types::Moose qw(ArrayRef);
  1         3  
  1         8  
8              
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod Most of this is documented in L<Color::Palette>. Below is just a bit more
12             #pod documentation.
13             #pod
14             #pod =attr required_colors
15             #pod
16             #pod This is an arrayref of color names that must be present in any palette checked
17             #pod against this schema.
18             #pod
19             #pod =cut
20              
21             has required_colors => (
22             is => 'ro',
23             isa => ArrayRef[ ColorName ],
24             required => 1,
25             );
26              
27             #pod =method check
28             #pod
29             #pod $schema->check($palette);
30             #pod
31             #pod This method will throw an exception if the given palette doesn't meet the
32             #pod requirements of the schema.
33             #pod
34             #pod =cut
35              
36             sub check {
37 1     1 1 303 my ($self, $palette) = @_;
38              
39             # ->color will throw an exception on unknown colors, doing our job for us.
40             # -- rjbs, 2009-05-19
41 1         2 $palette->color($_) for @{ $self->required_colors };
  1         33  
42             }
43              
44             1;
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Color::Palette::Schema - requirements for a palette
55              
56             =head1 VERSION
57              
58             version 0.100004
59              
60             =head1 DESCRIPTION
61              
62             Most of this is documented in L<Color::Palette>. Below is just a bit more
63             documentation.
64              
65             =head1 PERL VERSION
66              
67             This library should run on perls released even a long time ago. It should work
68             on any version of perl released in the last five years.
69              
70             Although it may work on older versions of perl, no guarantee is made that the
71             minimum required version will not be increased. The version may be increased
72             for any reason, and there is no promise that patches will be accepted to lower
73             the minimum required perl.
74              
75             =head1 ATTRIBUTES
76              
77             =head2 required_colors
78              
79             This is an arrayref of color names that must be present in any palette checked
80             against this schema.
81              
82             =head1 METHODS
83              
84             =head2 check
85              
86             $schema->check($palette);
87              
88             This method will throw an exception if the given palette doesn't meet the
89             requirements of the schema.
90              
91             =head1 AUTHOR
92              
93             Ricardo SIGNES <cpan@semiotic.systems>
94              
95             =head1 COPYRIGHT AND LICENSE
96              
97             This software is copyright (c) 2022 by Ricardo SIGNES.
98              
99             This is free software; you can redistribute it and/or modify it under
100             the same terms as the Perl 5 programming language system itself.
101              
102             =cut