line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ExtUtils::ModuleMaker::Initializers; |
2
|
86
|
|
|
86
|
|
363
|
use strict; |
|
86
|
|
|
|
|
85
|
|
|
86
|
|
|
|
|
1838
|
|
3
|
86
|
|
|
86
|
|
227
|
use warnings; |
|
86
|
|
|
|
|
85
|
|
|
86
|
|
|
|
|
1759
|
|
4
|
86
|
|
|
86
|
|
238
|
use vars qw( $VERSION ); |
|
86
|
|
|
|
|
81
|
|
|
86
|
|
|
|
|
3331
|
|
5
|
|
|
|
|
|
|
$VERSION = 0.56; |
6
|
86
|
|
|
|
|
6742
|
use ExtUtils::ModuleMaker::Licenses::Standard qw( |
7
|
|
|
|
|
|
|
Get_Standard_License |
8
|
|
|
|
|
|
|
Verify_Standard_License |
9
|
86
|
|
|
86
|
|
104056
|
); |
|
86
|
|
|
|
|
147
|
|
10
|
86
|
|
|
|
|
86593
|
use ExtUtils::ModuleMaker::Licenses::Local qw( |
11
|
|
|
|
|
|
|
Get_Local_License |
12
|
|
|
|
|
|
|
Verify_Local_License |
13
|
86
|
|
|
86
|
|
32632
|
); |
|
86
|
|
|
|
|
131
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
ExtUtils::ModuleMaker::Initializers - Methods used within C and C |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
The methods described below are 'quasi-private' methods which are called by |
22
|
|
|
|
|
|
|
certain publicly available methods of ExtUtils::ModuleMaker and |
23
|
|
|
|
|
|
|
ExtUtils::ModuleMaker::Interactive. They are 'quasi-private' in the sense |
24
|
|
|
|
|
|
|
that they are not intended to be called by the everyday user of |
25
|
|
|
|
|
|
|
ExtUtils::ModuleMaker. Nothing prevents a user from calling these |
26
|
|
|
|
|
|
|
methods, but they are documented here primarily so that users |
27
|
|
|
|
|
|
|
writing plug-ins for ExtUtils::ModuleMaker will know what methods |
28
|
|
|
|
|
|
|
need to be subclassed. I
|
29
|
|
|
|
|
|
|
names and functionality may change in future versions of |
30
|
|
|
|
|
|
|
ExtUtils::ModuleMaker.> |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The methods below are called in C but not in |
33
|
|
|
|
|
|
|
that same package's C. For methods called in |
34
|
|
|
|
|
|
|
C, please see ExtUtils::ModuleMaker::StandardText. Some of |
35
|
|
|
|
|
|
|
the methods below are also called within methods in |
36
|
|
|
|
|
|
|
ExtUtils::ModuleMaker::Interactive. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Subclassers: At ExtUtils::ModuleMaker's current state of development, it is |
39
|
|
|
|
|
|
|
recommended that you I subclass these methods but instead focus your |
40
|
|
|
|
|
|
|
efforts on subclassing the methods in ExtUtils::ModuleMaker::StandardText. |
41
|
|
|
|
|
|
|
The latter package's methods focus more closely on the structure and content |
42
|
|
|
|
|
|
|
of the files built by ExtUtils::ModuleMaker. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Happy subclassing! |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 Methods Called within C |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head3 C |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Usage : $self->set_author_composite() within new() and |
53
|
|
|
|
|
|
|
Interactive::Main_Menu() |
54
|
|
|
|
|
|
|
Purpose : Sets $self key COMPOSITE by composing it from $self keys AUTHOR, |
55
|
|
|
|
|
|
|
CPANID, ORGANIZATION, EMAIL and WEBSITE |
56
|
|
|
|
|
|
|
Returns : n/a |
57
|
|
|
|
|
|
|
Argument : n/a |
58
|
|
|
|
|
|
|
Comment : |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub set_author_composite { |
63
|
89
|
|
|
89
|
1
|
152
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
89
|
|
|
|
|
126
|
my ($cpan_message, $org, $web, $composite); |
66
|
89
|
100
|
|
|
|
406
|
$cpan_message = "CPAN ID: $self->{CPANID}" if $self->{CPANID}; |
67
|
89
|
100
|
|
|
|
281
|
$org = $self->{ORGANIZATION} if $self->{ORGANIZATION}; |
68
|
89
|
100
|
|
|
|
265
|
$web = $self->{WEBSITE} if $self->{WEBSITE}; |
69
|
|
|
|
|
|
|
my @data = ( |
70
|
|
|
|
|
|
|
$self->{AUTHOR}, |
71
|
|
|
|
|
|
|
$cpan_message, |
72
|
|
|
|
|
|
|
$org, |
73
|
|
|
|
|
|
|
$self->{EMAIL}, |
74
|
89
|
|
|
|
|
286
|
$web, |
75
|
|
|
|
|
|
|
); |
76
|
89
|
|
|
|
|
157
|
$composite = " $data[0]"; |
77
|
89
|
|
|
|
|
321
|
for my $el (@data[1..$#data]) { |
78
|
356
|
100
|
|
|
|
850
|
$composite .= "\n $el" if defined $el; |
79
|
|
|
|
|
|
|
} |
80
|
89
|
|
|
|
|
307
|
$self->{COMPOSITE} = $composite; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head3 C |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Usage : $self->set_file_composite() within new() |
86
|
|
|
|
|
|
|
Purpose : Sets $self key COMPOSITE by composing it from $self key NAME |
87
|
|
|
|
|
|
|
Returns : n/a |
88
|
|
|
|
|
|
|
Argument : n/a |
89
|
|
|
|
|
|
|
Comment : |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub set_file_composite { |
94
|
80
|
|
|
80
|
1
|
120
|
my $self = shift; |
95
|
|
|
|
|
|
|
|
96
|
80
|
|
|
|
|
360
|
my @layers = split( /::/, $self->{NAME} ); |
97
|
80
|
|
|
|
|
148
|
my $file = pop(@layers); |
98
|
80
|
|
|
|
|
158
|
$file .= '.pm'; |
99
|
80
|
|
|
|
|
197
|
my $dir = join( '/', 'lib', @layers ); |
100
|
80
|
|
|
|
|
333
|
$self->{FILE} = join( '/', $dir, $file ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head3 C |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Usage : $self->set_dates() within new() |
106
|
|
|
|
|
|
|
Purpose : Sets 3 keys in $self: year, timestamp and COPYRIGHT_YEAR |
107
|
|
|
|
|
|
|
Returns : n/a |
108
|
|
|
|
|
|
|
Argument : n/a |
109
|
|
|
|
|
|
|
Comment : |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub set_dates { |
114
|
89
|
|
|
89
|
1
|
142
|
my $self = shift; |
115
|
89
|
|
|
|
|
7306
|
$self->{year} = (localtime)[5] + 1900; |
116
|
89
|
|
|
|
|
1564
|
$self->{timestamp} = scalar localtime; |
117
|
89
|
|
66
|
|
|
863
|
$self->{COPYRIGHT_YEAR} ||= $self->{year}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head3 C |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Usage : $self->validate_values() within complete_build() and |
123
|
|
|
|
|
|
|
Interactive::Main_Menu() |
124
|
|
|
|
|
|
|
Purpose : Verify module values are valid and complete. |
125
|
|
|
|
|
|
|
Returns : Error message if there is a problem |
126
|
|
|
|
|
|
|
Argument : n/a |
127
|
|
|
|
|
|
|
Throws : Will die with a death_message if errors and not interactive. |
128
|
|
|
|
|
|
|
Comment : References many $self keys |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub validate_values { |
133
|
89
|
|
|
89
|
1
|
145
|
my $self = shift; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Key: short-hand name for error condition |
136
|
|
|
|
|
|
|
# Value: anonymous array holding: |
137
|
|
|
|
|
|
|
# [0]: error message |
138
|
|
|
|
|
|
|
# [1]: condition which will generate error message if evals true |
139
|
|
|
|
|
|
|
my %error_msg = ( |
140
|
|
|
|
|
|
|
NAME_REQ => [ |
141
|
|
|
|
|
|
|
q{NAME is required}, |
142
|
89
|
|
|
|
|
348
|
eval { ! $self->{NAME}; }, |
143
|
|
|
|
|
|
|
], |
144
|
|
|
|
|
|
|
NAME_ILLEGAL => [ |
145
|
|
|
|
|
|
|
q{Module NAME contains illegal characters}, |
146
|
89
|
100
|
|
|
|
1069
|
eval { $self->{NAME} and $self->{NAME} !~ m/^[\w:]+$/; }, |
147
|
|
|
|
|
|
|
], |
148
|
|
|
|
|
|
|
ABSTRACT => [ |
149
|
|
|
|
|
|
|
q{ABSTRACTs are limited to 44 characters}, |
150
|
89
|
|
|
|
|
345
|
eval { length( $self->{ABSTRACT} ) > 44; }, |
151
|
|
|
|
|
|
|
], |
152
|
|
|
|
|
|
|
CPANID => [ |
153
|
|
|
|
|
|
|
q{CPAN IDs are 3-9 characters}, |
154
|
89
|
100
|
|
|
|
754
|
eval { $self->{CPANID} and $self->{CPANID} !~ m/^\w{3,9}$/; }, |
155
|
|
|
|
|
|
|
], |
156
|
|
|
|
|
|
|
EMAIL => [ |
157
|
|
|
|
|
|
|
q{EMAIL addresses need to have an at sign}, |
158
|
89
|
|
|
|
|
415
|
eval { $self->{EMAIL} !~ m/.*\@.*/; }, |
159
|
|
|
|
|
|
|
], |
160
|
|
|
|
|
|
|
WEBSITE => [ |
161
|
|
|
|
|
|
|
q{WEBSITEs should start with an "http:" or "https:"}, |
162
|
89
|
100
|
|
|
|
741
|
eval { $self->{WEBSITE} and $self->{WEBSITE} !~ m{https?://.*}; }, |
163
|
|
|
|
|
|
|
], |
164
|
|
|
|
|
|
|
LICENSE => [ |
165
|
|
|
|
|
|
|
q{LICENSE is not recognized}, |
166
|
89
|
|
|
|
|
151
|
eval { ! ( |
167
|
|
|
|
|
|
|
Verify_Local_License($self->{LICENSE}) |
168
|
|
|
|
|
|
|
|| |
169
|
|
|
|
|
|
|
Verify_Standard_License($self->{LICENSE}) |
170
|
89
|
|
100
|
|
|
466
|
); }, |
171
|
|
|
|
|
|
|
], |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Errors should be checked in the following order |
175
|
89
|
|
|
|
|
393
|
my @msgs_ordered = qw( |
176
|
|
|
|
|
|
|
NAME_REQ |
177
|
|
|
|
|
|
|
NAME_ILLEGAL |
178
|
|
|
|
|
|
|
ABSTRACT |
179
|
|
|
|
|
|
|
CPANID |
180
|
|
|
|
|
|
|
EMAIL |
181
|
|
|
|
|
|
|
WEBSITE |
182
|
|
|
|
|
|
|
LICENSE |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
|
185
|
89
|
|
|
|
|
103
|
my @errors; |
186
|
|
|
|
|
|
|
|
187
|
89
|
|
|
|
|
174
|
foreach my $attr ( @msgs_ordered ) { |
188
|
|
|
|
|
|
|
push @errors, $error_msg{$attr}[0] |
189
|
623
|
100
|
|
|
|
1016
|
if $error_msg{$attr}[1]; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
89
|
100
|
|
|
|
488
|
return 1 unless @errors; |
193
|
9
|
|
|
|
|
90
|
$self->death_message(\@errors); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head3 C |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Usage : $self->initialize_license() within new() and |
199
|
|
|
|
|
|
|
Interactive::License_Menu |
200
|
|
|
|
|
|
|
Purpose : Gets appropriate license and, where necessary, fills in 'blanks' |
201
|
|
|
|
|
|
|
with information such as COPYRIGHT_YEAR, AUTHOR and |
202
|
|
|
|
|
|
|
ORGANIZATION; sets $self keys LICENSE and LicenseParts |
203
|
|
|
|
|
|
|
Returns : n/a |
204
|
|
|
|
|
|
|
Argument : n/a |
205
|
|
|
|
|
|
|
Comment : |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub initialize_license { |
210
|
80
|
|
|
80
|
1
|
106
|
my $self = shift; |
211
|
|
|
|
|
|
|
|
212
|
80
|
|
|
|
|
180
|
$self->{LICENSE} = lc( $self->{LICENSE} ); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
my $license_function = Get_Local_License( $self->{LICENSE} ) |
215
|
80
|
|
66
|
|
|
298
|
|| Get_Standard_License( $self->{LICENSE} ); |
216
|
|
|
|
|
|
|
|
217
|
80
|
50
|
|
|
|
471
|
if ( ref($license_function) eq 'CODE' ) { |
218
|
80
|
|
|
|
|
285
|
$self->{LicenseParts} = $license_function->(); |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
$self->{LicenseParts}{LICENSETEXT} =~ |
221
|
80
|
|
|
|
|
3966
|
s/###year###/$self->{COPYRIGHT_YEAR}/ig; |
222
|
|
|
|
|
|
|
$self->{LicenseParts}{LICENSETEXT} =~ |
223
|
80
|
|
|
|
|
3423
|
s/###owner###/$self->{AUTHOR}/ig; |
224
|
|
|
|
|
|
|
$self->{LicenseParts}{LICENSETEXT} =~ |
225
|
80
|
|
|
|
|
3502
|
s/###organization###/$self->{ORGANIZATION}/ig; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 SEE ALSO |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
F. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=cut |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
1; |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|