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