| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Egg::Helper::Build::Module; |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# $Id: Module.pm 337 2008-05-14 12:30:09Z lushe $ |
|
6
|
|
|
|
|
|
|
# |
|
7
|
1
|
|
|
1
|
|
369
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp qw/ croak /; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
571
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION= '3.02'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub build_script { |
|
14
|
0
|
|
|
0
|
1
|
|
require Egg::Helper::Util::Base; |
|
15
|
0
|
|
|
|
|
|
print STDOUT <<SCRIPT; |
|
16
|
0
|
|
|
|
|
|
#!@{[ Egg::Helper::Util::Base->helper_perl_path ]} |
|
17
|
|
|
|
|
|
|
use Egg::Helper; |
|
18
|
|
|
|
|
|
|
Egg::Helper->run('Build::Module'); |
|
19
|
|
|
|
|
|
|
SCRIPT |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
sub helper_mod_name_split { |
|
22
|
0
|
|
|
0
|
1
|
|
my $self= shift; |
|
23
|
0
|
|
0
|
|
|
|
my $mod_name= shift || croak 'I want module name.'; |
|
24
|
0
|
|
|
|
|
|
my @parts; |
|
25
|
0
|
|
|
|
|
|
for (split /(?:\:+|\-)/, $mod_name) { |
|
26
|
0
|
|
|
|
|
|
$_= ucfirst $_; |
|
27
|
0
|
0
|
|
|
|
|
/^[A-Z][A-Za-z0-9_]+$/ || return (undef); |
|
28
|
0
|
|
|
|
|
|
push @parts, $_; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
0
|
|
|
|
|
|
\@parts; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
sub helper_mod_template { |
|
33
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
34
|
0
|
|
|
|
|
|
[ $self->helper_yaml_load(join '', <DATA>) ]; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
sub _start_helper { |
|
37
|
0
|
|
|
0
|
|
|
my($self)= @_; |
|
38
|
0
|
|
|
|
|
|
my $c= $self->config; |
|
39
|
0
|
|
0
|
|
|
|
my $mod_name= shift(@ARGV) |
|
40
|
|
|
|
|
|
|
|| return $self->_helper_help('I want module name.'); |
|
41
|
0
|
|
0
|
|
|
|
my $parts= $self->helper_mod_name_split($mod_name) |
|
42
|
|
|
|
|
|
|
|| return $self->_helper_help('Bad format of plugin name.'); |
|
43
|
0
|
|
|
|
|
|
my $o= $self->_helper_get_options; |
|
44
|
0
|
|
0
|
|
|
|
my $version= $self->helper_valid_version_number($o->{version}) || return 0; |
|
45
|
0
|
|
0
|
|
|
|
my $param = $self->helper_prepare_param({ |
|
46
|
|
|
|
|
|
|
output_path => ($o->{output} || $self->helper_current_dir), |
|
47
|
|
|
|
|
|
|
module_version => $version, |
|
48
|
|
|
|
|
|
|
module_generator => __PACKAGE__, |
|
49
|
|
|
|
|
|
|
created => __PACKAGE__. " v$VERSION", |
|
50
|
|
|
|
|
|
|
}); |
|
51
|
0
|
|
|
|
|
|
$self->helper_prepare_param_module($param, $parts); |
|
52
|
0
|
0
|
|
|
|
|
-e $param->{target_path} and |
|
53
|
|
|
|
|
|
|
return $self->_helper_help("$param->{target_path} A already exists."); |
|
54
|
0
|
|
|
|
|
|
$param->{module_output_filepath}= |
|
55
|
|
|
|
|
|
|
"$param->{lib_dir}/$param->{module_filepath}"; |
|
56
|
0
|
0
|
|
|
|
|
$self->helper_generate_files( |
|
57
|
|
|
|
|
|
|
param => $param, |
|
58
|
|
|
|
|
|
|
chdir => [$param->{target_path}, 1], |
|
59
|
|
|
|
|
|
|
create_files => $self->helper_mod_template, |
|
60
|
|
|
|
|
|
|
makemaker_ok => ($o->{unmake} ? 0: 1), |
|
61
|
|
|
|
|
|
|
errors => { rmdir=> [$param->{target_path}] }, |
|
62
|
|
|
|
|
|
|
complete_msg => "\nModule generate is completed.\n\n" |
|
63
|
|
|
|
|
|
|
. "output path : $param->{target_path}\n" |
|
64
|
|
|
|
|
|
|
); |
|
65
|
0
|
|
|
|
|
|
$self; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
sub _helper_get_options { |
|
68
|
0
|
|
|
0
|
|
|
shift->next::method(' v-version= m-unmake '); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
sub _helper_help { |
|
71
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
72
|
0
|
|
0
|
|
|
|
my $msg = shift || ""; |
|
73
|
0
|
0
|
|
|
|
|
$msg= "ERROR: ${msg}\n\n" if $msg; |
|
74
|
0
|
|
|
|
|
|
print <<END_HELP; |
|
75
|
|
|
|
|
|
|
${msg}% egg_module_builder.pl [MODULE_NAME] [-o OUTPUT_PATH] [-v VERSION] |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
END_HELP |
|
78
|
0
|
|
|
|
|
|
0; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 NAME |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Egg::Helper::Build::Module - The module file complete set is generated. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
% perl -MEgg::Helper::Build::Module \ |
|
90
|
|
|
|
|
|
|
-e 'Egg::Helper::Build::Module->build_script' \ |
|
91
|
|
|
|
|
|
|
> /path/to/egg_module_builder.pl |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
% perl egg_module_builder.pl MyModule |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
It is a helper who generates the module file complete set. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This helper generates the file complete set that L<ExtUtils::MakeMaker> outputs. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The thing that starts specifying the mode of the helper script can be done, |
|
102
|
|
|
|
|
|
|
and the thing that generates a special script from 'build_script' method and |
|
103
|
|
|
|
|
|
|
uses it can be done. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The file complete set is generated when starting specifying the module name made |
|
106
|
|
|
|
|
|
|
for the generated script. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
% perl egg_module_builder.pl [MODULE_NAME] |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The file that this module outputs is as follows. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Build.PL |
|
113
|
|
|
|
|
|
|
Changes |
|
114
|
|
|
|
|
|
|
Makefile.PL |
|
115
|
|
|
|
|
|
|
MANIFEST |
|
116
|
|
|
|
|
|
|
README |
|
117
|
|
|
|
|
|
|
t/00_use.t |
|
118
|
|
|
|
|
|
|
t/89_pod.t |
|
119
|
|
|
|
|
|
|
t/98_perlcritic.t |
|
120
|
|
|
|
|
|
|
t/99_pod_coverage.t~ |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 METHODS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 build_script |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The start script only for this helper is returned and the code is returned. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
% perl -MEgg::Helper::Build::Module -e 'Egg::Helper::Build::Module->build_script' |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 helper_mod_name_split ([MODULE_NAME]) |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The ARRAY reference into which MODULE_NAME is divided by ':' and '-' is returned. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Undefined is returned if there is suitably no divided each value as a module name |
|
135
|
|
|
|
|
|
|
of Perl. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $parts= $self->helper_mod_name_split($module_name) || return 0; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 helper_mod_template |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Each template of the output file is settled by the ARRAY reference and it |
|
142
|
|
|
|
|
|
|
returns it. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Each value of ARRAY is HASH form to pass it to 'helper_create_files' method. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
my $files= $self->helper_mod_template; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L<Egg::Release>, |
|
151
|
|
|
|
|
|
|
L<Egg::Helper>, |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
162
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
|
163
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
__DATA__ |
|
170
|
|
|
|
|
|
|
--- |
|
171
|
|
|
|
|
|
|
filename: <e.module_output_filepath> |
|
172
|
|
|
|
|
|
|
filetype: module |
|
173
|
|
|
|
|
|
|
value: | |
|
174
|
|
|
|
|
|
|
package <e.module_distname>; |
|
175
|
|
|
|
|
|
|
# |
|
176
|
|
|
|
|
|
|
# Copyright (C) <e.year> <e.headcopy>. |
|
177
|
|
|
|
|
|
|
# <e.author> |
|
178
|
|
|
|
|
|
|
# |
|
179
|
|
|
|
|
|
|
# <e.revision> |
|
180
|
|
|
|
|
|
|
# |
|
181
|
|
|
|
|
|
|
use strict; |
|
182
|
|
|
|
|
|
|
use warnings; |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
our $VERSION = '<e.module_version>'; |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# ... Let's write the perl code here. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# Please refer to L<<e.module_generator>> for hook of Egg. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1; |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
__END__ |
|
193
|
|
|
|
|
|
|
<e.document> |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
--- |
|
196
|
|
|
|
|
|
|
filename: Makefile.PL |
|
197
|
|
|
|
|
|
|
value: | |
|
198
|
|
|
|
|
|
|
use inc::Module::Install; |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
name '<e.module_name>'; |
|
201
|
|
|
|
|
|
|
all_from 'lib/<e.module_filepath>'; |
|
202
|
|
|
|
|
|
|
version_from 'lib/<e.module_filepath>'; |
|
203
|
|
|
|
|
|
|
abstract_from 'lib/<e.module_filepath>'; |
|
204
|
|
|
|
|
|
|
author '<e.author>'; |
|
205
|
|
|
|
|
|
|
license '<e.license>'; |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
requires 'Egg::Release' => <e.egg_release_version>; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
build_requires 'Test::More'; |
|
210
|
|
|
|
|
|
|
build_requires 'Test::Pod'; |
|
211
|
|
|
|
|
|
|
# build_requires 'Test::Perl::Critic'; |
|
212
|
|
|
|
|
|
|
# build_requires 'Test::Pod::Coverage'; |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
use_test_base; |
|
215
|
|
|
|
|
|
|
auto_include; |
|
216
|
|
|
|
|
|
|
WriteAll; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
--- |
|
219
|
|
|
|
|
|
|
filename: t/00_use.t |
|
220
|
|
|
|
|
|
|
value: | |
|
221
|
|
|
|
|
|
|
# Before `make install' is performed this script should be runnable with |
|
222
|
|
|
|
|
|
|
# `make test'. After `make install' it should work as `perl test.t' |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
######################### |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# change 'tests => 1' to 'tests => last_test_to_print'; |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
use Test::More tests => 1; |
|
229
|
|
|
|
|
|
|
BEGIN { use_ok('<e.module_distname>') }; |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
######################### |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Insert your test code below, the Test::More module is use()ed here so read |
|
234
|
|
|
|
|
|
|
# its man page ( perldoc Test::More ) for help writing this test script. |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
--- |
|
237
|
|
|
|
|
|
|
filename: t/89_pod.t |
|
238
|
|
|
|
|
|
|
value: | |
|
239
|
|
|
|
|
|
|
use Test::More; |
|
240
|
|
|
|
|
|
|
eval "use Test::Pod 1.00"; |
|
241
|
|
|
|
|
|
|
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; |
|
242
|
|
|
|
|
|
|
all_pod_files_ok(); |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
--- |
|
245
|
|
|
|
|
|
|
filename: t/98_perlcritic.t |
|
246
|
|
|
|
|
|
|
value: | |
|
247
|
|
|
|
|
|
|
use strict; |
|
248
|
|
|
|
|
|
|
use Test::More; |
|
249
|
|
|
|
|
|
|
eval q{ use Test::Perl::Critic }; |
|
250
|
|
|
|
|
|
|
plan skip_all => "Test::Perl::Critic is not installed." if $@; |
|
251
|
|
|
|
|
|
|
all_critic_ok("lib"); |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
--- |
|
254
|
|
|
|
|
|
|
filename: t/99_pod_coverage.t~ |
|
255
|
|
|
|
|
|
|
value: | |
|
256
|
|
|
|
|
|
|
use Test::More; |
|
257
|
|
|
|
|
|
|
eval "use Test::Pod::Coverage 1.00"; |
|
258
|
|
|
|
|
|
|
plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; |
|
259
|
|
|
|
|
|
|
all_pod_coverage_ok(); |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
--- |
|
262
|
|
|
|
|
|
|
filename: Changes |
|
263
|
|
|
|
|
|
|
value: | |
|
264
|
|
|
|
|
|
|
Revision history for Perl extension <$e.distname>. |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
<e.module_version> <e.gmtime_string> |
|
267
|
|
|
|
|
|
|
- original version; created by <e.created> |
|
268
|
|
|
|
|
|
|
with module name <e.module_distname> |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
--- |
|
271
|
|
|
|
|
|
|
filename: README |
|
272
|
|
|
|
|
|
|
value: | |
|
273
|
|
|
|
|
|
|
<e.module_distname>. |
|
274
|
|
|
|
|
|
|
================================================= |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
The README is used to introduce the module and provide instructions on |
|
277
|
|
|
|
|
|
|
how to install the module, any machine dependencies it may have (for |
|
278
|
|
|
|
|
|
|
example C compilers and installed libraries) and any other information |
|
279
|
|
|
|
|
|
|
that should be provided before the module is installed. |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
A README file is required for CPAN modules since CPAN extracts the |
|
282
|
|
|
|
|
|
|
README file from a module distribution so that people browsing the |
|
283
|
|
|
|
|
|
|
archive can use it get an idea of the modules uses. It is usually a |
|
284
|
|
|
|
|
|
|
good idea to provide version information here so that people can |
|
285
|
|
|
|
|
|
|
decide whether fixes for the module are worth downloading. |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
INSTALLATION |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
To install this module type the following: |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
perl Makefile.PL |
|
292
|
|
|
|
|
|
|
make |
|
293
|
|
|
|
|
|
|
make test |
|
294
|
|
|
|
|
|
|
make install |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
AUTHOR |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
<e.author> |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
COPYRIGHT AND LICENCE |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Put the correct copyright and licence information here. |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Copyright (C) <e.year> by <e.copyright>. |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
307
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
|
308
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
--- |
|
311
|
|
|
|
|
|
|
filename: MANIFEST.SKIP |
|
312
|
|
|
|
|
|
|
value: | |
|
313
|
|
|
|
|
|
|
\bRCS\b |
|
314
|
|
|
|
|
|
|
\bCVS\b |
|
315
|
|
|
|
|
|
|
^blib/ |
|
316
|
|
|
|
|
|
|
^_build/ |
|
317
|
|
|
|
|
|
|
^MANIFEST\. |
|
318
|
|
|
|
|
|
|
^Makefile$ |
|
319
|
|
|
|
|
|
|
^pm_to_blib |
|
320
|
|
|
|
|
|
|
^MakeMaker-\d |
|
321
|
|
|
|
|
|
|
^t/9\d+_.*\.t |
|
322
|
|
|
|
|
|
|
Build$ |
|
323
|
|
|
|
|
|
|
\.cvsignore |
|
324
|
|
|
|
|
|
|
\.?svn* |
|
325
|
|
|
|
|
|
|
^\% |
|
326
|
|
|
|
|
|
|
(~|\-|\.(old|save|back|gz))$ |