line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Specio::Library::Perl; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
81
|
use strict; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
329
|
|
4
|
12
|
|
|
12
|
|
57
|
use warnings; |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
514
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.46'; |
7
|
|
|
|
|
|
|
|
8
|
12
|
|
|
12
|
|
58
|
use parent 'Specio::Exporter'; |
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
76
|
|
9
|
|
|
|
|
|
|
|
10
|
12
|
|
|
12
|
|
5081
|
use Specio::Library::String; |
|
12
|
|
|
|
|
32
|
|
|
12
|
|
|
|
|
72
|
|
11
|
12
|
|
|
12
|
|
5664
|
use version 0.83 (); |
|
12
|
|
|
|
|
21438
|
|
|
12
|
|
|
|
|
365
|
|
12
|
|
|
|
|
|
|
|
13
|
12
|
|
|
12
|
|
78
|
use Specio::Declare; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
74
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $package_inline = sub { |
16
|
|
|
|
|
|
|
return sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] ); |
17
|
|
|
|
|
|
|
( |
18
|
|
|
|
|
|
|
%s |
19
|
|
|
|
|
|
|
&& |
20
|
|
|
|
|
|
|
%s =~ /\A[^\W\d]\w*(?:::\w+)*\z/ |
21
|
|
|
|
|
|
|
) |
22
|
|
|
|
|
|
|
EOF |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
declare( |
26
|
|
|
|
|
|
|
'PackageName', |
27
|
|
|
|
|
|
|
parent => t('NonEmptyStr'), |
28
|
|
|
|
|
|
|
inline => $package_inline, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
declare( |
32
|
|
|
|
|
|
|
'ModuleName', |
33
|
|
|
|
|
|
|
parent => t('NonEmptyStr'), |
34
|
|
|
|
|
|
|
inline => $package_inline, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
declare( |
38
|
|
|
|
|
|
|
'DistName', |
39
|
|
|
|
|
|
|
parent => t('NonEmptyStr'), |
40
|
|
|
|
|
|
|
inline => sub { |
41
|
|
|
|
|
|
|
return |
42
|
|
|
|
|
|
|
sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] ); |
43
|
|
|
|
|
|
|
( |
44
|
|
|
|
|
|
|
%s |
45
|
|
|
|
|
|
|
&& |
46
|
|
|
|
|
|
|
%s =~ /\A[^\W\d]\w*(?:-\w+)*\z/ |
47
|
|
|
|
|
|
|
) |
48
|
|
|
|
|
|
|
EOF |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
declare( |
53
|
|
|
|
|
|
|
'Identifier', |
54
|
|
|
|
|
|
|
parent => t('NonEmptyStr'), |
55
|
|
|
|
|
|
|
inline => sub { |
56
|
|
|
|
|
|
|
return |
57
|
|
|
|
|
|
|
sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] ); |
58
|
|
|
|
|
|
|
( |
59
|
|
|
|
|
|
|
%s |
60
|
|
|
|
|
|
|
&& |
61
|
|
|
|
|
|
|
%s =~ /\A[^\W\d]\w*\z/ |
62
|
|
|
|
|
|
|
) |
63
|
|
|
|
|
|
|
EOF |
64
|
|
|
|
|
|
|
}, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
declare( |
68
|
|
|
|
|
|
|
'SafeIdentifier', |
69
|
|
|
|
|
|
|
parent => t('Identifier'), |
70
|
|
|
|
|
|
|
inline => sub { |
71
|
|
|
|
|
|
|
return |
72
|
|
|
|
|
|
|
sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] ); |
73
|
|
|
|
|
|
|
( |
74
|
|
|
|
|
|
|
%s |
75
|
|
|
|
|
|
|
&& |
76
|
|
|
|
|
|
|
%s !~ /\A[_ab]\z/ |
77
|
|
|
|
|
|
|
) |
78
|
|
|
|
|
|
|
EOF |
79
|
|
|
|
|
|
|
}, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
declare( |
83
|
|
|
|
|
|
|
'LaxVersionStr', |
84
|
|
|
|
|
|
|
parent => t('NonEmptyStr'), |
85
|
|
|
|
|
|
|
inline => sub { |
86
|
|
|
|
|
|
|
return |
87
|
|
|
|
|
|
|
sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] ); |
88
|
|
|
|
|
|
|
( |
89
|
|
|
|
|
|
|
%s |
90
|
|
|
|
|
|
|
&& |
91
|
|
|
|
|
|
|
version::is_lax(%s) |
92
|
|
|
|
|
|
|
) |
93
|
|
|
|
|
|
|
EOF |
94
|
|
|
|
|
|
|
}, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
declare( |
98
|
|
|
|
|
|
|
'StrictVersionStr', |
99
|
|
|
|
|
|
|
parent => t('NonEmptyStr'), |
100
|
|
|
|
|
|
|
inline => sub { |
101
|
|
|
|
|
|
|
return |
102
|
|
|
|
|
|
|
sprintf( <<'EOF', $_[0]->parent->inline_check( $_[1] ), $_[1] ); |
103
|
|
|
|
|
|
|
( |
104
|
|
|
|
|
|
|
%s |
105
|
|
|
|
|
|
|
&& |
106
|
|
|
|
|
|
|
version::is_strict(%s) |
107
|
|
|
|
|
|
|
) |
108
|
|
|
|
|
|
|
EOF |
109
|
|
|
|
|
|
|
}, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# ABSTRACT: Implements type constraint objects for some common Perl language things |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=pod |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=encoding UTF-8 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 NAME |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Specio::Library::Perl - Implements type constraint objects for some common Perl language things |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 VERSION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
version 0.46 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 DESCRIPTION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This library provides some additional string types for common cases. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 PackageName |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
A valid package name. Unlike the C<ClassName> constraint from the |
137
|
|
|
|
|
|
|
L<Specio::Library::Builtins> library, this package does not need to be loaded. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This type does allow Unicode characters. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 ModuleName |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Same as C<PackageName>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 DistName |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
A valid distribution name like C<DBD-Pg> Basically this is the same as a |
148
|
|
|
|
|
|
|
package name with the double-colons replaced by dashes. Note that there are |
149
|
|
|
|
|
|
|
some historical distribution names that don't fit this pattern, like |
150
|
|
|
|
|
|
|
C<CGI.pm>. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This type does allow Unicode characters. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 Identifier |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
An L<Identifier|perldata/Variable names> is something that could be used as a |
157
|
|
|
|
|
|
|
symbol name or other identifier (filehandle, directory handle, subroutine |
158
|
|
|
|
|
|
|
name, format name, or label). It's what you put after the sigil (dollar sign, |
159
|
|
|
|
|
|
|
at sign, percent sign) in a variable name. Generally, it's a bunch of |
160
|
|
|
|
|
|
|
word characters not starting with a digit. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This type does allow Unicode characters. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 SafeIdentifier |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This is just like an C<Identifier> but it excludes the single-character |
167
|
|
|
|
|
|
|
variables underscore (C<_>), C<a>< and C<b>, as these are special variables to |
168
|
|
|
|
|
|
|
the Perl interpreter. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 LaxVersionStr and StrictVersionStr |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Lax and strict version strings use the L<is_lax|version/is_lax> and |
173
|
|
|
|
|
|
|
L<is_strict|version/is_strict> methods from C<version> to check if the given |
174
|
|
|
|
|
|
|
string would be a valid lax or strict version. L<version::Internals> covers |
175
|
|
|
|
|
|
|
the details but basically: lax versions are everything you may do, and strict |
176
|
|
|
|
|
|
|
omit many of the usages best avoided. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 CREDITS |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Much of the code and docs for this library comes from MooseX::Types::Perl, |
181
|
|
|
|
|
|
|
written by Ricardo SIGNES <rjbs@cpan.org>. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SUPPORT |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Specio/issues>. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 SOURCE |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
The source code repository for Specio can be found at L<https://github.com/houseabsolute/Specio>. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 AUTHOR |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This software is Copyright (c) 2012 - 2020 by Dave Rolsky. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This is free software, licensed under: |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
The full text of the license can be found in the |
206
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |