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