Module-Starter-CSJEWELL
view release on metacpan or search on metacpan
lib/Module/Starter/CSJEWELL.pm view on Meta::CPAN
rename $config_file, $backup or croak $ERRNO;
print {*STDERR} "done.\n";
print {*STDERR} "Updating $config_file...";
open my $fh, '<', $backup or die "$config_file: $OS_ERROR\n";
@config_info =
grep { not /\A (?: template_dir | plugins ) : /xms } <$fh>;
close $fh or die "$config_file: $OS_ERROR\n";
} else {
print {*STDERR} "Creating $config_file...\n";
my $author = _prompt_for('your full name');
my $email = _prompt_for('an email address');
@config_info = (
"author: $author\n",
"email: $email\n",
"builder: Module::Build\n",
);
print {*STDERR} "Writing $config_file...\n";
} ## end else [ if ( -e $config_file )]
push @config_info,
( "plugins: Module::Starter::CSJEWELL\n",
"template_dir: $template_dir\n",
);
open my $fh, '>', $config_file or die "$config_file: $OS_ERROR\n";
print {$fh} @config_info or die "$config_file: $OS_ERROR\n";
close $fh or die "$config_file: $OS_ERROR\n";
print {*STDERR} "done.\n";
print {*STDERR} "Installing templates...\n";
# Then install the various files...
my @files = (
['Build.PL'],
['Changes'],
['Module.pm'],
['MANIFEST.SKIP'],
[ 't', '000_report_versions.t' ],
[ 'xt', 'settings', 'perltidy.txt' ],
[ 'xt', 'settings', 'perlcritic.txt' ],
[ 'xt', 'author', 'prereq.t' ],
[ 'xt', 'author', 'portability.t' ],
[ 'xt', 'author', 'meta.t' ],
[ 'xt', 'author', 'manifest.t' ],
[ 'xt', 'author', 'minimumversion.t' ],
[ 'xt', 'author', 'pod_coverage.t' ],
[ 'xt', 'author', 'pod.t' ],
[ 'xt', 'author', 'perlcritic.t' ],
[ 'xt', 'author', 'fixme.t' ],
[ 'xt', 'author', 'common_mistakes.t' ],
[ 'xt', 'author', 'changes.t' ],
[ 'xt', 'author', 'version.t' ],
);
my %contents_of = do {
local $INPUT_RECORD_SEPARATOR = undef;
( q{}, split m{_____\[ [ ] (\S+) [ ] \]_+\n}smx, <DATA> );
};
for ( values %contents_of ) {
s/^!=([[:lower:]])/=$1/gxms;
}
for my $ref_path (@files) {
my $abs_path =
File::Spec->catfile( $ENV{HOME}, '.module-starter', 'CSJEWELL',
@{$ref_path} );
print {*STDERR} "\t$abs_path...";
open my $fh, '>', $abs_path or die "$abs_path: $OS_ERROR\n";
print {$fh} $contents_of{ $ref_path->[-1] }
or die "$abs_path: $OS_ERROR\n";
close $fh or die "$abs_path: $OS_ERROR\n";
print {*STDERR} "done\n";
}
print {*STDERR} "Installation complete.\n";
exit;
} ## end sub import
sub _prompt_for {
my ($requested_info) = @_;
my $response;
RESPONSE: while (1) {
print "Please enter $requested_info: ";
$response = <>;
if ( not defined $response ) {
warn "\n[Installation cancelled]\n";
exit;
}
$response =~ s/\A \s+ | \s+ \Z//gxms;
last RESPONSE if $response =~ m{\S}sm;
}
return $response;
} ## end sub _prompt_for
1; # Magic true value required at end of module
__DATA__
_____[ Build.PL ]________________________________________________
use strict;
use warnings;
use Module::Build;
my $class = Module::Build->subclass(
class => 'My::Builder',
code => <<'END_CODE',
sub ACTION_authortest {
my ($self) = @_;
$self->depends_on('build');
$self->depends_on('manifest');
$self->depends_on('distmeta');
$self->test_files( qw( t xt/author ) );
$self->depends_on('test');
( run in 0.900 second using v1.01-cache-2.11-cpan-71847e10f99 )