line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Yukki::Types; |
2
|
|
|
|
|
|
|
$Yukki::Types::VERSION = '0.991_002'; # TRIAL |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
48
|
$Yukki::Types::VERSION = '0.991002';use v5.24; |
|
4
|
|
|
|
|
12
|
|
5
|
4
|
|
|
4
|
|
19
|
use utf8; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
22
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
|
|
31
|
use Type::Library -base, -declare => qw( |
8
|
|
|
|
|
|
|
LoginName AccessLevel |
9
|
|
|
|
|
|
|
NavigationLinks NavigationMenuMap |
10
|
|
|
|
|
|
|
BaseURL BaseURLEnum BreadcrumbLinks RepositoryMap |
11
|
|
|
|
|
|
|
PluginConfig PluginList |
12
|
|
|
|
|
|
|
PrivilegesMap |
13
|
|
|
|
|
|
|
EmailAddress YukkiSettings |
14
|
|
|
|
|
|
|
YukkiWebSettings YukkiSettingsAnonymous |
15
|
4
|
|
|
4
|
|
243
|
); |
|
4
|
|
|
|
|
11
|
|
16
|
4
|
|
|
4
|
|
7112
|
use Type::Utils qw( declare as where message coerce enum from via class_type ); |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
29
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
3736
|
use Types::Standard qw( Str Int ArrayRef Maybe HashRef Dict ); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
31
|
|
19
|
4
|
|
|
4
|
|
5774
|
use Types::URI qw( Uri ); |
|
4
|
|
|
|
|
213595
|
|
|
4
|
|
|
|
|
72
|
|
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
4
|
|
3977
|
use Email::Address; |
|
4
|
|
|
|
|
24287
|
|
|
4
|
|
|
|
|
346
|
|
22
|
4
|
|
|
4
|
|
59
|
use List::Util qw( first all ); |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
474
|
|
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
4
|
|
650
|
use namespace::clean; |
|
4
|
|
|
|
|
10189
|
|
|
4
|
|
|
|
|
42
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# ABSTRACT: standard types for use in Yukki |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
declare LoginName, |
30
|
|
|
|
|
|
|
as Str, |
31
|
|
|
|
|
|
|
where { /^[a-zA-Z0-9_-]{3,20}$/ }, |
32
|
|
|
|
|
|
|
message { "login name $_ must only contain letters and numbers" }; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
enum AccessLevel, [qw( read write none )]; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
declare NavigationLinks, |
39
|
|
|
|
|
|
|
as ArrayRef[ |
40
|
|
|
|
|
|
|
Dict[ |
41
|
|
|
|
|
|
|
label => Str, |
42
|
|
|
|
|
|
|
href => Str|Uri, |
43
|
|
|
|
|
|
|
sort => Maybe[Int], |
44
|
|
|
|
|
|
|
], |
45
|
|
|
|
|
|
|
]; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
declare NavigationMenuMap, |
49
|
|
|
|
|
|
|
as HashRef[ NavigationLinks ]; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
enum BaseURLEnum, [qw( SCRIPT_NAME REWRITE )]; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
declare BaseURL, as BaseURLEnum|Uri; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
coerce BaseURL, |
57
|
|
|
|
|
|
|
from Str, |
58
|
|
|
|
|
|
|
via { |
59
|
|
|
|
|
|
|
$_ !~ /^(?:SCRIPT_NAME|REWRITE)$/ |
60
|
|
|
|
|
|
|
&& URI->new($_) |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
declare BreadcrumbLinks, |
65
|
|
|
|
|
|
|
as ArrayRef[ |
66
|
|
|
|
|
|
|
Dict[ |
67
|
|
|
|
|
|
|
label => Str, |
68
|
|
|
|
|
|
|
href => Str, |
69
|
|
|
|
|
|
|
], |
70
|
|
|
|
|
|
|
]; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $Repository = class_type 'Yukki::Settings::Repository'; |
74
|
|
|
|
|
|
|
declare RepositoryMap, |
75
|
|
|
|
|
|
|
as HashRef[$Repository]; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
coerce RepositoryMap, |
78
|
|
|
|
|
|
|
from HashRef, |
79
|
|
|
|
|
|
|
via { |
80
|
|
|
|
|
|
|
my $source = $_; |
81
|
|
|
|
|
|
|
+{ |
82
|
|
|
|
|
|
|
map { $_ => Yukki::Settings::Repository->new($source->{$_}) } |
83
|
|
|
|
|
|
|
keys %$source |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $Privileges = class_type 'Yukki::Settings::Privileges'; |
89
|
|
|
|
|
|
|
declare PrivilegesMap, |
90
|
|
|
|
|
|
|
as HashRef[$Privileges]; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
coerce PrivilegesMap, |
93
|
|
|
|
|
|
|
from HashRef, |
94
|
|
|
|
|
|
|
via { |
95
|
|
|
|
|
|
|
my $source = $_; |
96
|
|
|
|
|
|
|
+{ |
97
|
|
|
|
|
|
|
map { $_ => Yukki::Settings::Privileges->new($source->{$_}) } |
98
|
|
|
|
|
|
|
keys %$source |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
}; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
declare PluginConfig, |
104
|
|
|
|
|
|
|
as ArrayRef[HashRef], |
105
|
|
|
|
|
|
|
where { all { defined $_->{module} } @$_ }; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $Plugin = class_type 'Yukki::Web::Plugin'; |
109
|
|
|
|
|
|
|
declare PluginList, |
110
|
|
|
|
|
|
|
as ArrayRef[$Plugin], |
111
|
|
|
|
|
|
|
message { |
112
|
|
|
|
|
|
|
return 'It is not an array of objects.' unless ref $_ eq 'ARRAY'; |
113
|
|
|
|
|
|
|
my $bad = first { not blessed $_ or not $_->isa('Yukki::Web::Plugin') } |
114
|
|
|
|
|
|
|
@$_; |
115
|
|
|
|
|
|
|
$bad = blessed $bad if blessed $bad; |
116
|
|
|
|
|
|
|
return "It contains $bad, which is not a Yukki::Web::Plugin."; |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
class_type EmailAddress, { class => 'Email::Address' }; |
121
|
|
|
|
|
|
|
coerce EmailAddress, |
122
|
|
|
|
|
|
|
from Str, |
123
|
|
|
|
|
|
|
via { (Email::Address->parse($_))[0] }; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
class_type YukkiSettings, { class => 'Yukki::Settings' }; |
127
|
|
|
|
|
|
|
coerce YukkiSettings, |
128
|
|
|
|
|
|
|
from HashRef, |
129
|
|
|
|
|
|
|
via { Yukki::Settings->new($_) }; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
class_type YukkiWebSettings, { class => 'Yukki::Web::Settings' }; |
133
|
|
|
|
|
|
|
coerce YukkiWebSettings, |
134
|
|
|
|
|
|
|
from HashRef, |
135
|
|
|
|
|
|
|
via { Yukki::Web::Settings->new($_) }; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
class_type YukkiSettingsAnonymous, { class => 'Yukki::Settings::Anonymous' }; |
139
|
|
|
|
|
|
|
coerce YukkiSettingsAnonymous, |
140
|
|
|
|
|
|
|
from HashRef, |
141
|
|
|
|
|
|
|
via { Yukki::Settings::Anonymous->new($_) }; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=pod |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=encoding UTF-8 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 NAME |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Yukki::Types - standard types for use in Yukki |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 VERSION |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
version 0.991_002 |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 SYNOPSIS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
use Yukki::Types qw( LoginName AccessLevel ); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
has login_name => ( isa => LoginName ); |
164
|
|
|
|
|
|
|
has access_level => ( isa => AccessLevel ); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 DESCRIPTION |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
A standard type library for Yukki. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 TYPES |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 LoginName |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This is a valid login name. Login names may only contain letters and numbers, as of this writing. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 AccessLevel |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This is a valid access level. This includes any of the following values: |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
read |
181
|
|
|
|
|
|
|
write |
182
|
|
|
|
|
|
|
none |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 NavigationLinks |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This is an array of hashes formatted like: |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
{ |
189
|
|
|
|
|
|
|
label => 'Label', |
190
|
|
|
|
|
|
|
href => '/link/to/somewhere', |
191
|
|
|
|
|
|
|
sort => 40, |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 NavigationMenuMap |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
This is a hash of L</NavigationLinks>. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 BaseURL |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This is either an absolute URL or the words C<SCRIPT_NAME> or C<REWRITE>. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 BreadcrumbLinks |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This is an array of hashes formatted like: |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
{ |
207
|
|
|
|
|
|
|
label => 'Label', |
208
|
|
|
|
|
|
|
href => '/link/to/somewhere', |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head2 RepositoryMap |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This is a hash of L<Yukki::Settings::Repository> objects. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 PrivilegeMap |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This is a hash of L<Yukki::Settings::Privileges> objects. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 PluginConfig |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
A plugin configuration is an array of hashes. Each hash must have at least one key named "module" defined. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 PluginList |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
A plugin list is a loaded set of plugin objects. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 COERCIONS |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
In addition to the types above, these coercions are provided for other types. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 EmailAddress |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Coerces a C<Str> into an L<Email::Address>. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 YukkiSettings |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Coerces a C<HashRef> into this object by passing the value to the constructor. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head2 YukkiWebSettings |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Coerces a C<HashRef> into a L<Yukki::Web::Settings>. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 YukkiSettingsAnonymous |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Coerces a C<HashRef> into this object by passing the value to the constructor. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 AUTHOR |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Qubling Software LLC. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
256
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=cut |