| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Module::Starter::CSJEWELL; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
29700
|
use 5.008001; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
46
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
47
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
108
|
|
|
7
|
1
|
|
|
1
|
|
1001
|
use English qw( -no_match_vars ); |
|
|
1
|
|
|
|
|
5065
|
|
|
|
1
|
|
|
|
|
8
|
|
|
8
|
1
|
|
|
1
|
|
1744
|
use parent 'Module::Starter::Simple'; |
|
|
1
|
|
|
|
|
385
|
|
|
|
1
|
|
|
|
|
5
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.200'; |
|
11
|
|
|
|
|
|
|
$VERSION =~ s/_//sm; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub module_guts { |
|
14
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
15
|
0
|
|
|
|
|
0
|
my %context = ( |
|
16
|
|
|
|
|
|
|
'MODULE NAME' => shift, |
|
17
|
|
|
|
|
|
|
'RT NAME' => shift, |
|
18
|
|
|
|
|
|
|
'DATE' => scalar localtime, |
|
19
|
|
|
|
|
|
|
'YEAR' => $self->_thisyear(), |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
return $self->_load_and_expand_template( 'Module.pm', \%context ); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub create_Makefile_PL { |
|
26
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# We don't create a Makefile.PL. |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
return; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub Build_PL_guts { |
|
34
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
35
|
0
|
|
|
|
|
0
|
my %context = ( |
|
36
|
|
|
|
|
|
|
'MAIN MODULE' => shift, |
|
37
|
|
|
|
|
|
|
'MAIN PM FILE' => shift, |
|
38
|
|
|
|
|
|
|
'DATE' => scalar localtime, |
|
39
|
|
|
|
|
|
|
'YEAR' => $self->_thisyear(), |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
return $self->_load_and_expand_template( 'Build.PL', \%context ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub Changes_guts { |
|
46
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my %context = ( |
|
49
|
|
|
|
|
|
|
'DATE' => scalar localtime, |
|
50
|
|
|
|
|
|
|
'YEAR' => $self->_thisyear(), |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
return $self->_load_and_expand_template( 'Changes', \%context ); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub create_README { |
|
57
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# We don't create a readme as such. |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
return; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub t_guts { ## no critic (RequireArgUnpacking) |
|
65
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
66
|
0
|
|
|
|
|
0
|
my @modules = @_; |
|
67
|
0
|
|
|
|
|
0
|
my %context = ( |
|
68
|
|
|
|
|
|
|
'DATE' => scalar localtime, |
|
69
|
|
|
|
|
|
|
'YEAR' => $self->_thisyear(), |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
my %t_files; |
|
73
|
|
|
|
|
|
|
my @template_files; |
|
74
|
0
|
|
|
|
|
0
|
push @template_files, glob "$self->{template_dir}/t/*.t"; |
|
75
|
0
|
|
|
|
|
0
|
push @template_files, glob "$self->{template_dir}/xt/author/*.t"; |
|
76
|
0
|
|
|
|
|
0
|
push @template_files, glob "$self->{template_dir}/xt/settings/*.txt"; |
|
77
|
0
|
|
|
|
|
0
|
for my $test_file ( |
|
|
0
|
|
|
|
|
0
|
|
|
78
|
|
|
|
|
|
|
map { |
|
79
|
|
|
|
|
|
|
my $x = $_; |
|
80
|
0
|
|
|
|
|
0
|
$x = File::Spec->abs2rel( $_, $self->{template_dir} ); |
|
81
|
0
|
|
|
|
|
0
|
$x; |
|
82
|
|
|
|
|
|
|
} @template_files |
|
83
|
|
|
|
|
|
|
) |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
0
|
|
|
|
|
0
|
$t_files{$test_file} = |
|
86
|
|
|
|
|
|
|
$self->_load_and_expand_template( $test_file, \%context ); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
my $nmodules = @modules; |
|
90
|
0
|
|
|
|
|
0
|
$nmodules++; |
|
91
|
0
|
|
|
|
|
0
|
my $main_module = $modules[0]; |
|
92
|
0
|
|
|
|
|
0
|
my $use_lines = join "\n", map {" use_ok( '$_' );"} @modules; |
|
|
0
|
|
|
|
|
0
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
0
|
$t_files{'t/compile.t'} = <<"END_LOAD"; |
|
95
|
|
|
|
|
|
|
use Test::More tests => $nmodules; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
BEGIN { |
|
98
|
|
|
|
|
|
|
use strict; |
|
99
|
|
|
|
|
|
|
\$^W = 1; |
|
100
|
|
|
|
|
|
|
\$| = 1; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
ok((\$] > 5.008000), 'Perl version acceptable') or BAIL_OUT ('Perl version unacceptably old.'); |
|
103
|
|
|
|
|
|
|
$use_lines |
|
104
|
|
|
|
|
|
|
diag( "Testing $main_module \$${main_module}::VERSION" ); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
END_LOAD |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
0
|
return %t_files; |
|
110
|
|
|
|
|
|
|
} ## end sub t_guts |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _create_t { |
|
113
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
114
|
0
|
|
|
|
|
0
|
my $filename = shift; |
|
115
|
0
|
|
|
|
|
0
|
my $content = shift; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
0
|
my @dirparts = ( $self->{basedir}, 't' ); |
|
118
|
0
|
|
|
|
|
0
|
foreach my $tdir ( |
|
119
|
|
|
|
|
|
|
File::Spec->catdir( $self->{basedir}, 't' ), |
|
120
|
|
|
|
|
|
|
File::Spec->catdir( $self->{basedir}, 'xt' ), |
|
121
|
|
|
|
|
|
|
File::Spec->catdir( $self->{basedir}, 'xt', 'settings' ), |
|
122
|
|
|
|
|
|
|
File::Spec->catdir( $self->{basedir}, 'xt', 'author' ), |
|
123
|
|
|
|
|
|
|
) |
|
124
|
|
|
|
|
|
|
{ |
|
125
|
|
|
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
0
|
if ( not -d $tdir ) { |
|
127
|
0
|
|
|
|
|
0
|
local @ARGV = $tdir; |
|
128
|
0
|
|
|
|
|
0
|
mkpath(); |
|
129
|
0
|
|
|
|
|
0
|
$self->progress("Created $tdir"); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} ## end foreach my $tdir ( File::Spec...) |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
0
|
my $fname = File::Spec->catfile( $self->{basedir}, $filename ); |
|
134
|
0
|
|
|
|
|
0
|
$self->create_file( $fname, $content ); |
|
135
|
0
|
|
|
|
|
0
|
$self->progress("Created $fname"); |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
0
|
return "$filename"; |
|
138
|
|
|
|
|
|
|
} ## end sub _create_t |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub MANIFEST_guts { ## no critic (RequireArgUnpacking) |
|
141
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
142
|
0
|
|
|
|
|
0
|
my @files = sort @_; |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
0
|
my $mskip = $self->_load_and_expand_template( 'MANIFEST.SKIP', {} ); |
|
145
|
0
|
|
|
|
|
0
|
my $fname = File::Spec->catfile( $self->{basedir}, 'MANIFEST.SKIP' ); |
|
146
|
0
|
|
|
|
|
0
|
$self->create_file( $fname, $mskip ); |
|
147
|
0
|
|
|
|
|
0
|
$self->progress("Created $fname"); |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
0
|
return join "\n", @files, q{}; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _load_and_expand_template { |
|
154
|
0
|
|
|
0
|
|
0
|
my ( $self, $rel_file_path, $context_ref ) = @_; |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
0
|
@{$context_ref}{ map {uc} keys %{$self} } = values %{$self}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
0
|
|
|
|
0
|
die |
|
159
|
|
|
|
|
|
|
"Can't find directory that holds Module::Starter::CSJEWELL templates\n", |
|
160
|
|
|
|
|
|
|
"(no 'template_dir: ' in config file)\n" |
|
161
|
|
|
|
|
|
|
if not defined $self->{template_dir}; |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
0
|
|
|
|
0
|
die "Can't access Module::Starter::CSJEWELL template directory\n", |
|
164
|
|
|
|
|
|
|
"(perhaps 'template_dir: $self->{template_dir}' is wrong in config file?)\n" |
|
165
|
|
|
|
|
|
|
if not -d $self->{template_dir}; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
0
|
my $abs_file_path = "$self->{template_dir}/$rel_file_path"; |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
0
|
die "The Module::Starter::CSJEWELL template: $rel_file_path\n", |
|
170
|
|
|
|
|
|
|
"isn't in the template directory ($self->{template_dir})\n\n" |
|
171
|
|
|
|
|
|
|
if not -e $abs_file_path; |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
0
|
die "The Module::Starter::CSJEWELL template: $rel_file_path\n", |
|
174
|
|
|
|
|
|
|
"isn't readable in the template directory ($self->{template_dir})\n\n" |
|
175
|
|
|
|
|
|
|
if not -r $abs_file_path; |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
0
|
|
|
|
0
|
open my $fh, '<', $abs_file_path or croak $ERRNO; |
|
178
|
0
|
|
|
|
|
0
|
local $INPUT_RECORD_SEPARATOR = undef; |
|
179
|
0
|
|
|
|
|
0
|
my $text = <$fh>; |
|
180
|
0
|
0
|
|
|
|
0
|
close $fh or croak $ERRNO; |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
0
|
$text =~ s{<([[:upper:] ]+)>} |
|
183
|
0
|
0
|
|
|
|
0
|
{ $context_ref->{$1} |
|
184
|
|
|
|
|
|
|
|| die "Unknown placeholder <$1> in $rel_file_path\n" |
|
185
|
|
|
|
|
|
|
}xmseg; |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
0
|
return $text; |
|
188
|
|
|
|
|
|
|
} ## end sub _load_and_expand_template |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub import { ## no critic (RequireArgUnpacking ProhibitExcessComplexity) |
|
191
|
1
|
|
|
1
|
|
26
|
my $class = shift; |
|
192
|
1
|
|
|
|
|
3
|
my ( $setup, @other_args ) = @_; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# If this is not a setup request, |
|
195
|
|
|
|
|
|
|
# refer the import request up the hierarchy... |
|
196
|
1
|
50
|
33
|
|
|
13
|
if ( @other_args || !$setup || $setup ne 'setup' ) { |
|
|
|
|
33
|
|
|
|
|
|
197
|
1
|
|
|
|
|
20
|
return $class->SUPER::import(@_); |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
## no critic (RequireLocalizedPunctuationVars ProhibitLocalVars) |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# Otherwise, gather the necessary tools... |
|
203
|
1
|
|
|
1
|
|
23926
|
use ExtUtils::Command qw( mkpath ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
62
|
|
|
204
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1896
|
|
|
205
|
0
|
|
|
|
|
|
local $OUTPUT_AUTOFLUSH = 1; |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
local $ENV{HOME} = $ENV{HOME}; |
|
208
|
|
|
|
|
|
|
|
|
209
|
0
|
0
|
|
|
|
|
if ( $OSNAME eq 'MSWin32' ) { |
|
210
|
0
|
0
|
|
|
|
|
if ( defined $ENV{HOME} ) { |
|
211
|
0
|
|
|
|
|
|
$ENV{HOME} = Win32::GetShortPathName( $ENV{HOME} ); |
|
212
|
|
|
|
|
|
|
} else { |
|
213
|
0
|
|
|
|
|
|
$ENV{HOME} = Win32::GetShortPathName( |
|
214
|
|
|
|
|
|
|
File::Spec->catpath( $ENV{HOMEDRIVE}, $ENV{HOMEPATH}, q{} ) |
|
215
|
|
|
|
|
|
|
); |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# Locate the home directory... |
|
220
|
0
|
0
|
|
|
|
|
if ( !defined $ENV{HOME} ) { |
|
221
|
0
|
|
|
|
|
|
print 'Please enter the full path of your home directory: '; |
|
222
|
0
|
|
|
|
|
|
$ENV{HOME} = <>; |
|
223
|
0
|
|
|
|
|
|
chomp $ENV{HOME}; |
|
224
|
0
|
0
|
|
|
|
|
croak 'Not a valid directory. Aborting.' |
|
225
|
|
|
|
|
|
|
if !-d $ENV{HOME}; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# Create the directories... |
|
229
|
0
|
|
|
|
|
|
my $template_dir = |
|
230
|
|
|
|
|
|
|
File::Spec->catdir( $ENV{HOME}, '.module-starter', 'CSJEWELL' ); |
|
231
|
0
|
0
|
|
|
|
|
if ( not -d $template_dir ) { |
|
232
|
0
|
|
|
|
|
|
print {*STDERR} "Creating $template_dir..."; |
|
|
0
|
|
|
|
|
|
|
|
233
|
0
|
|
|
|
|
|
local @ARGV = $template_dir; |
|
234
|
0
|
|
|
|
|
|
mkpath; |
|
235
|
0
|
|
|
|
|
|
print {*STDERR} "done.\n"; |
|
|
0
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
my $template_test_dir = |
|
239
|
|
|
|
|
|
|
File::Spec->catdir( $ENV{HOME}, '.module-starter', 'CSJEWELL', 't' ); |
|
240
|
0
|
0
|
|
|
|
|
if ( not -d $template_test_dir ) { |
|
241
|
0
|
|
|
|
|
|
print {*STDERR} "Creating $template_test_dir..."; |
|
|
0
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
local @ARGV = $template_test_dir; |
|
243
|
0
|
|
|
|
|
|
mkpath; |
|
244
|
0
|
|
|
|
|
|
print {*STDERR} "done.\n"; |
|
|
0
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
my $template_xtest_dir = |
|
248
|
|
|
|
|
|
|
File::Spec->catdir( $ENV{HOME}, '.module-starter', 'CSJEWELL', 'xt' ); |
|
249
|
0
|
0
|
|
|
|
|
if ( not -d $template_xtest_dir ) { |
|
250
|
0
|
|
|
|
|
|
print {*STDERR} "Creating $template_xtest_dir..."; |
|
|
0
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
|
local @ARGV = $template_xtest_dir; |
|
252
|
0
|
|
|
|
|
|
mkpath; |
|
253
|
0
|
|
|
|
|
|
print {*STDERR} "done.\n"; |
|
|
0
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
0
|
|
|
|
|
|
my $template_authortest_dir = |
|
257
|
|
|
|
|
|
|
File::Spec->catdir( $ENV{HOME}, '.module-starter', 'CSJEWELL', 'xt', |
|
258
|
|
|
|
|
|
|
'author' ); |
|
259
|
0
|
0
|
|
|
|
|
if ( not -d $template_authortest_dir ) { |
|
260
|
0
|
|
|
|
|
|
print {*STDERR} "Creating $template_authortest_dir..."; |
|
|
0
|
|
|
|
|
|
|
|
261
|
0
|
|
|
|
|
|
local @ARGV = $template_authortest_dir; |
|
262
|
0
|
|
|
|
|
|
mkpath; |
|
263
|
0
|
|
|
|
|
|
print {*STDERR} "done.\n"; |
|
|
0
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
} |
|
265
|
|
|
|
|
|
|
|
|
266
|
0
|
|
|
|
|
|
my $template_authortest_settings = |
|
267
|
|
|
|
|
|
|
File::Spec->catdir( $ENV{HOME}, '.module-starter', 'CSJEWELL', 'xt', |
|
268
|
|
|
|
|
|
|
'settings' ); |
|
269
|
0
|
0
|
|
|
|
|
if ( not -d $template_authortest_settings ) { |
|
270
|
0
|
|
|
|
|
|
print {*STDERR} "Creating $template_authortest_settings..."; |
|
|
0
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
local @ARGV = $template_authortest_settings; |
|
272
|
0
|
|
|
|
|
|
mkpath; |
|
273
|
0
|
|
|
|
|
|
print {*STDERR} "done.\n"; |
|
|
0
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# Create or update the config file (making a backup, of course)... |
|
277
|
0
|
|
|
|
|
|
my $config_file = |
|
278
|
|
|
|
|
|
|
File::Spec->catfile( $ENV{HOME}, '.module-starter', 'config' ); |
|
279
|
|
|
|
|
|
|
|
|
280
|
0
|
|
|
|
|
|
my @config_info; |
|
281
|
|
|
|
|
|
|
|
|
282
|
0
|
0
|
|
|
|
|
if ( -e $config_file ) { |
|
283
|
0
|
|
|
|
|
|
print {*STDERR} "Backing up $config_file..."; |
|
|
0
|
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
|
my $backup = |
|
285
|
|
|
|
|
|
|
File::Spec->catfile( $ENV{HOME}, '.module-starter', |
|
286
|
|
|
|
|
|
|
'config.bak' ); |
|
287
|
0
|
0
|
|
|
|
|
rename $config_file, $backup or croak $ERRNO; |
|
288
|
0
|
|
|
|
|
|
print {*STDERR} "done.\n"; |
|
|
0
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
|
|
290
|
0
|
|
|
|
|
|
print {*STDERR} "Updating $config_file..."; |
|
|
0
|
|
|
|
|
|
|
|
291
|
0
|
0
|
|
|
|
|
open my $fh, '<', $backup or die "$config_file: $OS_ERROR\n"; |
|
292
|
0
|
|
|
|
|
|
@config_info = |
|
293
|
0
|
|
|
|
|
|
grep { not /\A (?: template_dir | plugins ) : /xms } <$fh>; |
|
294
|
0
|
0
|
|
|
|
|
close $fh or die "$config_file: $OS_ERROR\n"; |
|
295
|
|
|
|
|
|
|
} else { |
|
296
|
0
|
|
|
|
|
|
print {*STDERR} "Creating $config_file...\n"; |
|
|
0
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
|
298
|
0
|
|
|
|
|
|
my $author = _prompt_for('your full name'); |
|
299
|
0
|
|
|
|
|
|
my $email = _prompt_for('an email address'); |
|
300
|
|
|
|
|
|
|
|
|
301
|
0
|
|
|
|
|
|
@config_info = ( |
|
302
|
|
|
|
|
|
|
"author: $author\n", |
|
303
|
|
|
|
|
|
|
"email: $email\n", |
|
304
|
|
|
|
|
|
|
"builder: Module::Build\n", |
|
305
|
|
|
|
|
|
|
); |
|
306
|
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
print {*STDERR} "Writing $config_file...\n"; |
|
|
0
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
} ## end else [ if ( -e $config_file )] |
|
309
|
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
push @config_info, |
|
311
|
|
|
|
|
|
|
( "plugins: Module::Starter::CSJEWELL\n", |
|
312
|
|
|
|
|
|
|
"template_dir: $template_dir\n", |
|
313
|
|
|
|
|
|
|
); |
|
314
|
|
|
|
|
|
|
|
|
315
|
0
|
0
|
|
|
|
|
open my $fh, '>', $config_file or die "$config_file: $OS_ERROR\n"; |
|
316
|
0
|
0
|
|
|
|
|
print {$fh} @config_info or die "$config_file: $OS_ERROR\n"; |
|
|
0
|
|
|
|
|
|
|
|
317
|
0
|
0
|
|
|
|
|
close $fh or die "$config_file: $OS_ERROR\n"; |
|
318
|
0
|
|
|
|
|
|
print {*STDERR} "done.\n"; |
|
|
0
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
print {*STDERR} "Installing templates...\n"; |
|
|
0
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
# Then install the various files... |
|
323
|
0
|
|
|
|
|
|
my @files = ( |
|
324
|
|
|
|
|
|
|
['Build.PL'], |
|
325
|
|
|
|
|
|
|
['Changes'], |
|
326
|
|
|
|
|
|
|
['Module.pm'], |
|
327
|
|
|
|
|
|
|
['MANIFEST.SKIP'], |
|
328
|
|
|
|
|
|
|
[ 't', '000_report_versions.t' ], |
|
329
|
|
|
|
|
|
|
[ 'xt', 'settings', 'perltidy.txt' ], |
|
330
|
|
|
|
|
|
|
[ 'xt', 'settings', 'perlcritic.txt' ], |
|
331
|
|
|
|
|
|
|
[ 'xt', 'author', 'prereq.t' ], |
|
332
|
|
|
|
|
|
|
[ 'xt', 'author', 'portability.t' ], |
|
333
|
|
|
|
|
|
|
[ 'xt', 'author', 'meta.t' ], |
|
334
|
|
|
|
|
|
|
[ 'xt', 'author', 'manifest.t' ], |
|
335
|
|
|
|
|
|
|
[ 'xt', 'author', 'minimumversion.t' ], |
|
336
|
|
|
|
|
|
|
[ 'xt', 'author', 'pod_coverage.t' ], |
|
337
|
|
|
|
|
|
|
[ 'xt', 'author', 'pod.t' ], |
|
338
|
|
|
|
|
|
|
[ 'xt', 'author', 'perlcritic.t' ], |
|
339
|
|
|
|
|
|
|
[ 'xt', 'author', 'fixme.t' ], |
|
340
|
|
|
|
|
|
|
[ 'xt', 'author', 'common_mistakes.t' ], |
|
341
|
|
|
|
|
|
|
[ 'xt', 'author', 'changes.t' ], |
|
342
|
|
|
|
|
|
|
[ 'xt', 'author', 'version.t' ], |
|
343
|
|
|
|
|
|
|
); |
|
344
|
|
|
|
|
|
|
|
|
345
|
0
|
|
|
|
|
|
my %contents_of = do { |
|
346
|
0
|
|
|
|
|
|
local $INPUT_RECORD_SEPARATOR = undef; |
|
347
|
0
|
|
|
|
|
|
( q{}, split m{_____\[ [ ] (\S+) [ ] \]_+\n}smx, ); |
|
348
|
|
|
|
|
|
|
}; |
|
349
|
|
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
for ( values %contents_of ) { |
|
351
|
0
|
|
|
|
|
|
s/^!=([[:lower:]])/=$1/gxms; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
|
|
354
|
0
|
|
|
|
|
|
for my $ref_path (@files) { |
|
355
|
0
|
|
|
|
|
|
my $abs_path = |
|
356
|
|
|
|
|
|
|
File::Spec->catfile( $ENV{HOME}, '.module-starter', 'CSJEWELL', |
|
357
|
0
|
|
|
|
|
|
@{$ref_path} ); |
|
358
|
0
|
|
|
|
|
|
print {*STDERR} "\t$abs_path..."; |
|
|
0
|
|
|
|
|
|
|
|
359
|
0
|
0
|
|
|
|
|
open my $fh, '>', $abs_path or die "$abs_path: $OS_ERROR\n"; |
|
360
|
0
|
0
|
|
|
|
|
print {$fh} $contents_of{ $ref_path->[-1] } |
|
|
0
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
or die "$abs_path: $OS_ERROR\n"; |
|
362
|
0
|
0
|
|
|
|
|
close $fh or die "$abs_path: $OS_ERROR\n"; |
|
363
|
0
|
|
|
|
|
|
print {*STDERR} "done\n"; |
|
|
0
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
} |
|
365
|
0
|
|
|
|
|
|
print {*STDERR} "Installation complete.\n"; |
|
|
0
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
|
|
367
|
0
|
|
|
|
|
|
exit; |
|
368
|
|
|
|
|
|
|
} ## end sub import |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
sub _prompt_for { |
|
371
|
0
|
|
|
0
|
|
|
my ($requested_info) = @_; |
|
372
|
0
|
|
|
|
|
|
my $response; |
|
373
|
0
|
|
|
|
|
|
RESPONSE: while (1) { |
|
374
|
0
|
|
|
|
|
|
print "Please enter $requested_info: "; |
|
375
|
0
|
|
|
|
|
|
$response = <>; |
|
376
|
0
|
0
|
|
|
|
|
if ( not defined $response ) { |
|
377
|
0
|
|
|
|
|
|
warn "\n[Installation cancelled]\n"; |
|
378
|
0
|
|
|
|
|
|
exit; |
|
379
|
|
|
|
|
|
|
} |
|
380
|
0
|
|
|
|
|
|
$response =~ s/\A \s+ | \s+ \Z//gxms; |
|
381
|
0
|
0
|
|
|
|
|
last RESPONSE if $response =~ m{\S}sm; |
|
382
|
|
|
|
|
|
|
} |
|
383
|
0
|
|
|
|
|
|
return $response; |
|
384
|
|
|
|
|
|
|
} ## end sub _prompt_for |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
__DATA__ |