line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::ShortCut::BuildInstance::Types; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JANDREW'; |
3
|
2
|
|
|
2
|
|
328367
|
use version; our $VERSION = version->declare('v1.34.8'); |
|
2
|
|
|
|
|
2103
|
|
|
2
|
|
|
|
|
14
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
252
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
56
|
|
6
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
7
|
2
|
|
|
2
|
|
10
|
use Data::Dumper; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
127
|
|
8
|
2
|
|
|
2
|
|
1718
|
use Type::Utils 1.000 -all; |
|
2
|
|
|
|
|
9982
|
|
|
2
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
use Type::Library |
10
|
2
|
|
|
|
|
12
|
-base, |
11
|
|
|
|
|
|
|
-declare => qw( |
12
|
|
|
|
|
|
|
NameSpace |
13
|
|
|
|
|
|
|
SuperClassesList |
14
|
|
|
|
|
|
|
RolesList |
15
|
|
|
|
|
|
|
Attributes |
16
|
|
|
|
|
|
|
Methods |
17
|
|
|
|
|
|
|
BuildClassDict |
18
|
2
|
|
|
2
|
|
6435
|
); |
|
2
|
|
|
|
|
4
|
|
19
|
2
|
|
|
2
|
|
1689
|
use Types::Standard -types; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
13
|
|
20
|
|
|
|
|
|
|
my $try_xs = |
21
|
|
|
|
|
|
|
exists($ENV{PERL_TYPE_TINY_XS}) ? !!$ENV{PERL_TYPE_TINY_XS} : |
22
|
|
|
|
|
|
|
exists($ENV{PERL_ONLY}) ? !$ENV{PERL_ONLY} : |
23
|
|
|
|
|
|
|
1; |
24
|
|
|
|
|
|
|
if( $try_xs and exists $INC{'Type/Tiny/XS.pm'} ){ |
25
|
2
|
|
|
2
|
|
13
|
eval "use Type::Tiny::XS 0.010"; |
|
2
|
|
|
|
|
56
|
|
|
2
|
|
|
|
|
36
|
|
26
|
|
|
|
|
|
|
if( $@ ){ |
27
|
|
|
|
|
|
|
die "You have loaded Type::Tiny::XS but versions prior to 0.010 will cause this module to fail"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#########1 Package Variables 3#########4#########5#########6#########7#########8#########9 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#########1 Type Library 3#########4#########5#########6#########7#########8#########9 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
declare NameSpace, |
38
|
|
|
|
|
|
|
as Str, |
39
|
|
|
|
|
|
|
where{ $_ =~ /^[A-Za-z:]+$/ }, |
40
|
|
|
|
|
|
|
message{ "-$_- does not match: " . qr/^[A-Za-z:]+$/ }; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
declare SuperClassesList, |
43
|
|
|
|
|
|
|
as ArrayRef[ ClassName ], |
44
|
|
|
|
|
|
|
where{ scalar( @$_ ) > 0 }; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
declare RolesList, |
47
|
|
|
|
|
|
|
as ArrayRef[ RoleName ], |
48
|
|
|
|
|
|
|
where{ scalar( @$_ ) > 0 }; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
declare Attributes, |
51
|
|
|
|
|
|
|
as HashRef[ HashRef ], |
52
|
|
|
|
|
|
|
where{ scalar( keys %$_ ) > 0 }; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
declare Methods, |
55
|
|
|
|
|
|
|
as HashRef[ CodeRef ], |
56
|
|
|
|
|
|
|
where{ scalar( keys %$_ ) > 0 }; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
declare BuildClassDict, |
59
|
|
|
|
|
|
|
as Dict[ |
60
|
|
|
|
|
|
|
package => Optional[ NameSpace ], |
61
|
|
|
|
|
|
|
superclasses => Optional[ SuperClassesList ], |
62
|
|
|
|
|
|
|
roles => Optional[ RolesList ], |
63
|
|
|
|
|
|
|
add_roles_in_sequence => Optional[ RolesList ], |
64
|
|
|
|
|
|
|
add_attributes => Optional[ Attributes ], |
65
|
|
|
|
|
|
|
add_methods => Optional[ Methods ], |
66
|
|
|
|
|
|
|
], |
67
|
|
|
|
|
|
|
where{ scalar( keys( %$_ ) ) > 0 }; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#########1 Declared Coercions 3#########4#########5#########6#########7#########8#########9 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#########1 Private Methods 3#########4#########5#########6#########7#########8#########9 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#########1 Phinish 3#########4#########5#########6#########7#########8#########9 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#########1 Documentation 3#########4#########5#########6#########7#########8#########9 |
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
MooseX::ShortCut::BuildInstance::Types - The BuildInstance type library |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is the package for managing types in the L<MooseX::ShortCut::BuildInstance> |
91
|
|
|
|
|
|
|
package. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 L<Caveat utilitor|http://en.wiktionary.org/wiki/Appendix:List_of_Latin_phrases_(A%E2%80%93E)#C> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
All type tests included with this package are considered to be the fixed definition of |
96
|
|
|
|
|
|
|
the types. Any definition not included in the testing is considered flexible. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This module uses L<Type::Tiny> which can, in the background, use L<Type::Tiny::XS>. |
99
|
|
|
|
|
|
|
While in general this is a good thing you will need to make sure that |
100
|
|
|
|
|
|
|
Type::Tiny::XS is version 0.010 or newer since the older ones didn't support the |
101
|
|
|
|
|
|
|
'Optional' method. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 Types |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
These are checks compatible with the L<Moose> typing system. They are used to see |
106
|
|
|
|
|
|
|
if passed information is compatible with some standard. For mor information see |
107
|
|
|
|
|
|
|
L<Type::Tiny>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head3 NameSpace |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
B<Test:> to see if the name_space fits classical package nameing conventions |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
B<Accepts:> $string =~ /^[A-Za-z:]+$/ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head3 SuperClassesList |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
B<Test:> Checking for an arrayref of classes suitable for inheritance by the built class |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
B<Accepts:> an array ref of class names |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head3 RolesList |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
B<Test:> Checking for an arrayref of role suitable for adding to the built class |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
B<Accepts:> an array ref of role names |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head3 Attributes |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
B<Test:> This is a hash ref of attributes to be added to the built class |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
B<Accepts:> the hash keys will be treated as the attribute names and the values |
146
|
|
|
|
|
|
|
will be treated as the attribute settings. Only HashRefs are accepted as values |
147
|
|
|
|
|
|
|
but no testing of the HashRef for suitability as attribute settings is done prior |
148
|
|
|
|
|
|
|
to implementation by $meta-E<gt>add_attribute( $value ). |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head3 Methods |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
B<Test:> This is a hash ref of methods to be added to the built class |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
B<Accepts:> the hash keys will be treated as the method names and the values |
159
|
|
|
|
|
|
|
will be treated as method refs. Only CodeRefs are accepted as values |
160
|
|
|
|
|
|
|
but no testing of the CodeRefs for suitability as methods is done prior |
161
|
|
|
|
|
|
|
to implementation by $meta-E<gt>add_method( $value ). |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head3 BuildClassDict |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=over |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
B<Test:> This is a Dictionary ref defining the possible entrys to the |
170
|
|
|
|
|
|
|
'build_class' function |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
B<Accepts:> |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Dict[ |
175
|
|
|
|
|
|
|
package => Optional[ NameSpace ], |
176
|
|
|
|
|
|
|
superclasses => Optional[ SuperClassesList ], |
177
|
|
|
|
|
|
|
roles => Optional[ RolesList ], |
178
|
|
|
|
|
|
|
add_roles_in_sequence => Optional[ RolesList ], |
179
|
|
|
|
|
|
|
add_attributes => Optional[ Attributes ], |
180
|
|
|
|
|
|
|
add_methods => Optional[ Methods ], |
181
|
|
|
|
|
|
|
] |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 SUPPORT |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=over |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L<MooseX-ShortCut-BuildInstance/issues|https://github.com/jandrew/MooseX-ShortCut-BuildInstance/issues> |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 TODO |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=over |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
B<1.> Nothing L<currently|/SUPPORT> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=back |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 AUTHOR |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=over |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item Jed Lund |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item jandrew@cpan.org |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=back |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 COPYRIGHT |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This program is free software; you can redistribute |
214
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
The full text of the license can be found in the |
217
|
|
|
|
|
|
|
LICENSE file included with this module. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This software is copyrighted (c) 2014 and 2015 by Jed Lund |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=over |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
L<version> |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
L<Type::Tiny> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=back |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
#########1#########2 main pod documentation end 5#########6#########7#########8#########9 |