| 1 | package Boxer::Types; | ||
| 2 | |||
| 3 | =encoding UTF-8 | ||
| 4 | |||
| 5 | =cut | ||
| 6 | |||
| 7 | 6 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 6 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 6 | ▶ | use Role::Commons -all; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 6 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 6 | ▶ | use Path::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 6 | ▶ | use Type::Library -base, -declare => qw( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 6 | WorldName DataDir ClassDir NodeDir SkelDir Basename Suite SerializationList ); | |
| 16 | 6 | ▶ | use Type::Utils; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 6 | ▶ | use Types::Standard qw( ArrayRef Split Str Tuple StrMatch slurpy ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 6 | ▶ | use Types::Common::String qw( NonEmptySimpleStr LowerCaseSimpleStr ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 6 | ▶ | use Types::Path::Tiny qw(Dir); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | |||
| 21 | 6 | ▶ | use strictures 2; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 6 | ▶ | no warnings "experimental::signatures"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | =head1 VERSION | ||
| 25 | |||
| 26 | Version v1.4.3 | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | 6 | our $VERSION = "v1.4.3"; | |
| 31 | |||
| 32 | declare WorldName, as LowerCaseSimpleStr, | ||
| 33 | coercion => 1, | ||
| 34 | 0 | ▶ | message {'Must be a single lowercase word'}; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 35 | |||
| 36 | 0 | ▶ | declare DataDir, as Dir, coercion => 1, message { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 37 | 0 | 'Must be an existing directory containing directories for boxer classes and/or boxer nodes'; | |
| 38 | 6 | }; | |
| 39 | |||
| 40 | declare ClassDir, as Dir, | ||
| 41 | coercion => 1, | ||
| 42 | 2 | ▶ | message {'Must be an existing directory containing boxer classes'}; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 43 | |||
| 44 | declare NodeDir, as Dir, | ||
| 45 | coercion => 1, | ||
| 46 | 1 | ▶ | message {'Must be an existing directory containing boxer nodes'}; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 47 | |||
| 48 | declare SkelDir, as Dir, | ||
| 49 | coercion => 1, | ||
| 50 | 0 | ▶ | message {'Must be an existing directory containing boxer skeleton files'}; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 51 | |||
| 52 | declare Basename, as NonEmptySimpleStr, | ||
| 53 | 32 | ▶ | where { $_ eq path($_)->basename }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 54 | 0 | ▶ | message {'Must be a bare filename with no directory parts'}; |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 55 | |||
| 56 | declare Suite, as LowerCaseSimpleStr, | ||
| 57 | coercion => 1, | ||
| 58 | 1 | ▶ | message {'Must be a single lowercase word'}; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 59 | |||
| 60 | 6 | my $SerializationList = "Type::Tiny"->new( | |
| 61 | name => 'SerializationList', | ||
| 62 | parent => | ||
| 63 | Tuple [ slurpy ArrayRef [ StrMatch [qr{^(?:preseed|script)$}] ] ], | ||
| 64 | ); | ||
| 65 | declare SerializationList, | ||
| 66 | as $SerializationList->plus_coercions( Split [qr/[^a-z]+/] ), | ||
| 67 | coercion => 1, | ||
| 68 | 1 | ▶ | message {'Must be one or more of these words: preseed script'}; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 69 | |||
| 70 | =head1 AUTHOR | ||
| 71 | |||
| 72 | Jonas Smedegaard C<< <dr@jones.dk> >>. | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | 6 | our $AUTHORITY = 'cpan:JONASS'; | |
| 77 | |||
| 78 | =head1 COPYRIGHT AND LICENCE | ||
| 79 | |||
| 80 | Copyright © 2013-2016 Jonas Smedegaard | ||
| 81 | |||
| 82 | This is free software; you can redistribute it and/or modify it under | ||
| 83 | the same terms as the Perl 5 programming language system itself. | ||
| 84 | |||
| 85 | =head1 DISCLAIMER OF WARRANTIES | ||
| 86 | |||
| 87 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||
| 88 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||
| 89 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | 6 | 1; | |