line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sietima::Types; |
2
|
16
|
|
|
16
|
|
100
|
use Sietima::Policy; |
|
16
|
|
|
|
|
28
|
|
|
16
|
|
|
|
|
116
|
|
3
|
16
|
|
|
16
|
|
6723
|
use Type::Utils -all; |
|
16
|
|
|
|
|
63473
|
|
|
16
|
|
|
|
|
133
|
|
4
|
16
|
|
|
16
|
|
43813
|
use Types::Standard qw(Str HashRef Defined Str); |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
84
|
|
5
|
16
|
|
|
16
|
|
20544
|
use namespace::clean; |
|
16
|
|
|
|
|
77027
|
|
|
16
|
|
|
|
|
83
|
|
6
|
|
|
|
|
|
|
use Type::Library |
7
|
16
|
|
|
|
|
104
|
-base, |
8
|
|
|
|
|
|
|
-declare => qw(SietimaObj |
9
|
|
|
|
|
|
|
Address AddressFromStr |
10
|
|
|
|
|
|
|
TagName |
11
|
|
|
|
|
|
|
EmailMIME Message |
12
|
|
|
|
|
|
|
HeaderUri HeaderUriFromThings |
13
|
|
|
|
|
|
|
Subscriber SubscriberFromAddress SubscriberFromStr SubscriberFromHashRef |
14
|
16
|
|
|
16
|
|
6284
|
Transport MailStore MailStoreFromHashRef); |
|
16
|
|
|
|
|
33
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.0.5'; # VERSION |
17
|
|
|
|
|
|
|
# ABSTRACT: type library for Sietima |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
class_type SietimaObj, { class => 'Sietima' }; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
class_type EmailMIME, { class => 'Email::MIME' }; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
role_type Transport, { role => 'Email::Sender::Transport' }; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
role_type MailStore, { role => 'Sietima::MailStore' }; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
declare_coercion MailStoreFromHashRef, |
32
|
|
|
|
|
|
|
to_type MailStore, from HashRef, |
33
|
|
|
|
|
|
|
q{ require Module::Runtime; } . |
34
|
|
|
|
|
|
|
q{ Module::Runtime::use_module(delete $_->{class})->new($_); }; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
class_type Address, { class => 'Email::Address' }; |
38
|
|
|
|
|
|
|
declare_coercion AddressFromStr, |
39
|
|
|
|
|
|
|
to_type Address, from Str, |
40
|
|
|
|
|
|
|
q{ (Email::Address->parse($_))[0] }; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
declare TagName, as Str, |
44
|
|
|
|
|
|
|
where { /\A\w+\z/ }, |
45
|
|
|
|
|
|
|
inline_as sub($constraint,$varname,@){ |
46
|
|
|
|
|
|
|
$constraint->parent->inline_check($varname) |
47
|
|
|
|
|
|
|
.qq{ && ($varname =~/\\A\\w+\\z/) }; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
class_type Message, { class => 'Sietima::Message' }; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
class_type HeaderUri, { class => 'Sietima::HeaderURI' }; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
declare_coercion HeaderUriFromThings, |
56
|
|
|
|
|
|
|
to_type HeaderUri, from Defined, |
57
|
|
|
|
|
|
|
q{ Sietima::HeaderURI->new($_) }; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
class_type Subscriber, { class => 'Sietima::Subscriber' }; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
declare_coercion SubscriberFromAddress, |
63
|
|
|
|
|
|
|
to_type Subscriber, from Address, |
64
|
|
|
|
|
|
|
q{ Sietima::Subscriber->new(primary=>$_) }; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
declare_coercion SubscriberFromStr, |
67
|
|
|
|
|
|
|
to_type Subscriber, from Str, |
68
|
|
|
|
|
|
|
q{ Sietima::Subscriber->new(primary=>(Email::Address->parse($_))[0]) }; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
declare_coercion SubscriberFromHashRef, |
71
|
|
|
|
|
|
|
to_type Subscriber, from HashRef, |
72
|
|
|
|
|
|
|
q{ Sietima::Subscriber->new($_) }; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=pod |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=encoding UTF-8 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Sietima::Types - type library for Sietima |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 1.0.5 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This module is a L<< C<Type::Library> >>. It declares a few type |
93
|
|
|
|
|
|
|
constraints nad coercions. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 TYPES |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C<SietimaObj> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
An instance of L<< C<Sietima> >>. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 C<EmailMIME> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
An instance of L<< C<Email::MIME> >>. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 C<Transport> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
An object that consumes the role L<< C<Email::Sender::Transport> >>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 C<MailStore> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
An object that consumes the role L<< C<Sietima::MailStore> >>. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Coercions: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item C<MailStoreFromHashRef> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
has store => ( isa => MailStore->plus_coercions(MailStoreFromHashRef) ); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Using this coercion, a hashref of the form: |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
{ |
124
|
|
|
|
|
|
|
class => 'Some::Store::Class', |
125
|
|
|
|
|
|
|
%constructor_args, |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
will be converted into an instance of C<Some::Store::Class> built with |
129
|
|
|
|
|
|
|
the C<%constructor_args>. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 C<Address> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
An instance of L<< C<Email::Address> >>. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Coercions: |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item C<AddressFromStr> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
has address => ( isa => Address->plus_coercions(AddressFromStr) ); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Using this coercion, a string will be parsed into an L<< |
146
|
|
|
|
|
|
|
C<Email::Address> >>. If the string contains more than one address, |
147
|
|
|
|
|
|
|
only the first one will be used. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 C<TagName> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
A string composed exclusively of "word" (C</\w/>) characters. Used by |
154
|
|
|
|
|
|
|
L<mail stores|Sietima::MailStore> to tag messages. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 C<Message> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
An instance of L<< C<Sietima::Message> >>. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 C<Subscriber> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
An instance of L<< C<Sietima::Subscriber> >>. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Coercions: |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item C<SubscriberFromAddress> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
has sub => ( isa => Subscriber->plus_coercions(SubscriberFromAddress) ); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Using this coercion, an L<< C<Email::Address> >> will be converted |
173
|
|
|
|
|
|
|
into a subscriber that has that address as its primary. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item C<SubscriberFromStr> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
has sub => ( isa => Subscriber->plus_coercions(SubscriberFromStr) ); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Using this coercion, a string will be converted into a subscriber that |
180
|
|
|
|
|
|
|
has the first address parsed from that string as its primary. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item C<SubscriberFromHashRef> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
has sub => ( isa => Subscriber->plus_coercions(SubscriberFromHashRef) ); |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Using this coercion, a hashref will be converted into a subscriber by |
187
|
|
|
|
|
|
|
passing it to the constructor. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 AUTHOR |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Gianni Ceccarelli <dakkar@thenautilus.net> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gianni Ceccarelli <dakkar@thenautilus.net>. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
200
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |