| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dist::Man::Plugin::Template; |
|
2
|
|
|
|
|
|
|
# vi:et:sw=4 ts=4 |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1840
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp qw( confess ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
668
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Dist::Man::Plugin::Template - dist manager with templates |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.0.6 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.0.8'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Dist::Man qw( |
|
23
|
|
|
|
|
|
|
Dist::Man::Simple |
|
24
|
|
|
|
|
|
|
Dist::Man::Plugin::Template |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Dist::Man->create_distro(%args); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This plugin is designed to be added to a Dist::Man::Simple-compatible |
|
32
|
|
|
|
|
|
|
Dist::Man class. It adds stub methods for template retrieval and |
|
33
|
|
|
|
|
|
|
rendering, and it replaces all of Simple's _guts methods with methods that will |
|
34
|
|
|
|
|
|
|
retrieve and render the apropriate templates. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 CLASS METHODS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 C<< new(%args) >> |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
This plugin calls the C supermethod and then initializes the template |
|
41
|
|
|
|
|
|
|
store and renderer. (See C and C below.) |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
|
46
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
47
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
48
|
0
|
|
|
|
|
|
$self->{templates} = { $self->templates }; |
|
49
|
0
|
|
|
|
|
|
$self->{renderer} = $self->renderer; |
|
50
|
0
|
|
|
|
|
|
return bless $self => $class; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 C<< templates() >> |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This method is used to initialize the template store on the Dist::Man |
|
58
|
|
|
|
|
|
|
object. It returns a hash of templates; each key is a filename and each value |
|
59
|
|
|
|
|
|
|
is the body of the template. The filename F is used for the module |
|
60
|
|
|
|
|
|
|
template. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub templates { |
|
65
|
0
|
|
|
0
|
1
|
|
confess 'attempted to use abstract base templates method'; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 C<< renderer() >> |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This method is used to initialize the template renderer. Its result is stored |
|
71
|
|
|
|
|
|
|
in the object's C entry. The implementation will determine its use. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub renderer { |
|
76
|
0
|
|
|
0
|
1
|
|
confess 'attempted to use abstract base renderer method'; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 C<< render($template, \%options) >> |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The C method will render the template passed to it, using the |
|
82
|
|
|
|
|
|
|
data in the Dist::Man object and in the hash of passed parameters. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub render { |
|
87
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
88
|
0
|
|
|
|
|
|
my $template = shift; |
|
89
|
0
|
|
|
|
|
|
my $options = shift; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
confess 'attempted to use abstract base render method'; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 _guts methods |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
All of the C methods from Dist::Man::Simple are subclassed to |
|
97
|
|
|
|
|
|
|
look something like this: |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub file_guts { |
|
100
|
|
|
|
|
|
|
my $self = shift; |
|
101
|
|
|
|
|
|
|
my %options; |
|
102
|
|
|
|
|
|
|
@options{qw(first second third)} = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $template = $self->{templates}{filename}; |
|
105
|
|
|
|
|
|
|
$self->render($template, \%options); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
These methods will need to be rewritten when (as is likely) |
|
109
|
|
|
|
|
|
|
Dist::Man::Simple's _guts methods are refactored into a registry. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over 4 |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item module_guts |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub module_guts { |
|
118
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
119
|
0
|
|
|
|
|
|
my %options; |
|
120
|
0
|
|
|
|
|
|
@options{qw(module rtname)} = @_; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
my $template = $self->{templates}{'Module.pm'}; |
|
123
|
0
|
|
|
|
|
|
$self->render($template, \%options); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item Makefile_PL_guts |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub Makefile_PL_guts { |
|
131
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
132
|
0
|
|
|
|
|
|
my %options; |
|
133
|
0
|
|
|
|
|
|
@options{qw(main_module main_pm_file)} = @_; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $template = $self->{templates}{'Makefile.PL'}; |
|
136
|
0
|
|
|
|
|
|
$self->render($template, \%options); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item MI_Makefile_PL_guts |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub MI_Makefile_PL_guts { |
|
144
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
145
|
0
|
|
|
|
|
|
my %options; |
|
146
|
0
|
|
|
|
|
|
@options{qw(main_module main_pm_file)} = @_; |
|
147
|
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my $template = $self->{templates}{'MI_Makefile.PL'}; |
|
149
|
0
|
|
|
|
|
|
$self->render($template, \%options); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item Build_PL_guts |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub Build_PL_guts { |
|
157
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
158
|
0
|
|
|
|
|
|
my %options; |
|
159
|
0
|
|
|
|
|
|
@options{qw(main_module main_pm_file)} = @_; |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
my $template = $self->{templates}{'Build.PL'}; |
|
162
|
0
|
|
|
|
|
|
$self->render($template, \%options); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item Changes_guts |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub Changes_guts { |
|
170
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $template = $self->{templates}{'Changes'}; |
|
173
|
0
|
|
|
|
|
|
$self->render($template); |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item README_guts |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub README_guts { |
|
181
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
182
|
0
|
|
|
|
|
|
my %options; |
|
183
|
0
|
|
|
|
|
|
@options{qw(build_instructions)} = @_; |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
my $template = $self->{templates}{'README'}; |
|
186
|
0
|
|
|
|
|
|
$self->render($template, \%options); |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item t_guts |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub t_guts { |
|
194
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
195
|
0
|
|
|
|
|
|
my %options; |
|
196
|
0
|
|
|
|
|
|
$options{modules} = [ @_ ]; |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
my %t_files; |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
foreach (grep { /\.t$/ } keys %{$self->{templates}}) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
my $template = $self->{templates}{$_}; |
|
202
|
0
|
|
|
|
|
|
$t_files{$_} = $self->render($template, \%options); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
return %t_files; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item MANIFEST_guts |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub MANIFEST_guts { |
|
213
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
214
|
0
|
|
|
|
|
|
my %options; |
|
215
|
0
|
|
|
|
|
|
$options{files} = [ sort @_ ]; |
|
216
|
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
my $template = $self->{templates}{MANIFEST}; |
|
218
|
0
|
|
|
|
|
|
$self->render($template, \%options); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item item ignores_guts |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub ignores_guts { |
|
226
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
my $template = $self->{templates}{ignores}; |
|
229
|
0
|
|
|
|
|
|
$self->render($template); |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=back |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 AUTHOR |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Ricardo SIGNES, C<< >> |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 Bugs |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
241
|
|
|
|
|
|
|
C, or through the web interface at |
|
242
|
|
|
|
|
|
|
L. I will be notified, and then you'll automatically be |
|
243
|
|
|
|
|
|
|
notified of progress on your bug as I make changes. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 Module::Starter::Template |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Copyright 2005-2007 Ricardo SIGNES, All Rights Reserved. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
252
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head2 Dist::Man::Template |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Modified by Shlomi Fish while disclaiming any explicit or implicit ownership. |
|
257
|
|
|
|
|
|
|
May be used under the present or future terms of |
|
258
|
|
|
|
|
|
|
L. |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=cut |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
1; |