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