| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Frost::Types; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use Moose::Util::TypeConstraints; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1449
|
use Frost::Util; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.64; |
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:ERNESTO'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
enum 'Frost::SortType', ( SORT_INT, SORT_FLOAT, SORT_DATE, SORT_TEXT, ); |
|
14
|
|
|
|
|
|
|
enum 'Frost::Status', ( STATUS_NOT_INITIALIZED, STATUS_MISSING, STATUS_LOADED, STATUS_EXISTS, ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
subtype 'Frost::Date' |
|
17
|
|
|
|
|
|
|
=> as 'Str' |
|
18
|
|
|
|
|
|
|
=> where |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
|
|
|
|
|
|
return undef unless $_ =~ m#^\d{4}-\d{2}-\d{2}$#; # 1999-10-03 |
|
21
|
|
|
|
|
|
|
return 1; |
|
22
|
|
|
|
|
|
|
}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
subtype 'Frost::Time' |
|
25
|
|
|
|
|
|
|
=> as 'Str' |
|
26
|
|
|
|
|
|
|
=> where |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
|
|
|
|
|
|
return undef unless $_ =~ m#^\d{2}:\d{2}:\d{2}$#; # 15:23:41 |
|
29
|
|
|
|
|
|
|
return 1; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
subtype 'Frost::TimeStamp' |
|
33
|
|
|
|
|
|
|
=> as 'Str' |
|
34
|
|
|
|
|
|
|
=> where |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
|
|
|
|
|
|
return undef unless $_ =~ m#^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$#; # 1999-10-03 15:23:41 |
|
37
|
|
|
|
|
|
|
return 1; |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
subtype 'Frost::FilePath' |
|
41
|
|
|
|
|
|
|
=> as 'Str' |
|
42
|
|
|
|
|
|
|
=> where |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
|
|
|
|
|
|
return undef unless $_ =~ m#^(/[-a-zA-Z0-9_\.\@]+)+$#; # '/' (root) forbidden! |
|
45
|
|
|
|
|
|
|
return 1; |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
subtype 'Frost::FilePathMustExist' |
|
49
|
|
|
|
|
|
|
=> as 'Str' |
|
50
|
|
|
|
|
|
|
=> where |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
|
|
|
|
|
|
return undef unless $_ =~ m#^(/[-a-zA-Z0-9_\.\@]+)+$#; # '/' (root) forbidden! |
|
53
|
|
|
|
|
|
|
return undef unless -e $_; # must exist |
|
54
|
|
|
|
|
|
|
return 1; |
|
55
|
|
|
|
|
|
|
}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
subtype 'Frost::Real' |
|
58
|
|
|
|
|
|
|
=> as 'Num'; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
subtype 'Frost::RealPositive' |
|
61
|
|
|
|
|
|
|
=> as 'Num' |
|
62
|
|
|
|
|
|
|
=> where { $_ > 0.0 }; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
subtype 'Frost::Whole' |
|
65
|
|
|
|
|
|
|
=> as 'Int' |
|
66
|
|
|
|
|
|
|
=> where { $_ >= 0 }; # 0 1 2 3... |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
subtype 'Frost::Natural' |
|
69
|
|
|
|
|
|
|
=> as 'Int' |
|
70
|
|
|
|
|
|
|
=> where { $_ > 0 }; # 1 2 3... |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
subtype 'Frost::StringId' |
|
73
|
|
|
|
|
|
|
=> as 'Str' |
|
74
|
|
|
|
|
|
|
# => where { $_ =~ m/^[A-Za-z_][A-Za-z0-9_]*$/; }; # starts with '_' or char, no '.' |
|
75
|
|
|
|
|
|
|
=> where { $_ =~ m/^(--|([A-Za-z_][A-Za-z0-9_]*))$/; }; # and special case '--' => "catch all", "default" etc. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
subtype 'Frost::BSN' |
|
78
|
|
|
|
|
|
|
=> as 'Str' |
|
79
|
|
|
|
|
|
|
=> where { $_ =~ m/^\d+[A-Z]+\d+(-\d+)?$/; }; # 01A05-2 |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# from http://www.regular-expressions.info/email.html |
|
82
|
|
|
|
|
|
|
# /^[A-Za-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$/ |
|
83
|
|
|
|
|
|
|
# |
|
84
|
|
|
|
|
|
|
# from CGI::FormBuilder::Field |
|
85
|
|
|
|
|
|
|
# /^[\w\-\+\._]+\@[a-zA-Z0-9][-a-zA-Z0-9\.]*\.[a-zA-Z]+$/ |
|
86
|
|
|
|
|
|
|
# |
|
87
|
|
|
|
|
|
|
# Email::Valid not considered due to speed... |
|
88
|
|
|
|
|
|
|
# |
|
89
|
|
|
|
|
|
|
subtype 'Frost::EmailString' |
|
90
|
|
|
|
|
|
|
=> as 'Str', |
|
91
|
|
|
|
|
|
|
=> where { $_ =~ m/^[\w\-\+\.]+\@[a-zA-Z0-9][-a-zA-Z0-9\.]*\.[a-zA-Z]{2,6}$/; }; # firstname.lastname@sub.domain.tld |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
subtype 'Frost::UniqueStringId' |
|
94
|
|
|
|
|
|
|
=> as 'Str' |
|
95
|
|
|
|
|
|
|
=> where { $_ =~ m/^[0-9A-F]+-[0-9A-F]+-[0-9A-F]+-[0-9A-F]+-[0-9A-F]+$/; }; # 1234-5678-90AB-CDEF-42AF |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
subtype 'Frost::UniqueId' |
|
98
|
|
|
|
|
|
|
=> as 'Frost::Natural | Frost::StringId | Frost::BSN | Frost::UniqueStringId | Frost::EmailString'; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
subtype 'Frost::DBM_Object' |
|
101
|
|
|
|
|
|
|
=> as 'Object' |
|
102
|
|
|
|
|
|
|
# => where { $_->isa ( 'DB_File' ) }; |
|
103
|
|
|
|
|
|
|
=> where { $_->isa ( 'BerkeleyDB::Btree' ) }; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
subtype 'Frost::DBM_Hash' |
|
106
|
|
|
|
|
|
|
=> as 'HashRef'; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
subtype 'Frost::DBM_Cursor' |
|
109
|
|
|
|
|
|
|
=> as 'Object' |
|
110
|
|
|
|
|
|
|
=> where { $_->isa ( 'BerkeleyDB::Cursor' ) }; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
####################################### |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
package Frost::Check; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use strict; |
|
117
|
|
|
|
|
|
|
use warnings; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
use Data::Dumper; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Moose::Util::TypeConstraints->export_type_constraints_as_functions; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# see Frost::Util::check_type_manuel |
|
126
|
|
|
|
|
|
|
# avoid cyclic dependance... |
|
127
|
|
|
|
|
|
|
# |
|
128
|
|
|
|
|
|
|
sub check_type_manuel ( $$;$ ) |
|
129
|
|
|
|
|
|
|
{ |
|
130
|
|
|
|
|
|
|
no strict 'refs'; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# 0.64 |
|
133
|
|
|
|
|
|
|
# This works not for namespaced types! |
|
134
|
|
|
|
|
|
|
# |
|
135
|
|
|
|
|
|
|
# unless ( $_[0] ( $_[1] ) ) |
|
136
|
|
|
|
|
|
|
# |
|
137
|
|
|
|
|
|
|
# so: |
|
138
|
|
|
|
|
|
|
# |
|
139
|
|
|
|
|
|
|
my $func = __PACKAGE__ . '::' . $_[0]; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
unless ( &$func ( $_[1] ) ) |
|
142
|
|
|
|
|
|
|
{ |
|
143
|
|
|
|
|
|
|
my ( $type, $value, $silent ) = @_; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
return 0 if $silent; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$value = 'undef' unless defined $value; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Carp::confess "Manual check does not pass the type constraint ($type) with '$value'"; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
return 1; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
__END__ |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 NAME |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Frost::Types - The backstage boys |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
No documentation yet... |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
No user maintainable parts inside ;-) |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 TYPES |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 Frost::SortType |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 Frost::Status |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 Frost::Date |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 Frost::Time |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 Frost::TimeStamp |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 Frost::FilePath |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 Frost::FilePathMustExist |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 Frost::Real |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head2 Frost::RealPositive |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 Frost::Whole |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 Frost::Natural |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 Frost::StringId |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 Frost::BSN |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 Frost::EmailString |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 Frost::UniqueStringId |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 Frost::UniqueId |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 Frost::DBM_Object |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 Frost::DBM_Hash |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 PUBLIC FUNCTIONS |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 check_type_manuel |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Internal function, called by L<Frost::Util/check_type_manuel>. |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 GETTING HELP |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
I'm reading the Moose mailing list frequently, so please ask your |
|
219
|
|
|
|
|
|
|
questions there. |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
The mailing list is L<moose@perl.org>. You must be subscribed to send |
|
222
|
|
|
|
|
|
|
a message. To subscribe, send an empty message to |
|
223
|
|
|
|
|
|
|
L<moose-subscribe@perl.org> |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 BUGS |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
|
228
|
|
|
|
|
|
|
exception. |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Please report any bugs to me or the mailing list. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 AUTHOR |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Ernesto L<ernesto@dienstleistung-kultur.de> |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Copyright (C) 2010 by Dienstleistung Kultur Ltd. & Co. KG |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
L<http://dienstleistung-kultur.de/frost/> |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
243
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=cut |