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