blib/lib/Clustericious/Command/generate/app.pm

filter: Statementstmt 50.0% 19 / 38 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 62.5% 5 / 8 Podpod 100% 1 / 1 totaltotal 41.6% 25 / 60 CC 7 SCAR 22.5
CC
7
Cov
38%
run
20.0
_installfile
12.0
__ANON__
6.0
CRAP 9.5
« blib/lib/Test/Clustericious/Log.pm ↑ Summary blib/lib/Clustericious/Config.pm »
1 package Clustericious::Command::generate::app;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Clustericious;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Mojo::Base 'Clustericious::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Clustericious command to generate a new Clustericious application
10 1 our $VERSION = '1.29'; # VERSION
11  
12  
13 1 has description => <<'EOF';
14 Generate Clustericious app.
15 EOF
16  
17 1 has usage => <<"EOF";
18 usage: $0 generate app [NAME]
19 EOF
20  
21 sub _installfile
22 0 ▶{
Subroutine _installfile: not called CC=3 SCAR=24.8
23 0 my $self = shift;
24 0 my ($templatedir, $file, $class) = @_;
25  
26 0 my $name = lc $class;
27  
28 0 (my $relpath = $file) =~ s/^$templatedir/$class/;
29 0 $relpath =~ s/APPCLASS/$class/g;
30 0 $relpath =~ s/APPNAME/$name/g;
31  
32 0 ▶ return if -e $relpath;
Branch: 1 branch
BranchTrueFalseTotal
if -e $relpath 0 0 0
33  
34 0 my $content = Mojo::Template->new->render_file( $file, $class );
35 0 $self->write_file($relpath, $content );
36 0 ▶ -x $file && $self->chmod_file($relpath, 0755);
Branch: 1 branch
BranchTrueFalseTotal
-x $file and $self->chmod_file($relpath, 493) 0 0 0
37 }
38  
39 sub run
40 0 ▶{
Subroutine run: not called CC=4 SCAR=30.0
Pod documented
41 0 my ($self, $class, @args ) = @_;
42 0 ▶ $class ||= 'MyClustericiousApp';
Condition0%0/2
$class ||= "MyClustericiousApp"
l!l
00
MC/DC0%0/1
$class ||= "MyClustericiousApp"
$class
Truth table0%0/2
A
A= $class
Aresult
11
00
43 0 ▶ if (@args % 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args % 2) 0 0 0
44 0 die "usage : $0 generate app <name>\n";
45 }
46 0 my %args = @args;
47  
48 0 my $templatedir = Clustericious->_dist_dir->subdir('tmpl', '1.08', 'app');
49  
50 0 ▶ die "Can't find template.\n" unless -d $templatedir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $templatedir 0 0 0
51  
52 0 ▶ find({wanted => sub { $self->_installfile($templatedir, $_, $class) if -f },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if -f $_ 0 0 0
53 0 no_chdir => 1}, $templatedir);
54 }
55  
56 1 1;
57  
58 __END__
« blib/lib/Test/Clustericious/Log.pm ↑ Summary blib/lib/Clustericious/Config.pm »