File Coverage

blib/lib/EPL2/Types.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package EPL2::Types;
2             # ABSTRACT: EPL2::Types (Library for EPL2 types)
3             $EPL2::Types::VERSION = '0.001';
4              
5             # predeclare our own types
6 7     7   1071 use MooseX::Types -declare => [qw/Natural Positive Rotation Font Mult Reverse Human Text Barcode Padwidth Padheight/];
  7         308047  
  7         54  
7              
8             # import builtin types
9 7     7   37359 use MooseX::Types::Moose qw/Int Str/;
  7         9467  
  7         40  
10              
11             # declare our constants
12 7     7   21518 use constant { MAX_PADWIDTH => 832, MAX_PADHEIGHT => 65535 };
  7         8  
  7         5148  
13              
14             # type definition.
15             subtype Natural,
16             as Int,
17             where { $_ >= 0 },
18             message { "Value($_) is not Natural [ 0, 1, 2, 3, 4, ... ]" };
19              
20             subtype Positive,
21             as Int,
22             where { $_ >= 1 },
23             message { "Value($_) is not Positive [ 1, 2, 3, 4, ... ]" };
24              
25             subtype Rotation,
26             as Natural,
27             where { $_ < 4 },
28             message { "Value($_) is not a Rotation [ 0, 1, 2, 3 ]" };
29              
30             subtype Font,
31             as Natural,
32             where { $_ > 0 && $_ < 6 },
33             message { "Value($_) is not a Font [ 1, 2, 3, 4, 5 ]" };
34              
35             subtype Mult,
36             as Natural,
37             where { $_ > 0 && $_ < 10 },
38             message { "Value($_) is not a Mult [ 1 - 9 ]" };
39              
40             subtype Reverse,
41             as Str,
42             where { /^(N|R)$/ },
43             message { "Value($_) is not a Reverse [ N, R ]" };
44              
45             subtype Text,
46             as Str,
47             where { /^".+"$/ || /^V\d[1-9]$/ || /^C\d$/ || /^T(T|D)$/ },
48             message { "Value($_) is not Text -- Literal Text \"\" or Variable V01-V99 or Counter C0-C9 or TimeCode [TT, TD]" };
49              
50             subtype Human,
51             as Str,
52             where { /^(B|N)$/ },
53             message { "Value($_) is not Human [ B, N ]" };
54              
55             subtype Barcode,
56             as Str,
57             where {
58             /^(0|K|P|J|L|M)$/
59             || /^1(A|B|C|E)?$/
60             || /^2(C|D|G|U)?$/
61             || /^3C?$/
62             || /^E(80|82|85|30|32|35)$/
63             || /^U(A0|A2|A5|E0|E2|E5)$/
64             },
65             message { "Value($_) is not Barcode Type" };
66              
67             subtype Padwidth,
68             as Natural,
69             where { $_ <= MAX_PADWIDTH },
70             message { "Value($_) is not < " . MAX_PADWIDTH };
71              
72             subtype Padheight,
73             as Natural,
74             where { $_ <= MAX_PADHEIGHT },
75             message { "Value($_) is not < " . MAX_PADHEIGHT };
76              
77              
78             1;
79              
80             __END__
81              
82             =pod
83              
84             =encoding UTF-8
85              
86             =head1 NAME
87              
88             EPL2::Types - EPL2::Types (Library for EPL2 types)
89              
90             =head1 VERSION
91              
92             version 0.001
93              
94             =head1 SEE ALSO
95              
96             L<EPL2>
97              
98             =head1 AUTHOR
99              
100             Ted Katseres <tedkat@cpan.org>
101              
102             =head1 COPYRIGHT AND LICENSE
103              
104             This software is copyright (c) 2016 by Ted Katseres.
105              
106             This is free software; you can redistribute it and/or modify it under
107             the same terms as the Perl 5 programming language system itself.
108              
109             =cut