/usr/share/perl5/Courriel/Types/Internal.pm is in libcourriel-perl 0.45-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | package Courriel::Types::Internal;
use strict;
use warnings;
use namespace::autoclean;
our $VERSION = '0.45';
use List::AllUtils qw( all );
use Scalar::Util qw( blessed );
use MooseX::Types -declare => [
qw(
Body
EmailAddressStr
HeaderArray
Headers
Part
Printable
Streamable
StringRef
)
];
use MooseX::Types::Common::String qw( NonEmptyStr );
use MooseX::Types::Moose
qw( ArrayRef CodeRef FileHandle HashRef Object ScalarRef Str );
#<<<
subtype Body,
as role_type('Courriel::Role::Body');
subtype Headers,
as class_type('Courriel::Headers');
subtype EmailAddressStr,
as NonEmptyStr;
coerce EmailAddressStr,
from class_type('Email::Address'),
via { $_->format };
my $_check_header_array = sub {
return 0 unless @{$_} % 2 == 0;
my ( @even, @odd );
for my $i ( 0 .. $#{$_} ) {
if ( $i % 2 ) {
push @odd, $i;
}
else {
push @even, $i;
}
}
## no critic (ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions)
return 0 unless all { defined $_ && length $_ && !ref $_ } @{$_}[@even];
## use critic;
return 0
unless all { blessed($_) && $_->isa('Courriel::Header') } @{$_}[@odd];
return 1;
};
subtype HeaderArray,
as ArrayRef,
# prototype wants an actual block, not a ref to a sub
&where($_check_header_array),
message { 'The array reference must contain an even number of elements' };
subtype Part,
as role_type('Courriel::Role::Part');
subtype Printable,
as Object,
where { $_->can('print') };
subtype Streamable,
as CodeRef;
coerce Streamable,
from FileHandle,
via sub {
my $fh = $_;
return sub { print {$fh} @_ or die $! };
};
coerce Streamable,
from Printable,
via sub {
my $obj = $_;
return sub { $obj->print(@_) };
};
subtype StringRef,
as ScalarRef[Str];
coerce StringRef,
from Str,
via { my $str = $_; \$str };
#>>>
1;
|