| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | Module::Starter::Plugin::CGIApp - template based module starter for CGI apps. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | use Module::Starter qw( | ||||||||||||||||||||||||||||
| 8 | Module::Starter::Plugin::CGIApp | ||||||||||||||||||||||||||||
| 9 | ); | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | Module::Starter->create_distro(%args); | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 ABSTRACT | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | This is a plugin for L<Module::Starter|Module::Starter> that builds you a skeleton | ||||||||||||||||||||||||||||
| 16 | L<CGI::Application|CGI::Application> module with all the extra files needed to package it for | ||||||||||||||||||||||||||||
| 17 | CPAN. You can customize the output using L<HTML::Template|HTML::Template>. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | package Module::Starter::Plugin::CGIApp; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use base 'Module::Starter::Simple'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | use File::Path qw( mkpath ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 4 | ▶ | use Module::Starter::BuilderSet; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 4 | ▶ | use HTML::Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 VERSION | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | This document describes version 0.44 | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =cut | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 4 | our $VERSION = '0.44'; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | This module subclasses L<Module::Starter::Simple|Module::Starter::Simple> and | ||||||||||||||||||||||||||||
| 45 | includes functionality similar to L<Module::Starter::Plugin::Template|Module::Starter::Plugin::Template>. | ||||||||||||||||||||||||||||
| 46 | This document only describes the methods which are overridden from those modules or are new. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Only developers looking to extend this module need to read this. If you just | ||||||||||||||||||||||||||||
| 49 | want to use L<Module::Starter::Plugin::CGIApp|Module::Starter::Plugin::CGIApp>, read the docs for | ||||||||||||||||||||||||||||
| 50 | L<cgiapp-starter|cgiapp-starter> or L<titanium-starter|titanium-starter> instead. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head1 METHODS | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head2 new ( %args ) | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | This method calls the C<new> supermethod from | ||||||||||||||||||||||||||||
| 57 | L<Module::Starter::Plugin::Simple|Module::Starter::Plugin::Simple> and then | ||||||||||||||||||||||||||||
| 58 | initializes the template store. (See C<templates>.) | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 3 | my ( $proto, %opts ) = @_; | |||||||||||||||||||||||||||
| 64 | 3 | ▶ | my $class = ref $proto || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 3 | my $self = $class->SUPER::new(%opts); | |||||||||||||||||||||||||||
| 67 | 3 | $self->{templates} = { $self->templates }; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 3 | return bless $self => $class; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head2 create_distro ( %args ) | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | This method works as advertised in L<Module::Starter|Module::Starter>. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 3 | ▶ | sub create_distro { | ||||||||||||||||||||||||||
|
Subroutine
create_distro: called CC=12 SCAR=34.8
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | 3 | my ( $either, %opts ) = @_; | |||||||||||||||||||||||||||
| 80 | 3 | ▶ | ( ref $either ) or $either = $either->new(%opts); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 3 | my $self = $either; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # Supposedly the *-starter scripts can handle multiple --builder options | ||||||||||||||||||||||||||||
| 84 | # but this doesn't work (and IMO doesn't make sense anyway.) So in the | ||||||||||||||||||||||||||||
| 85 | # case multiple builders were specified, we just pick the first one. | ||||||||||||||||||||||||||||
| 86 | 3 | ▶ | if ( ref $self->{builder} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 0 | $self->{builder} = $self->{builder}->[0]; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 3 | my @modules; | |||||||||||||||||||||||||||
| 91 | 3 | foreach my $arg ( @{ $self->{modules} } ) { | |||||||||||||||||||||||||||
| 92 | 6 | push @modules, ( split /[,]/msx, $arg ); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | 3 | ▶ | if ( !@modules ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | croak "No modules specified.\n"; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | 3 | for (@modules) { | |||||||||||||||||||||||||||
| 98 | 6 | ▶ | if ( !/\A [[:alpha:]_] \w* (?: [:] [:] [\w]+ )* \Z /imsx ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | croak "Invalid module name: $_"; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | 3 | $self->{modules} = \@modules; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 3 | ▶ | if ( !$self->{author} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | croak "Must specify an author\n"; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 3 | ▶ | if ( !$self->{email} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 0 | croak "Must specify an email address\n"; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 3 | ( $self->{email_obfuscated} = $self->{email} ) =~ s/@/ at /msx; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 3 | ▶ | $self->{license} ||= 'perl'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"license"} ||= "perl"
MC/DC0%0/1
$self->{"license"} ||= "perl"
$self->{"license"}
Truth table50%1/2
A
A= $self->{"license"}
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 3 | $self->{main_module} = $self->{modules}->[0]; | |||||||||||||||||||||||||||
| 115 | 3 | ▶ | if ( !$self->{distro} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | $self->{distro} = $self->{main_module}; | |||||||||||||||||||||||||||
| 117 | 0 | $self->{distro} =~ s/::/-/gmsx; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 3 | ▶ | $self->{basedir} = $self->{dir} || $self->{distro}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'dir'} || $self->{'distro'}
MC/DC0%0/2
$self->{'dir'} || $self->{'distro'}
$self->{'dir'}
$self->{'distro'}
Truth table33%1/3
A || B
A= $self->{'dir'}B= $self->{'distro'}
| |||||||||||||||||||||||||||||
| 121 | 3 | $self->create_basedir; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 3 | my @files; | |||||||||||||||||||||||||||
| 124 | 3 | push @files, $self->create_modules( @{ $self->{modules} } ); | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | push @files, $self->create_t( @{ $self->{modules} } ); | |||||||||||||||||||||||||||
| 127 | 0 | push @files, $self->create_xt( @{ $self->{modules} } ); | |||||||||||||||||||||||||||
| 128 | 0 | push @files, $self->create_tmpl(); | |||||||||||||||||||||||||||
| 129 | 0 | my %build_results = $self->create_build(); | |||||||||||||||||||||||||||
| 130 | 0 | push @files, @{ $build_results{files} }; | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | push @files, $self->create_Changes; | |||||||||||||||||||||||||||
| 133 | 0 | push @files, $self->create_LICENSE; | |||||||||||||||||||||||||||
| 134 | 0 | push @files, $self->create_README( $build_results{instructions} ); | |||||||||||||||||||||||||||
| 135 | 0 | push @files, $self->create_MANIFEST_SKIP; | |||||||||||||||||||||||||||
| 136 | 0 | push @files, $self->create_perlcriticrc; | |||||||||||||||||||||||||||
| 137 | 0 | push @files, $self->create_server_pl; | |||||||||||||||||||||||||||
| 138 | 0 | push @files, 'MANIFEST'; | |||||||||||||||||||||||||||
| 139 | 0 | ▶ | $self->create_MANIFEST( sub { _create_manifest( $self, @files ) } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | return; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub _create_manifest { | ||||||||||||||||||||||||||
|
Subroutine
_create_manifest: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 145 | 0 | my ( $self, @files ) = @_; | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | my $file = File::Spec->catfile( $self->{basedir}, 'MANIFEST' ); | |||||||||||||||||||||||||||
| 148 | 0 | ▶ | open my $fh, '>', $file or croak "Can't open file $file: $OS_ERROR\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | foreach my $file ( sort @files ) { | |||||||||||||||||||||||||||
| 150 | 0 | ▶ | print {$fh} "$file\n" or croak "$OS_ERROR\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | 0 | ▶ | close $fh or croak "Can't close file $file: $OS_ERROR\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | return; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =head2 create_LICENSE( ) | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | This method creates a C<LICENSE> file in the distribution's directory which | ||||||||||||||||||||||||||||
| 160 | can hold the distribution's license terms. | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =cut | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub create_LICENSE { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
create_LICENSE: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | my $fname = File::Spec->catfile( $self->{basedir}, 'LICENSE' ); | |||||||||||||||||||||||||||
| 168 | 0 | $self->create_file( $fname, $self->LICENSE_guts() ); | |||||||||||||||||||||||||||
| 169 | 0 | $self->progress("Created $fname"); | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | return 'LICENSE'; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =head2 create_MANIFEST_SKIP( ) | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | This method creates a C<MANIFEST.SKIP> file in the distribution's directory so | ||||||||||||||||||||||||||||
| 177 | that unneeded files can be skipped from inclusion in the distribution. | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =cut | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub create_MANIFEST_SKIP { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
create_MANIFEST_SKIP: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 182 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | my $fname = File::Spec->catfile( $self->{basedir}, 'MANIFEST.SKIP' ); | |||||||||||||||||||||||||||
| 185 | 0 | $self->create_file( $fname, $self->MANIFEST_SKIP_guts() ); | |||||||||||||||||||||||||||
| 186 | 0 | $self->progress("Created $fname"); | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | return 'MANIFEST.SKIP'; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | =head2 create_modules( @modules ) | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | This method will create a starter module file for each module named in | ||||||||||||||||||||||||||||
| 194 | I<@modules>. It is only subclassed from L<Module::Starter::Simple|Module::Starter::Simple> here | ||||||||||||||||||||||||||||
| 195 | so we can change the I<rtname> tmpl_var to be the distro name instead of | ||||||||||||||||||||||||||||
| 196 | the module name. | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 3 | ▶ | sub create_modules { | ||||||||||||||||||||||||||
|
Subroutine
create_modules: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 201 | 3 | my ( $self, @modules ) = @_; | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 3 | my @files; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 3 | my $rtname = lc $self->{distro}; | |||||||||||||||||||||||||||
| 206 | 3 | for my $module (@modules) { | |||||||||||||||||||||||||||
| 207 | 3 | push @files, $self->_create_module( $module, $rtname ); | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | return @files; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | =head2 create_perlcriticrc( ) | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | This method creates a C<perlcriticrc> in the distribution's author test | ||||||||||||||||||||||||||||
| 216 | directory so that the behavior of C<perl-critic.t> can be modified. | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | =cut | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub create_perlcriticrc { | ||||||||||||||||||||||||||
|
Subroutine
create_perlcriticrc: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | my @dirparts = ( $self->{basedir}, 'xt' ); | |||||||||||||||||||||||||||
| 224 | 0 | my $tdir = File::Spec->catdir(@dirparts); | |||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ( not -d $tdir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 0 | mkpath($tdir); | |||||||||||||||||||||||||||
| 227 | 0 | $self->progress("Created $tdir"); | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | my $fname = File::Spec->catfile( @dirparts, 'perlcriticrc' ); | |||||||||||||||||||||||||||
| 231 | 0 | $self->create_file( $fname, $self->perlcriticrc_guts() ); | |||||||||||||||||||||||||||
| 232 | 0 | $self->progress("Created $fname"); | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | return 'xt/perlcriticrc'; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | =head2 create_server_pl( ) | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | This method creates C<server.pl> in the distribution's root directory. | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | =cut | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub create_server_pl { | ||||||||||||||||||||||||||
|
Subroutine
create_server_pl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 244 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | my $fname = File::Spec->catfile( $self->{basedir}, 'server.pl' ); | |||||||||||||||||||||||||||
| 247 | 0 | $self->create_file( $fname, $self->server_pl_guts() ); | |||||||||||||||||||||||||||
| 248 | 0 | $self->progress("Created $fname"); | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | return 'server.pl'; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | =head2 create_t( @modules ) | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | This method creates a bunch of *.t files. I<@modules> is a list of all modules | ||||||||||||||||||||||||||||
| 256 | in the distribution. | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | =cut | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | ▶ | sub create_t { | ||||||||||||||||||||||||||
|
Subroutine
create_t: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 261 | 0 | my ( $self, @modules ) = @_; | |||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | my %t_files = $self->t_guts(@modules); | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | my @files = map { $self->_create_t( 't', $_, $t_files{$_} ) } keys %t_files; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | # This next part is for the static files dir t/www | ||||||||||||||||||||||||||||
| 268 | 0 | my @dirparts = ( $self->{basedir}, 't', 'www' ); | |||||||||||||||||||||||||||
| 269 | 0 | my $twdir = File::Spec->catdir(@dirparts); | |||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ( not -d $twdir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 0 | mkpath($twdir); | |||||||||||||||||||||||||||
| 272 | 0 | $self->progress("Created $twdir"); | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | 0 | my $placeholder = | |||||||||||||||||||||||||||
| 275 | File::Spec->catfile( @dirparts, 'PUT.STATIC.CONTENT.HERE' ); | ||||||||||||||||||||||||||||
| 276 | 0 | $self->create_file( $placeholder, q{ } ); | |||||||||||||||||||||||||||
| 277 | 0 | $self->progress("Created $placeholder"); | |||||||||||||||||||||||||||
| 278 | 0 | push @files, 't/www/PUT.STATIC.CONTENT.HERE'; | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | return @files; | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | =head2 create_tmpl( ) | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | This method takes all the template files ending in .html (representing | ||||||||||||||||||||||||||||
| 286 | L<HTML::Template|HTML::Template>'s and installs them into a directory under the distro tree. | ||||||||||||||||||||||||||||
| 287 | For instance if the distro was called C<Foo-Bar>, the templates would be | ||||||||||||||||||||||||||||
| 288 | installed in C<lib/Foo/Bar/templates>. | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | Note the files will just be copied over not rendered. | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =cut | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub create_tmpl { | ||||||||||||||||||||||||||
|
Subroutine
create_tmpl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 295 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | return $self->tmpl_guts(); | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | =head2 create_xt( @modules ) | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | This method creates a bunch of *.t files for author tests. I<@modules> is a | ||||||||||||||||||||||||||||
| 303 | list of all modules in the distribution. | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | =cut | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub create_xt { | ||||||||||||||||||||||||||
|
Subroutine
create_xt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 308 | 0 | my ( $self, @modules ) = @_; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 0 | my %xt_files = $self->xt_guts(@modules); | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | my @files = map { $self->_create_t( 'xt', $_, $xt_files{$_} ) } keys %xt_files; | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 0 | return @files; | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | =head2 render( $template, \%options ) | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | This method is given an L<HTML::Template|HTML::Template> and options and | ||||||||||||||||||||||||||||
| 320 | returns the resulting document. | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | Data in the C<Module::Starter> object which represents a reference to an array | ||||||||||||||||||||||||||||
| 323 | @foo is transformed into an array of hashes with one key called | ||||||||||||||||||||||||||||
| 324 | C<$foo_item> in order to make it usable in an L<HTML::Template|HTML::Template> C<TMPL_LOOP>. | ||||||||||||||||||||||||||||
| 325 | For example: | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | $data = ['a'. 'b', 'c']; | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | would become: | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | $data = [ | ||||||||||||||||||||||||||||
| 332 | { data_item => 'a' }, | ||||||||||||||||||||||||||||
| 333 | { data_item => 'b' }, | ||||||||||||||||||||||||||||
| 334 | { data_item => 'c' }, | ||||||||||||||||||||||||||||
| 335 | ]; | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | so that in the template you could say: | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | <tmpl_loop data> | ||||||||||||||||||||||||||||
| 340 | <tmpl_var data_item> | ||||||||||||||||||||||||||||
| 341 | </tmpl_loop> | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | =cut | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 3 | ▶ | sub render { | ||||||||||||||||||||||||||
|
Subroutine
render: called CC=7 SCAR=33.5
Pod
documented
| |||||||||||||||||||||||||||||
| 346 | 3 | my ( $self, $template, $options ) = @_; | |||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | # we need a local copy of $options otherwise we get recursion in loops | ||||||||||||||||||||||||||||
| 349 | # because of [1] | ||||||||||||||||||||||||||||
| 350 | 3 | my %opts = %{$options}; | |||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 3 | $opts{nummodules} = scalar @{ $self->{modules} }; | |||||||||||||||||||||||||||
| 353 | 3 | $opts{year} = $self->_thisyear(); | |||||||||||||||||||||||||||
| 354 | 3 | $opts{license_blurb} = $self->_license_blurb(); | |||||||||||||||||||||||||||
| 355 | 0 | $opts{datetime} = scalar localtime; | |||||||||||||||||||||||||||
| 356 | $opts{buildscript} = | ||||||||||||||||||||||||||||
| 357 | 0 | Module::Starter::BuilderSet->new()->file_for_builder( $self->{builder} ); | |||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | 0 | foreach my $key ( keys %{$self} ) { | |||||||||||||||||||||||||||
| 360 | 0 | ▶ | next if defined $opts{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | 0 | $opts{$key} = $self->{$key}; | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | # [1] HTML::Templates wants loops to be arrays of hashes not plain arrays | ||||||||||||||||||||||||||||
| 365 | 0 | foreach my $key ( keys %opts ) { | |||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ( ref $opts{$key} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 0 | my @temp = (); | |||||||||||||||||||||||||||
| 368 | 0 | for my $option ( @{ $opts{$key} } ) { | |||||||||||||||||||||||||||
| 369 | 0 | push @temp, { "${key}_item" => $option }; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | 0 | $opts{$key} = [@temp]; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | 0 | ▶ | my $t = HTML::Template->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | die_on_bad_params => 0, | ||||||||||||||||||||||||||||
| 376 | scalarref => \$template, | ||||||||||||||||||||||||||||
| 377 | ) or croak "Can't create template $template"; | ||||||||||||||||||||||||||||
| 378 | 0 | $t->param( \%opts ); | |||||||||||||||||||||||||||
| 379 | 0 | return $t->output; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | =head2 templates ( ) | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | This method reads in the template files and populates the object's templates | ||||||||||||||||||||||||||||
| 385 | attribute. The module template directory is found by checking the | ||||||||||||||||||||||||||||
| 386 | C<MODULE_TEMPLATE_DIR> environment variable and then the config option | ||||||||||||||||||||||||||||
| 387 | C<template_dir>. | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | =cut | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 3 | ▶ | sub templates { | ||||||||||||||||||||||||||
|
Subroutine
templates: called CC=9 SCAR=24.2
Pod
documented
| |||||||||||||||||||||||||||||
| 392 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||
| 393 | 3 | my %template; | |||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | my $template_dir = ( $ENV{MODULE_TEMPLATE_DIR} || $self->{template_dir} ) | ||||||||||||||||||||||||||||
| 396 | 3 | ▶ | or croak 'template dir not defined'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{'MODULE_TEMPLATE_DIR'} || $self->{'template_dir'}
MC/DC0%0/2
$ENV{'MODULE_TEMPLATE_DIR'} || $self->{'template_dir'}
$ENV{'MODULE_TEMPLATE_DIR'}
$self->{'template_dir'}
Truth table33%1/3
A || B
A= $ENV{'MODULE_TEMPLATE_DIR'}B= $self->{'template_dir'}
| |||||||||||||||||||||||||||||
| 397 | 3 | ▶ | if ( !-d $template_dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | 0 | croak "template dir does not exist: $template_dir"; | |||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 1 | ▶ | foreach ( glob "$template_dir/*" ) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 402 | 57 | my $basename = basename $_; | |||||||||||||||||||||||||||
| 403 | 57 | ▶ | next if ( not -f $_ ) or ( $basename =~ /\A [.]/msx ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not -f $_ or $basename =~ /\A [.]/msx
MC/DC0%0/2
not -f $_ or $basename =~ /\A [.]/msx
not -f $_
$basename =~ /\A [.]/msx
Truth table33%1/3
not(A) or B
A= not -f $_B= $basename =~ /\A [.]/msx
| |||||||||||||||||||||||||||||
| 404 | 57 | ▶ | open my $template_file, '<', $_ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | or croak "couldn't open template: $_"; | ||||||||||||||||||||||||||||
| 406 | 57 | $template{$basename} = do { | |||||||||||||||||||||||||||
| 407 | 57 | local $RS = undef; | |||||||||||||||||||||||||||
| 408 | 57 | <$template_file>; | |||||||||||||||||||||||||||
| 409 | }; | ||||||||||||||||||||||||||||
| 410 | 57 | ▶ | close $template_file or croak "couldn't close template: $_"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 3 | return %template; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | =head2 Build_PL_guts($main_module, $main_pm_file) | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | This method is called by L<create_Build_PL|create_Build_PL> and returns text used to populate | ||||||||||||||||||||||||||||
| 419 | Build.PL when the builder is L<Module::Build|Module::Build>; I<$main_pm_file> | ||||||||||||||||||||||||||||
| 420 | is the filename of the distribution's main module, I<$main_module>. | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | =cut | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub Build_PL_guts { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
Build_PL_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 425 | 0 | my ( $self, $main_module, $main_pm_file ) = @_; | |||||||||||||||||||||||||||
| 426 | 0 | my %options; | |||||||||||||||||||||||||||
| 427 | 0 | $options{main_module} = $main_module; | |||||||||||||||||||||||||||
| 428 | 0 | $options{main_pm_file} = $main_pm_file; | |||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 0 | my $template = $self->{templates}{'Build.PL'}; | |||||||||||||||||||||||||||
| 431 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | =head2 Changes_guts | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | Implements the creation of a C<Changes> file. | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | =cut | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 0 | ▶ | sub Changes_guts { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
Changes_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 441 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 442 | 0 | my %options; | |||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 0 | my $template = $self->{templates}{Changes}; | |||||||||||||||||||||||||||
| 445 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | =head2 LICENSE_guts | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | Implements the creation of a C<LICENSE> file. | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | =cut | ||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | 0 | ▶ | sub LICENSE_guts { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
LICENSE_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 455 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 456 | 0 | my %options; | |||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | 0 | my $template = $self->{templates}{LICENSE}; | |||||||||||||||||||||||||||
| 459 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | 3 | ▶ | sub _license_blurb { | ||||||||||||||||||||||||||
|
Subroutine
_license_blurb: called CC=3 SCAR=20.0
| |||||||||||||||||||||||||||||
| 463 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 464 | 3 | my $license_blurb; | |||||||||||||||||||||||||||
| 465 | 3 | my $license_record = $self->_license_record(); | |||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ( defined $license_record ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if ( $license_record->{license} eq 'perl' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | 0 | $license_blurb = <<'EOT'; | |||||||||||||||||||||||||||
| 470 | This distribution is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 471 | under the terms of either: | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | a) the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||
| 474 | Foundation; either version 1, or (at your option) any later version, or | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | b) the Artistic License version 1.0 or a later version. | ||||||||||||||||||||||||||||
| 477 | EOT | ||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | else { | ||||||||||||||||||||||||||||
| 480 | 0 | $license_blurb = $license_record->{blurb}; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | else { | ||||||||||||||||||||||||||||
| 484 | 0 | $license_blurb = <<"EOT"; | |||||||||||||||||||||||||||
| 485 | This program is released under the following license: $self->{license} | ||||||||||||||||||||||||||||
| 486 | EOT | ||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||
| 488 | 0 | chomp $license_blurb; | |||||||||||||||||||||||||||
| 489 | 0 | return $license_blurb; | |||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | =head2 Makefile_PL_guts($main_module, $main_pm_file) | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | This method is called by L<create_Makefile_PL|create_Makefile_PL> and returns text used to populate | ||||||||||||||||||||||||||||
| 495 | Makefile.PL when the builder is L<ExtUtils::MakeMaker|ExtUtils::MakeMaker>; | ||||||||||||||||||||||||||||
| 496 | I<$main_pm_file> is the filename of the distribution's main module, | ||||||||||||||||||||||||||||
| 497 | I<$main_module>. | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =cut | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub Makefile_PL_guts { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
Makefile_PL_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 502 | 0 | my ( $self, $main_module, $main_pm_file ) = @_; | |||||||||||||||||||||||||||
| 503 | 0 | my %options; | |||||||||||||||||||||||||||
| 504 | 0 | $options{main_module} = $main_module; | |||||||||||||||||||||||||||
| 505 | 0 | $options{main_pm_file} = $main_pm_file; | |||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | 0 | my $template = $self->{templates}{'Makefile.PL'}; | |||||||||||||||||||||||||||
| 508 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | =head2 MANIFEST_SKIP_guts | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | Implements the creation of a C<MANIFEST.SKIP> file. | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | =cut | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 0 | ▶ | sub MANIFEST_SKIP_guts { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
MANIFEST_SKIP_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 518 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 519 | 0 | my %options; | |||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | 0 | my $template = $self->{templates}{'MANIFEST.SKIP'}; | |||||||||||||||||||||||||||
| 522 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | =head2 MI_Makefile_PL_guts($main_module, $main_pm_file) | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | This method is called by L<create_MI_Makefile_PL|create_MI_Makefile_PL> and returns text used to populate | ||||||||||||||||||||||||||||
| 528 | Makefile.PL when the builder is L<Module::Install|Module::Install>; | ||||||||||||||||||||||||||||
| 529 | I<$main_pm_file> is the filename of the distribution's main module, | ||||||||||||||||||||||||||||
| 530 | I<$main_module>. | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | =cut | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | 0 | ▶ | sub MI_Makefile_PL_guts { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
MI_Makefile_PL_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 535 | 0 | my ( $self, $main_module, $main_pm_file ) = @_; | |||||||||||||||||||||||||||
| 536 | 0 | my %options; | |||||||||||||||||||||||||||
| 537 | 0 | $options{main_module} = $main_module; | |||||||||||||||||||||||||||
| 538 | 0 | $options{main_pm_file} = $main_pm_file; | |||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 0 | my $template = $self->{templates}{'MI_Makefile.PL'}; | |||||||||||||||||||||||||||
| 541 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | =head2 module_guts($module, $rtname) | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | Implements the creation of a C<README> file. | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | =cut | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | 3 | ▶ | sub module_guts { | ||||||||||||||||||||||||||
|
Subroutine
module_guts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 551 | 3 | my ( $self, $module, $rtname ) = @_; | |||||||||||||||||||||||||||
| 552 | 3 | my %options; | |||||||||||||||||||||||||||
| 553 | 3 | $options{module} = $module; | |||||||||||||||||||||||||||
| 554 | 3 | $options{rtname} = $rtname; | |||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | 3 | my $template = $self->{templates}{'Module.pm'}; | |||||||||||||||||||||||||||
| 557 | 3 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | =head2 README_guts($build_instructions) | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | Implements the creation of a C<README> file. | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | =cut | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | 0 | ▶ | sub README_guts { ## no critic 'NamingConventions::Capitalization' | ||||||||||||||||||||||||||
|
Subroutine
README_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 567 | 0 | my ( $self, $build_instructions ) = @_; | |||||||||||||||||||||||||||
| 568 | 0 | my %options; | |||||||||||||||||||||||||||
| 569 | 0 | $options{build_instructions} = $build_instructions; | |||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 0 | my $template = $self->{templates}{'README'}; | |||||||||||||||||||||||||||
| 572 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | =head2 perlcriticrc_guts | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | Implements the creation of a C<perlcriticrc> file. | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =cut | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | 0 | ▶ | sub perlcriticrc_guts { | ||||||||||||||||||||||||||
|
Subroutine
perlcriticrc_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 582 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 583 | 0 | my %options; | |||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | 0 | my $template = $self->{templates}{perlcriticrc}; | |||||||||||||||||||||||||||
| 586 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | =head2 server_pl_guts | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | Implements the creation of a C<server.pl> file. | ||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | =cut | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | 0 | ▶ | sub server_pl_guts { | ||||||||||||||||||||||||||
|
Subroutine
server_pl_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 596 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 597 | 0 | my %options; | |||||||||||||||||||||||||||
| 598 | 0 | $options{main_module} = $self->{main_module}; | |||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | 0 | my $template = $self->{templates}{'server.pl'}; | |||||||||||||||||||||||||||
| 601 | 0 | return $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | =head2 t_guts(@modules) | ||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | Implements the creation of test files. I<@modules> is a list of all the modules | ||||||||||||||||||||||||||||
| 607 | in the distribution. | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | =cut | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | 0 | ▶ | sub t_guts { | ||||||||||||||||||||||||||
|
Subroutine
t_guts: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 612 | 0 | my ( $self, @opts ) = @_; | |||||||||||||||||||||||||||
| 613 | 0 | my %options; | |||||||||||||||||||||||||||
| 614 | 0 | $options{modules} = [@opts]; | |||||||||||||||||||||||||||
| 615 | 0 | $options{modulenames} = []; | |||||||||||||||||||||||||||
| 616 | 0 | foreach ( @{ $options{modules} } ) { | |||||||||||||||||||||||||||
| 617 | 0 | push @{ $options{module_pm_files} }, $self->_module_to_pm_file($_); | |||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | 0 | my %t_files; | |||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 0 | foreach ( grep { /[.]t\z/msx } keys %{ $self->{templates} } ) { | |||||||||||||||||||||||||||
| 623 | 0 | my $template = $self->{templates}{$_}; | |||||||||||||||||||||||||||
| 624 | 0 | $t_files{$_} = $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | 0 | return %t_files; | |||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | =head2 tmpl_guts | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | Implements the creation of template files. | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | =cut | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | 0 | ▶ | sub tmpl_guts { | ||||||||||||||||||||||||||
|
Subroutine
tmpl_guts: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 637 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 638 | 0 | my %options; # unused in this function. | |||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | 0 | my @dirparts = ( $self->{basedir}, 'share', 'templates' ); | |||||||||||||||||||||||||||
| 641 | 0 | my $tdir = File::Spec->catdir(@dirparts); | |||||||||||||||||||||||||||
| 642 | 0 | ▶ | if ( not -d $tdir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 643 | 0 | mkpath($tdir); | |||||||||||||||||||||||||||
| 644 | 0 | $self->progress("Created $tdir"); | |||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | 0 | my @t_files; | |||||||||||||||||||||||||||
| 648 | 0 | foreach | |||||||||||||||||||||||||||
| 649 | 0 | my $filename ( grep { /[.]html \z/msx } keys %{ $self->{templates} } ) | |||||||||||||||||||||||||||
| 650 | { | ||||||||||||||||||||||||||||
| 651 | 0 | my $template = $self->{templates}{$filename}; | |||||||||||||||||||||||||||
| 652 | 0 | my $fname = File::Spec->catfile( @dirparts, $filename ); | |||||||||||||||||||||||||||
| 653 | 0 | $self->create_file( $fname, $template ); | |||||||||||||||||||||||||||
| 654 | 0 | $self->progress("Created $fname"); | |||||||||||||||||||||||||||
| 655 | 0 | push @t_files, "share/templates/$filename"; | |||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | 0 | return @t_files; | |||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||
| 661 | =head2 xt_guts(@modules) | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | Implements the creation of test files for author tests. I<@modules> is a list | ||||||||||||||||||||||||||||
| 664 | of all the modules in the distribution. | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | =cut | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | 0 | ▶ | sub xt_guts { | ||||||||||||||||||||||||||
|
Subroutine
xt_guts: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 669 | 0 | my ( $self, @opts ) = @_; | |||||||||||||||||||||||||||
| 670 | 0 | my %options; | |||||||||||||||||||||||||||
| 671 | 0 | $options{modules} = [@opts]; | |||||||||||||||||||||||||||
| 672 | 0 | $options{modulenames} = []; | |||||||||||||||||||||||||||
| 673 | 0 | foreach ( @{ $options{modules} } ) { | |||||||||||||||||||||||||||
| 674 | 0 | push @{ $options{module_pm_files} }, $self->_module_to_pm_file($_); | |||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | 0 | my %xt_files; | |||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | 0 | foreach ( grep { /[.]xt\z/msx } keys %{ $self->{templates} } ) { | |||||||||||||||||||||||||||
| 680 | 0 | my $template = $self->{templates}{$_}; | |||||||||||||||||||||||||||
| 681 | 0 | $_ =~ s/[.]xt\z/.t/msx; # change *.xt back to *.t | |||||||||||||||||||||||||||
| 682 | 0 | $xt_files{$_} = $self->render( $template, \%options ); | |||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | 0 | return %xt_files; | |||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | =head1 BUGS | ||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||
| 691 | C<bug-module-starter-plugin-cgiapp at rt.cpan.org>, or through the web | ||||||||||||||||||||||||||||
| 692 | interface at L<rt.cpan.org|http://rt.cpan.org>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 693 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||
| 697 | Jaldhar H. Vyas, E<lt>jaldhar at braincells.comE<gt> | ||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||
| 699 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||
| 701 | Copyright (C) 2015, Consolidated Braincells Inc. All Rights Reserved. | ||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||
| 703 | This distribution is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 704 | under the terms of either: | ||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||
| 706 | a) the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||
| 707 | Foundation; either version 1, or (at your option) any later version, or | ||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||
| 709 | b) the Artistic License version 1.0 or a later version. | ||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | The full text of the license can be found in the LICENSE file included | ||||||||||||||||||||||||||||
| 712 | with this distribution. | ||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | L<cgiapp-starter|cgiapp-starter>, L<titanium-starter|titanium-starter>, L<Module::Starter|Module::Starter>, | ||||||||||||||||||||||||||||
| 717 | L<Module::Starter::Simple|Module::Starter::Simple>, L<Module::Starter::Plugin::Template|Module::Starter::Plugin::Template>. | ||||||||||||||||||||||||||||
| 718 | L<CGI::Application|CGI::Application>, L<Titanium|Titanium>, L<HTML::Template|HTML::Template> | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | =cut | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | 4 | 1; | |||||||||||||||||||||||||||