| 1 | package Catalyst::Helper; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use File::Spec::Unix; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use FindBin; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use POSIX 'strftime'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Template; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Catalyst::Devel; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use Catalyst::Utils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use Catalyst::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use Path::Class qw/dir file/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 9 | ▶ | use File::ShareDir qw/dist_dir/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 9 | ▶ | use YAML::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 9 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 9 | with 'MooseX::Emulate::Class::Accessor::Fast'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 9 | our $VERSION = '1.42'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 9 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | my %cache; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 39 | ▶ | sub get_sharedir_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_sharedir_file: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 39 | my ($self, @filename) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 39 | my $dist_dir; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 39 | ▶ | if (exists $ENV{CATALYST_DEVEL_SHAREDIR}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 36 | $dist_dir = $ENV{CATALYST_DEVEL_SHAREDIR}; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ▶ | elsif (-d "inc/.author" && -f "lib/Catalyst/Helper.pm" | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
-d "inc/.author" and -f "lib/Catalyst/Helper.pm"
MC/DC0%0/2
-d "inc/.author" and -f "lib/Catalyst/Helper.pm"
-d "inc/.author"
-f "lib/Catalyst/Helper.pm"
Truth table33%1/3
A and B
A= -d "inc/.author"B= -f "lib/Catalyst/Helper.pm"
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | ) { # Can't use sharedir if we're in a checkout | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # this feels horrible, better ideas? | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $dist_dir = 'share'; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 3 | $dist_dir = dist_dir('Catalyst-Devel'); | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 39 | my $file = file( $dist_dir, @filename); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 39 | ▶ | Carp::confess("Cannot find $file") unless -r $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 38 | my $contents = $file->slurp(iomode => "<:raw"); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 38 | return $contents; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # Do not touch this method, *EVER*, it is needed for back compat. | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | ▶ | sub get_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_file: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | my ( $self, $class, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | unless ( $cache{$class} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | local $/; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $cache{$class} = eval "package $class; <DATA>"; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | my $data = $cache{$class}; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | Carp::confess("Could not get data from __DATA__ segment for $class") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | unless $data; | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | my @files = split /^__(.+)__\r?\n/m, $data; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | shift @files; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | ▶ | while (@files) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | my ( $name, $content ) = splice @files, 0, 2; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | return $content if $name eq $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | sub mk_app { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_app: called CC=21 SCAR=33.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # Needs to be here for PAR | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | require Catalyst; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | if($name eq '.') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | if(!-e 'META.yml') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | system perl => 'Makefile.PL' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | and Catalyst::Exception->throw(message => q( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | Failed to run "perl Makefile.PL". | ||||||||||||||||||||||||||||||||||||||||||
| 77 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | $name = YAML::Tiny->read('META.yml')->[0]->{'name'}; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | $name =~ s/-/::/g; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | $self->{dir} = '.'; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | if ( $name =~ /[^\w:]/ || $name =~ /^\d/ || $name =~ /\b:\b|:{3,}/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$name =~ /[^\w:]/ or $name =~ /^\d/ or $name =~ /\b:\b|:{3,}/
$name =~ /[^\w:]/ or $name =~ /^\d/
MC/DC0%0/3
$name =~ /[^\w:]/ or $name =~ /^\d/ or $name =~ /\b:\b|:{3,}/
$name =~ /[^\w:]/
$name =~ /^\d/
$name =~ /\b:\b|:{3,}/
Truth table25%1/4
A or B or C
A= $name =~ /[^\w:]/B= $name =~ /^\d/C= $name =~ /\b:\b|:{3,}/
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | warn "Error: Invalid application name.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | if(!defined $self->{'dir'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | $self->{dir} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | $self->{dir} =~ s/\:\:/-/g; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | $self->{name } = $name; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | $self->{script } = dir( $self->{dir}, 'script' ); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | $self->{appprefix } = Catalyst::Utils::appprefix($name); | |||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | $self->{appenv } = Catalyst::Utils::class2env($name); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | $self->{startperl } = -r '/usr/bin/env' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | ? '#!/usr/bin/env perl' | ||||||||||||||||||||||||||||||||||||||||||
| 102 | : "#!$Config{perlpath}"; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | $self->{scriptgen } = $Catalyst::Devel::CATALYST_SCRIPT_GEN; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | $self->{catalyst_version} = $Catalyst::VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 105 | $self->{author } ||= $ENV{'AUTHOR'} | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | ▶ | || eval { @{ [ getpwuid($<) ] }[6] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
$self->{"author"} ||= $ENV{"AUTHOR"} || eval {
do {
@{[getpwuid $<];}[6]
}
} || "Catalyst developer"
$ENV{'AUTHOR'} || eval {
do {
@{[getpwuid $<];}[6]
}
} || 'Catalyst developer'
$ENV{"AUTHOR"} or eval {
do {
@{[getpwuid $<];}[6]
}
}
MC/DC0%0/3
$self->{"author"} ||= $ENV{"AUTHOR"} || eval {
do {
@{[getpwuid $<];}[6]
}
} || "Catalyst developer"
$self->{"author"}
$ENV{"AUTHOR"}
eval {
do {
@{[getpwuid $<];}[6]
}
}
Truth table0%0/4
A ||= B or C
A= $self->{"author"}B= $ENV{"AUTHOR"}C= eval {
do {
@{[getpwuid $<];}[6]
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | || 'Catalyst developer'; | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | ▶ | my $gen_scripts = ( $self->{makefile} ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | ▶ | my $gen_makefile = ( $self->{scripts} ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | ▶ | my $gen_app = ( $self->{scripts} || $self->{makefile} ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"scripts"} or $self->{"makefile"}
MC/DC50%1/2
$self->{"scripts"} or $self->{"makefile"}
$self->{"scripts"}
$self->{"makefile"}
Truth table66%2/3
A or B
A= $self->{"scripts"}B= $self->{"makefile"}
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | ▶ | if ($gen_app) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | for ( qw/ _mk_dirs _mk_config _mk_psgi _mk_appclass _mk_rootclass | |||||||||||||||||||||||||||||||||||||||||
| 115 | _mk_readme _mk_changes _mk_apptest _mk_podtest _mk_podcoveragetest | ||||||||||||||||||||||||||||||||||||||||||
| 116 | _mk_images _mk_favicon/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 12 | $self->$_; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | if ($gen_makefile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | $self->_mk_makefile; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | ▶ | if ($gen_scripts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | for ( qw/ _mk_cgi _mk_fastcgi _mk_server | |||||||||||||||||||||||||||||||||||||||||
| 125 | _mk_test _mk_create _mk_information | ||||||||||||||||||||||||||||||||||||||||||
| 126 | / ) { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 12 | $self->$_; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | return $self->{dir}; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | ## not much of this can really be changed, mk_compclass must be left for | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ## backcompat | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | ▶ | sub mk_component { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_component: called CC=22 SCAR=43.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | my $app = shift; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | $self->{app} = $app; | |||||||||||||||||||||||||||||||||||||||||
| 139 | $self->{author} = $self->{author} = $ENV{'AUTHOR'} | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | ▶ | || eval { @{ [ getpwuid($<) ] }[6] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$ENV{'AUTHOR'} || eval {
do {
@{[getpwuid $<];}[6]
}
} || 'A clever guy'
$ENV{"AUTHOR"} or eval {
do {
@{[getpwuid $<];}[6]
}
}
MC/DC0%0/2
$ENV{'AUTHOR'} || eval {
do {
@{[getpwuid $<];}[6]
}
} || 'A clever guy'
$ENV{"AUTHOR"}
eval {
do {
@{[getpwuid $<];}[6]
}
}
Truth table33%1/3
A or B
A= $ENV{"AUTHOR"}B= eval {
do {
@{[getpwuid $<];}[6]
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | || 'A clever guy'; | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 3 | ▶ | $self->{base} ||= dir( $FindBin::Bin, '..' ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"base"} ||= dir($FindBin::Bin, "..")
MC/DC0%0/2
$self->{"base"} ||= dir($FindBin::Bin, "..")
$self->{"base"}
dir($FindBin::Bin, "..")
Truth table33%1/3
A ||= B
A= $self->{"base"}B= dir($FindBin::Bin, "..")
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | ▶ | unless ( $_[0] =~ /^(?:model|view|controller)$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $helper = shift; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $class = "Catalyst::Helper::$helper"; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | eval "require $class"; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | Catalyst::Exception->throw( | |||||||||||||||||||||||||||||||||||||||||
| 151 | message => qq/Couldn't load helper "$class", "$@"/ ); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ( $class->can('mk_stuff') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return 1 unless $class->mk_stuff( $self, @args ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | my $name = shift || "Missing name for model/view/controller"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 'Missing name for model/view/controller'
MC/DC0%0/1
shift() || 'Missing name for model/view/controller'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | my $helper = shift; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | return 0 if $name =~ /[^\w\:]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | $type = lc $type; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | $self->{long_type} = ucfirst $type; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | $type = 'M' if $type =~ /model/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | $type = 'V' if $type =~ /view/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | ▶ | $type = 'C' if $type =~ /controller/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | my $appdir = dir( split /\:\:/, $app ); | |||||||||||||||||||||||||||||||||||||||||
| 170 | my $test_path = | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | dir( $self->{base}, 'lib', $appdir, 'C' ); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | ▶ | $type = $self->{long_type} unless -d $test_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | $self->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | $self->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | $self->{class} = "$app\::$type\::$name"; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | # Class | ||||||||||||||||||||||||||||||||||||||||||
| 178 | my $path = | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | dir( $self->{base}, 'lib', $appdir, $type ); | |||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | my $file = $name; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | ▶ | if ( $name =~ /\:/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my @path = split /\:\:/, $name; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $file = pop @path; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $path = dir( $path, @path ); | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | $self->mk_dir($path); | |||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | $file = file( $path, "$file.pm" ); | |||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | $self->{file} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | # Test | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 3 | $self->{test_dir} = dir( $self->{base}, 't' ); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | $self->{test} = $self->next_test; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # Helper | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | if ($helper) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $comp = $self->{long_type}; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $class = "Catalyst::Helper::$comp\::$helper"; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | eval "require $class"; | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | Catalyst::Exception->throw( | |||||||||||||||||||||||||||||||||||||||||
| 202 | message => qq/Couldn't load helper "$class", "$@"/ ); | ||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ( $class->can('mk_compclass') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | return 1 unless $class->mk_compclass( $self, @args ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | return 1 unless $self->_mk_compclass | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( $class->can('mk_comptest') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $class->mk_comptest( $self, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $self->_mk_comptest | |||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | # Fallback | ||||||||||||||||||||||||||||||||||||||||||
| 221 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | ▶ | return 1 unless $self->_mk_compclass; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 | $self->_mk_comptest; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 17 | ▶ | sub mk_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_dir: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 17 | my ( $self, $dir ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 17 | ▶ | if ( -d $dir ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | print qq/ exists "$dir"\n/; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 11 | ▶ | if ( mkpath [$dir] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 11 | print qq/created "$dir"\n/; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 11 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | Catalyst::Exception->throw( message => qq/Couldn't create "$dir", "$!"/ ); | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 39 | ▶ | sub mk_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_file: called CC=10 SCAR=29.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 39 | my ( $self, $file, $content ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 39 | ▶ | if ( -e $file && -s _ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
-e $file and -s _
MC/DC100%2/2
-e $file and -s _
-e $file
-s _
Truth table100%3/3
A and B
A= -e $fileB= -s _
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | print qq/ exists "$file"\n/; | |||||||||||||||||||||||||||||||||||||||||
| 247 | return 0 | ||||||||||||||||||||||||||||||||||||||||||
| 248 | unless ( $self->{'.newfiles'} | ||||||||||||||||||||||||||||||||||||||||||
| 249 | || $self->{scripts} | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 5 | ▶ | || $self->{makefile} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{".newfiles"} or $self->{"scripts"} or $self->{"makefile"}
$self->{".newfiles"} or $self->{"scripts"}
MC/DC0%0/3
$self->{".newfiles"} or $self->{"scripts"} or $self->{"makefile"}
$self->{".newfiles"}
$self->{"scripts"}
$self->{"makefile"}
Truth table25%1/4
A or B or C
A= $self->{".newfiles"}B= $self->{"scripts"}C= $self->{"makefile"}
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 5 | ▶ | if ( $self->{'.newfiles'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ( my $f = IO::File->new("< $file") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $oldcontent = join( '', (<$f>) ); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | return 0 if $content eq $oldcontent; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $file .= '.new'; | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 39 | ▶ | if ( my $f = IO::File->new("> $file") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 39 | binmode $f; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 39 | print $f $content; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 39 | print qq/created "$file"\n/; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 39 | return $file; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | Catalyst::Exception->throw( message => qq/Couldn't create "$file", "$!"/ ); | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | ▶ | sub next_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_test: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | my ( $self, $tname ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if ($tname) { $tname = "$tname.t" } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | my $name = $self->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | my $prefix = $name; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 3 | $prefix =~ s/::/-/g; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | $prefix = $prefix; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | $tname = $prefix . '.t'; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | $self->{prefix} = $prefix; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | $prefix = lc $prefix; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | $prefix =~ s/-/\//g; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | $self->{uri} = "/$prefix"; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 3 | my $dir = $self->{test_dir}; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 3 | my $type = lc $self->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 3 | $self->mk_dir($dir); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | return file( $dir, "$type\_$tname" ); | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | # Do not touch this method, *EVER*, it is needed for back compat. | ||||||||||||||||||||||||||||||||||||||||||
| 291 | ## addendum: we had to split this method so we could have backwards | ||||||||||||||||||||||||||||||||||||||||||
| 292 | ## compatibility. otherwise, we'd have no way to pass stuff from __DATA__ | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | sub render_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | my ( $self, $file, $path, $vars, $perms ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | my $template = $self->get_file( ( caller(0) )[0], $file ); | |||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | $self->render_file_contents($template, $path, $vars, $perms); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 27 | ▶ | sub render_sharedir_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_sharedir_file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 27 | my ( $self, $file, $path, $vars, $perms ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 27 | my $template = $self->get_sharedir_file( $file ); | |||||||||||||||||||||||||||||||||||||||||
| 303 | 27 | ▶ | die("Cannot get template from $file for $self\n") unless $template; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 27 | $self->render_file_contents($template, $path, $vars, $perms); | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 29 | ▶ | sub render_file_contents { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_file_contents: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 29 | my ( $self, $template, $path, $vars, $perms ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 29 | ▶ | $vars ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$vars ||= {}
MC/DC100%1/1
$vars ||= {}
$vars
Truth table100%2/2
A
A= $vars
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 29 | my $t = Template->new; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 29 | ▶ | return 0 unless $template; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 29 | my $output; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 29 | ▶ | $t->process( \$template, { %{$self}, %$vars }, \$output ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | || Catalyst::Exception->throw( | ||||||||||||||||||||||||||||||||||||||||||
| 315 | message => qq/Couldn't process "$template", / . $t->error() ); | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 29 | my $file = $self->mk_file( $path, $output ); | |||||||||||||||||||||||||||||||||||||||||
| 317 | 29 | ▶ | chmod $perms, file($file) if defined $perms; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 29 | return $file; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | ▶ | sub _mk_information { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_information: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | print qq/Change to application directory and Run "perl Makefile.PL" to make sure your install is complete\n/; | |||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | ▶ | sub _mk_dirs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_dirs: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | $self->mk_dir( $self->{dir} ); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | $self->mk_dir( $self->{script} ); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | $self->{lib} = dir( $self->{dir}, 'lib' ); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | $self->mk_dir( $self->{lib} ); | |||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | $self->{root} = dir( $self->{dir}, 'root' ); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | $self->mk_dir( $self->{root} ); | |||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | $self->{static} = dir( $self->{root}, 'static' ); | |||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | $self->mk_dir( $self->{static} ); | |||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | $self->{images} = dir( $self->{static}, 'images' ); | |||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | $self->mk_dir( $self->{images} ); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | $self->{t} = dir( $self->{dir}, 't' ); | |||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | $self->mk_dir( $self->{t} ); | |||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | $self->{class} = dir( split( /\:\:/, $self->{name} ) ); | |||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | $self->{mod} = dir( $self->{lib}, $self->{class} ); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 1 | $self->mk_dir( $self->{mod} ); | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | ▶ | if ( $self->{short} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->{m} = dir( $self->{mod}, 'M' ); | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $self->mk_dir( $self->{m} ); | |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $self->{v} = dir( $self->{mod}, 'V' ); | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $self->mk_dir( $self->{v} ); | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $self->{c} = dir( $self->{mod}, 'C' ); | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->mk_dir( $self->{c} ); | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | $self->{m} = dir( $self->{mod}, 'Model' ); | |||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | $self->mk_dir( $self->{m} ); | |||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | $self->{v} = dir( $self->{mod}, 'View' ); | |||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | $self->mk_dir( $self->{v} ); | |||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | $self->{c} = dir( $self->{mod}, 'Controller' ); | |||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | $self->mk_dir( $self->{c} ); | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | my $name = $self->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 362 | $self->{rootname} = | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | ▶ | $self->{short} ? "$name\::C::Root" : "$name\::Controller::Root"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | $self->{base} = dir( $self->{dir} )->absolute; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | ▶ | sub _mk_appclass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_appclass: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | my $mod = $self->{mod}; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | $self->render_sharedir_file( file('lib', 'MyApp.pm.tt'), "$mod.pm" ); | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | ▶ | sub _mk_rootclass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_rootclass: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 375 | $self->render_sharedir_file( file('lib', 'MyApp', 'Controller', 'Root.pm.tt'), | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | file( $self->{c}, "Root.pm" ) ); | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | ▶ | sub _mk_makefile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_makefile: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | $self->{path} = join('/', 'lib', split( '::', $self->{name} ) ); | |||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | $self->{path} .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | my $dir = $self->{dir}; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | $self->render_sharedir_file( 'Makefile.PL.tt', file($dir, "Makefile.PL") ); | |||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | ▶ | if ( $self->{makefile} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | # deprecate the old Build.PL file when regenerating Makefile.PL | ||||||||||||||||||||||||||||||||||||||||||
| 389 | $self->_deprecate_file( | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | file( $self->{dir}, 'Build.PL' ) ); | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | ▶ | sub _mk_psgi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_psgi: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | my $dir = $self->{dir}; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | my $appprefix = $self->{appprefix}; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | $self->render_sharedir_file( 'myapp.psgi.tt', | |||||||||||||||||||||||||||||||||||||||||
| 399 | file( $dir, "$appprefix.psgi" ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | ▶ | sub _mk_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_config: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | my $dir = $self->{dir}; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | my $appprefix = $self->{appprefix}; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | $self->render_sharedir_file( 'myapp.conf.tt', | |||||||||||||||||||||||||||||||||||||||||
| 407 | file( $dir, "$appprefix.conf" ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | ▶ | sub _mk_readme { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_readme: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | my $dir = $self->{dir}; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | $self->render_sharedir_file( 'README.tt', file($dir, "README") ); | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | sub _mk_changes { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_changes: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | my $dir = $self->{dir}; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | my $time = strftime('%Y-%m-%d %H:%M:%S', localtime time); | |||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | $self->render_sharedir_file( 'Changes.tt', file($dir, "Changes"), { time => $time } ); | |||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 1 | ▶ | sub _mk_apptest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_apptest: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | my $t = $self->{t}; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | $self->render_sharedir_file( file('t', '01app.t.tt'), file($t, "01app.t") ); | |||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | ▶ | sub _mk_podtest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_podtest: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | my $t = $self->{t}; | |||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | $self->render_sharedir_file( file('t', '02pod.t.tt'), file($t, "02pod.t") ); | |||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | ▶ | sub _mk_podcoveragetest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_podcoveragetest: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | my $t = $self->{t}; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | $self->render_sharedir_file( file('t', '03podcoverage.t.tt'), file($t, "03podcoverage.t") ); | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | ▶ | sub _mk_cgi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_cgi: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | my $script = $self->{script}; | |||||||||||||||||||||||||||||||||||||||||
| 444 | 2 | my $appprefix = $self->{appprefix}; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | $self->render_sharedir_file( file('script', 'myapp_cgi.pl.tt'), | |||||||||||||||||||||||||||||||||||||||||
| 446 | file($script,"$appprefix\_cgi.pl"), undef, 0755 ); | ||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | ▶ | sub _mk_fastcgi { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_fastcgi: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | my $script = $self->{script}; | |||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | my $appprefix = $self->{appprefix}; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | $self->render_sharedir_file( file('script', 'myapp_fastcgi.pl.tt'), | |||||||||||||||||||||||||||||||||||||||||
| 454 | file($script, "$appprefix\_fastcgi.pl"), undef, 0755 ); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 2 | ▶ | sub _mk_server { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_server: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | my $script = $self->{script}; | |||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | my $appprefix = $self->{appprefix}; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 2 | $self->render_sharedir_file( file('script', 'myapp_server.pl.tt'), | |||||||||||||||||||||||||||||||||||||||||
| 462 | file($script, "$appprefix\_server.pl"), undef, 0755 ); | ||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | ▶ | sub _mk_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 2 | my $script = $self->{script}; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | my $appprefix = $self->{appprefix}; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 2 | $self->render_sharedir_file( file('script', 'myapp_test.pl.tt'), | |||||||||||||||||||||||||||||||||||||||||
| 470 | file($script, "$appprefix\_test.pl"), undef, 0755 ); | ||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 2 | ▶ | sub _mk_create { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_create: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | my $script = $self->{script}; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | my $appprefix = $self->{appprefix}; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 2 | $self->render_sharedir_file( file('script', 'myapp_create.pl.tt'), | |||||||||||||||||||||||||||||||||||||||||
| 478 | file($script, "$appprefix\_create.pl"), undef, 0755 ); | ||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 3 | ▶ | sub _mk_compclass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_compclass: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | my $file = $self->{file}; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 3 | return $self->render_sharedir_file( file('lib', 'Helper', 'compclass.pm.tt'), $file ); | |||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 3 | ▶ | sub _mk_comptest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_comptest: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 489 | 3 | my $test = $self->{test}; | |||||||||||||||||||||||||||||||||||||||||
| 490 | 3 | $self->render_sharedir_file( file('t', 'comptest.tt'), $test ); ## wtf do i rename this to? | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 1 | ▶ | sub _mk_images { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_images: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | my $images = $self->{images}; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | my @images = | |||||||||||||||||||||||||||||||||||||||||
| 497 | qw/catalyst_logo btn_120x50_built btn_120x50_built_shadow | ||||||||||||||||||||||||||||||||||||||||||
| 498 | btn_120x50_powered btn_120x50_powered_shadow btn_88x31_built | ||||||||||||||||||||||||||||||||||||||||||
| 499 | btn_88x31_built_shadow btn_88x31_powered btn_88x31_powered_shadow/; | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 1 | for my $name (@images) { | |||||||||||||||||||||||||||||||||||||||||
| 501 | 9 | my $image = $self->get_sharedir_file("root", "static", "images", "$name.png.bin"); | |||||||||||||||||||||||||||||||||||||||||
| 502 | 9 | $self->mk_file( file( $images, "$name.png" ), $image ); | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | ▶ | sub _mk_favicon { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mk_favicon: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 1 | my $root = $self->{root}; | |||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | my $favicon = $self->get_sharedir_file( 'root', 'favicon.ico.bin' ); | |||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | my $dest = dir( $root, "favicon.ico" ); | |||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | $self->mk_file( $dest, $favicon ); | |||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | sub _deprecate_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deprecate_file: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if ( -e $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my ($f, $oldcontent); | |||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ( $f = IO::File->new("< $file") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | $oldcontent = join( '', (<$f>) ); | |||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $newfile = $file . '.deprecated'; | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | if ( $f = IO::File->new("> $newfile") ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | binmode $f; | |||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | print $f $oldcontent; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | print qq/created "$newfile"\n/; | |||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | unlink $file; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | print qq/removed "$file"\n/; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | Catalyst::Exception->throw( | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | message => qq/Couldn't create "$file", "$!"/ ); | |||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 537 | __END__ | ||||||||||||||||||||||||||||||||||||||||||