| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
App::CPANModuleSite - Automatically create a web site for a CPAN module. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# From a command line |
|
8
|
|
|
|
|
|
|
$ mksite My::Lovely::Module |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
It's probably not particularly useful to use the class directly. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package App::CPANModuleSite; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.0.8'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
76912
|
use v5.14; |
|
|
2
|
|
|
|
|
18
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
1082
|
use MetaCPAN::Client; |
|
|
2
|
|
|
|
|
756492
|
|
|
|
2
|
|
|
|
|
69
|
|
|
21
|
2
|
|
|
2
|
|
1150
|
use Template; |
|
|
2
|
|
|
|
|
38854
|
|
|
|
2
|
|
|
|
|
65
|
|
|
22
|
2
|
|
|
2
|
|
1331
|
use Path::Iterator::Rule; |
|
|
2
|
|
|
|
|
27832
|
|
|
|
2
|
|
|
|
|
70
|
|
|
23
|
2
|
|
|
2
|
|
1074
|
use File::Copy; |
|
|
2
|
|
|
|
|
4725
|
|
|
|
2
|
|
|
|
|
119
|
|
|
24
|
2
|
|
|
2
|
|
1178
|
use Moose; |
|
|
2
|
|
|
|
|
1056970
|
|
|
|
2
|
|
|
|
|
17
|
|
|
25
|
2
|
|
|
2
|
|
14751
|
use Moose::Util::TypeConstraints; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
22
|
|
|
26
|
2
|
|
|
2
|
|
5761
|
use File::ShareDir 'dist_dir'; |
|
|
2
|
|
|
|
|
37707
|
|
|
|
2
|
|
|
|
|
2086
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
subtype 'App::CPANModuleSite::Str', |
|
29
|
|
|
|
|
|
|
as 'Str'; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
coerce 'MetaCPAN::Client::Distribution', |
|
32
|
|
|
|
|
|
|
from 'App::CPANModuleSite::Str', |
|
33
|
|
|
|
|
|
|
via { |
|
34
|
|
|
|
|
|
|
MetaCPAN::Client->new->distribution($_); |
|
35
|
|
|
|
|
|
|
}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has distribution => ( |
|
38
|
|
|
|
|
|
|
is => 'ro', |
|
39
|
|
|
|
|
|
|
isa => 'MetaCPAN::Client::Distribution', |
|
40
|
|
|
|
|
|
|
required => 1, |
|
41
|
|
|
|
|
|
|
coerce => 1, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has metacpan => ( |
|
45
|
|
|
|
|
|
|
is => 'ro', |
|
46
|
|
|
|
|
|
|
isa => 'MetaCPAN::Client', |
|
47
|
|
|
|
|
|
|
lazy_build => 1, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _build_metacpan { |
|
51
|
0
|
|
|
0
|
|
|
return MetaCPAN::Client->new; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has release => ( |
|
55
|
|
|
|
|
|
|
is => 'ro', |
|
56
|
|
|
|
|
|
|
isa => 'MetaCPAN::Client::Release', |
|
57
|
|
|
|
|
|
|
lazy_build => 1, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _build_release { |
|
61
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self->metacpan->release($self->distribution->name); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has modules => ( |
|
67
|
|
|
|
|
|
|
is => 'ro', |
|
68
|
|
|
|
|
|
|
isa => 'ArrayRef[MetaCPAN::Client::Module]', |
|
69
|
|
|
|
|
|
|
lazy_build => 1, |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _build_modules { |
|
73
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return [ map { $self->metacpan->module($_) } @{ $self->release->provides } ]; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has tt => ( |
|
79
|
|
|
|
|
|
|
is => 'ro', |
|
80
|
|
|
|
|
|
|
isa => 'Template', |
|
81
|
|
|
|
|
|
|
lazy_build => 1, |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _build_tt { |
|
85
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return Template->new($self->tt_config); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
has tt_config => ( |
|
91
|
|
|
|
|
|
|
is => 'ro', |
|
92
|
|
|
|
|
|
|
isa => 'HashRef', |
|
93
|
|
|
|
|
|
|
lazy_build => 1, |
|
94
|
|
|
|
|
|
|
); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _build_tt_config { |
|
97
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return { |
|
100
|
0
|
0
|
|
|
|
|
INCLUDE_PATH => $self->include_path, |
|
101
|
|
|
|
|
|
|
OUTPUT_PATH => $self->output_path, |
|
102
|
|
|
|
|
|
|
( $self->wrapper ? ( WRAPPER => $self->wrapper ) : () ), |
|
103
|
|
|
|
|
|
|
RELATIVE => 1, |
|
104
|
|
|
|
|
|
|
VARIABLES => { |
|
105
|
|
|
|
|
|
|
distribution => $self->distribution, |
|
106
|
|
|
|
|
|
|
release => $self->release, |
|
107
|
|
|
|
|
|
|
modules => $self->modules, |
|
108
|
|
|
|
|
|
|
base => $self->base, |
|
109
|
|
|
|
|
|
|
}, |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
has [ qw[site_src local_site_src tt_lib local_tt_lib] ] => ( |
|
114
|
|
|
|
|
|
|
is => 'ro', |
|
115
|
|
|
|
|
|
|
isa => 'Str', |
|
116
|
|
|
|
|
|
|
lazy_build => 1, |
|
117
|
|
|
|
|
|
|
); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _build_site_src { |
|
120
|
0
|
|
|
0
|
|
|
return dist_dir('App-CPANModuleSite') . '/site_src'; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _build_local_site_src { |
|
124
|
0
|
|
|
0
|
|
|
return './site_src'; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub _build_tt_lib { |
|
128
|
0
|
|
|
0
|
|
|
return dist_dir('App-CPANModuleSite') . '/tt_lib'; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub _build_local_tt_lib { |
|
132
|
0
|
|
|
0
|
|
|
return './tt_lib'; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
has include_path => ( |
|
136
|
|
|
|
|
|
|
is => 'ro', |
|
137
|
|
|
|
|
|
|
isa => 'ArrayRef', |
|
138
|
|
|
|
|
|
|
lazy_build => 1, |
|
139
|
|
|
|
|
|
|
); |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub _build_include_path { |
|
142
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
return [ |
|
145
|
0
|
|
|
|
|
|
$self->local_tt_lib, |
|
146
|
|
|
|
|
|
|
$self->local_site_src, |
|
147
|
|
|
|
|
|
|
$self->tt_lib, |
|
148
|
|
|
|
|
|
|
$self->site_src, |
|
149
|
|
|
|
|
|
|
]; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
has output_path => ( |
|
153
|
|
|
|
|
|
|
is => 'ro', |
|
154
|
|
|
|
|
|
|
isa => 'Str', |
|
155
|
|
|
|
|
|
|
lazy_build => 1, |
|
156
|
|
|
|
|
|
|
); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub _build_output_path { |
|
159
|
0
|
|
|
0
|
|
|
return './docs'; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
has wrapper => ( |
|
163
|
|
|
|
|
|
|
is => 'ro', |
|
164
|
|
|
|
|
|
|
isa => 'Str', |
|
165
|
|
|
|
|
|
|
lazy_build => 1, |
|
166
|
|
|
|
|
|
|
); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub _build_wrapper { |
|
169
|
0
|
|
|
0
|
|
|
return 'page.tt'; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
has base => ( |
|
173
|
|
|
|
|
|
|
is => 'ro', |
|
174
|
|
|
|
|
|
|
isa => 'Str', |
|
175
|
|
|
|
|
|
|
default => '', |
|
176
|
|
|
|
|
|
|
); |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
179
|
|
|
|
|
|
|
my $orig = shift; |
|
180
|
|
|
|
|
|
|
my $class = shift; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
if ( @_ == 1 && !ref $_[0] ) { |
|
183
|
|
|
|
|
|
|
return $class->$orig( distribution => $_[0] ); |
|
184
|
|
|
|
|
|
|
} else { |
|
185
|
|
|
|
|
|
|
return $class->$orig(@_); |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
}; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 METHODS |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 run |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
The main driver method for the class. Does the following steps: |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=over 4 |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * Creates a list of input files |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item * Uses Template Toolkit to process the templates |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item * Copies any non-template files into the output tree |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item * Creates a HTML version of the Pod from all the modules |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=back |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub run { |
|
210
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
my $finder = Path::Iterator::Rule->new->file; |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
my @src_dirs = ($self->local_site_src, $self->site_src); |
|
215
|
0
|
|
|
|
|
|
my %src_files = map { $_ => 1 } |
|
|
0
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
$finder->all($self->site_src, { relative => 1 }); |
|
217
|
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
for ( keys %src_files ) { |
|
219
|
0
|
0
|
|
|
|
|
if (/\.tt$/) { |
|
220
|
0
|
|
|
|
|
|
$self->process_template($_); |
|
221
|
|
|
|
|
|
|
} else { |
|
222
|
0
|
|
|
|
|
|
$self->copy_file($_); |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
foreach (@{ $self->modules }) { |
|
|
0
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
my $outpath = $_->path =~ s/\.pm$/.html/r; |
|
228
|
0
|
|
|
|
|
|
my $pod = $_->pod('html'); |
|
229
|
0
|
|
|
|
|
|
$self->tt->process(\$pod, undef, $outpath); |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub process_template { |
|
234
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
235
|
0
|
|
|
|
|
|
my ($template) = @_; |
|
236
|
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
my $output = $template =~ s/\.tt$//r; |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
0
|
|
|
|
|
$self->tt->process($template, undef, $output) |
|
240
|
|
|
|
|
|
|
or die $self->tt->error; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub copy_file { |
|
244
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
245
|
0
|
|
|
|
|
|
my ($file) = @_; |
|
246
|
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
copy($file, $self->output_path . "/$file"); |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
1; |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 AUTHOR |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Dave Cross <dave@perlhacks.com> |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
L<mksite> |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Copyright (C) 2021, Magnum Solutions Ltd. All Rights Reserved. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This script is free software; you can redistribute it and/or modify it |
|
265
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=cut |