line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pod::Readme::Types; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
76
|
use v5.10.1; |
|
5
|
|
|
|
|
20
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
33
|
use feature 'state'; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
596
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
46
|
use strict; |
|
5
|
|
|
|
|
61
|
|
|
5
|
|
|
|
|
107
|
|
8
|
5
|
|
|
5
|
|
51
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
229
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 'v1.2.2'; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
27
|
use Exporter qw/ import /; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
148
|
|
13
|
5
|
|
|
5
|
|
28
|
use IO qw/ Handle /; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
37
|
|
14
|
5
|
|
|
5
|
|
574
|
use Path::Tiny; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
256
|
|
15
|
5
|
|
|
5
|
|
28
|
use Scalar::Util qw/ blessed /; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
192
|
|
16
|
5
|
|
|
5
|
|
27
|
use Type::Tiny; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
126
|
|
17
|
5
|
|
|
5
|
|
25
|
use Types::Standard qw/ FileHandle Str /; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
29
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# RECOMMEND PREREQ: Type::Tiny::XS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = |
22
|
|
|
|
|
|
|
qw/ Dir File Indentation IO ReadIO WriteIO HeadingLevel TargetName DistZilla /; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Pod::Readme::Types - Types used by Pod::Readme |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Pod::Readme::Types qw/ Indentation /; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has verbatim_indent => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
isa => Indentation, |
35
|
|
|
|
|
|
|
default => 2, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 DESCRIPTION |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This module provides types for use with the modules in L. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
It is intended for internal use, although some of these may be useful |
43
|
|
|
|
|
|
|
for writing plugins (see L). |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 EXPORTS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
None by default. All functions must be explicitly exported. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 C |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The indentation level used for verbatim text. Must be an integer |
52
|
|
|
|
|
|
|
greater than or equal to 2. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub Indentation { |
57
|
|
|
|
|
|
|
state $type = Type::Tiny->new( |
58
|
|
|
|
|
|
|
name => 'Indentation', |
59
|
11
|
50
|
|
11
|
|
1025
|
constraint => sub { $_ =~ /^\d+$/ && $_ >= 2 }, |
60
|
0
|
|
|
0
|
|
0
|
message => sub { 'must be an integer >= 2' }, |
61
|
5
|
|
|
5
|
1
|
82
|
); |
62
|
5
|
|
|
|
|
591
|
return $type; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
A heading level, used for plugin headings. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Must be either 1, 2 or 3. (Note that C<=head4> is not allowed, since |
70
|
|
|
|
|
|
|
some plugins use subheadings.) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub HeadingLevel { |
75
|
|
|
|
|
|
|
state $type = Type::Tiny->new( |
76
|
|
|
|
|
|
|
name => 'HeadingLevel', |
77
|
4
|
|
|
4
|
|
339
|
constraint => sub { $_ =~ /^[123]$/ }, |
78
|
0
|
|
|
0
|
|
0
|
message => sub { 'must be an integer between 1 and 3' }, |
79
|
3
|
|
|
3
|
1
|
56
|
); |
80
|
3
|
|
|
|
|
451
|
return $type; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
A name of a target, e.g. "readme". |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub TargetName { |
90
|
|
|
|
|
|
|
state $type = Type::Tiny->new( |
91
|
|
|
|
|
|
|
name => 'TargetName', |
92
|
11
|
|
|
11
|
|
1092
|
constraint => sub { $_ =~ /^\w+$/ }, |
93
|
0
|
|
|
0
|
|
0
|
message => sub { 'must be an alphanumeric string' }, |
94
|
5
|
|
|
5
|
1
|
56
|
); |
95
|
5
|
|
|
|
|
440
|
return $type; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 C |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
A directory. Can be a string or L object. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub Dir { |
105
|
|
|
|
|
|
|
state $type = Type::Tiny->new( |
106
|
|
|
|
|
|
|
name => 'Dir', |
107
|
|
|
|
|
|
|
constraint => sub { |
108
|
22
|
100
|
66
|
22
|
|
15967
|
blessed($_) |
109
|
|
|
|
|
|
|
&& $_->isa('Path::Tiny') |
110
|
|
|
|
|
|
|
&& -d $_; |
111
|
|
|
|
|
|
|
}, |
112
|
0
|
|
|
0
|
|
0
|
message => sub { "$_ must be be a directory" }, |
113
|
16
|
|
|
16
|
1
|
102
|
); |
114
|
16
|
|
|
11
|
|
601
|
return $type->plus_coercions( Str, sub { path($_) }, ); |
|
11
|
|
|
|
|
157
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 C |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
A file. Can be a string or L object. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub File { |
124
|
|
|
|
|
|
|
state $type = Type::Tiny->new( |
125
|
|
|
|
|
|
|
name => 'File', |
126
|
|
|
|
|
|
|
constraint => sub { |
127
|
38
|
100
|
|
38
|
|
22109
|
blessed($_) |
128
|
|
|
|
|
|
|
&& $_->isa('Path::Tiny'); |
129
|
|
|
|
|
|
|
}, |
130
|
0
|
|
|
0
|
|
0
|
message => sub { "$_ must be be a file" }, |
131
|
36
|
|
|
36
|
1
|
139
|
); |
132
|
36
|
|
|
11
|
|
550
|
return $type->plus_coercions( Str, sub { path($_) }, ); |
|
11
|
|
|
|
|
125
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 C |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
An L or L object. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub IO { |
142
|
|
|
|
|
|
|
state $type = Type::Tiny->new( |
143
|
|
|
|
|
|
|
name => 'IO', |
144
|
|
|
|
|
|
|
constraint => sub { |
145
|
34
|
100
|
66
|
34
|
|
6418
|
blessed($_) |
146
|
|
|
|
|
|
|
&& ( $_->isa('IO::Handle') || $_->isa('IO::String') ); |
147
|
|
|
|
|
|
|
}, |
148
|
0
|
|
|
0
|
|
0
|
message => sub { 'must be be an IO::Handle or IO::String' }, |
149
|
10
|
|
|
10
|
1
|
58
|
); |
150
|
10
|
|
|
|
|
445
|
return $type; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 C |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 C |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L types, which coerce filehandles to read/write L, |
158
|
|
|
|
|
|
|
respectively. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub ReadIO { |
163
|
|
|
|
|
|
|
state $type = IO->plus_coercions( # |
164
|
2
|
|
|
2
|
|
36
|
FileHandle, sub { IO::Handle->new_from_fd( $_, 'r' ) }, |
165
|
9
|
|
|
9
|
1
|
34
|
); |
166
|
9
|
|
|
|
|
2169
|
return $type; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub WriteIO { |
170
|
|
|
|
|
|
|
state $type = IO->plus_coercions( # |
171
|
6
|
|
|
6
|
|
78
|
FileHandle, sub { IO::Handle->new_from_fd( $_, 'w' ) }, |
172
|
22
|
|
|
22
|
1
|
64
|
); |
173
|
22
|
|
|
|
|
1741
|
return $type; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |