blib/lib/Clustericious/Command/configure.pm

filter: Statementstmt 46.1% 18 / 39 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 41.3% 24 / 58 CC 8 SCAR 38.0
CC
8
Cov
38%
run
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 44.7
« blib/lib/Clustericious/Command/start.pm ↑ Summary blib/lib/Clustericious/Client/Meta/Route.pm »
1 package Clustericious::Command::configure;
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 5.010;
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 Path::Class qw( dir );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Generate a default configuration.
10 1 our $VERSION = '1.29'; # VERSION
11  
12  
13 1 has description => <<EOT;
14 Write default configuration files.
15 EOT
16  
17 1 has usage => <<EOT;
18 usage $0: configure
19 EOT
20  
21 sub run
22 0 ▶{
Subroutine run: not called CC=8 SCAR=42.8
Pod documented
23 0 my($self, @args) = @_;
24  
25 0 ▶ my $root = dir($ENV{CLUSTERICIOUS_CONF_DIR} || $ENV{HOME});
Condition0%0/3
$ENV{'CLUSTERICIOUS_CONF_DIR'} || $ENV{'HOME'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'CLUSTERICIOUS_CONF_DIR'} || $ENV{'HOME'}
$ENV{'CLUSTERICIOUS_CONF_DIR'} $ENV{'HOME'}
Truth table0%0/3
A || B
A= $ENV{'CLUSTERICIOUS_CONF_DIR'}B= $ENV{'HOME'}
ABresult
1X1
011
000
26 0 my $conf = $self->app->generate_config(@args);
27  
28 0 ▶ for my $d (@{$conf->{dirs} || []}) {
Condition0%0/2
$conf->{'dirs'} || []
l!l
00
MC/DC0%0/1
$conf->{'dirs'} || []
$conf->{'dirs'}
Truth table0%0/2
A
A= $conf->{'dirs'}
Aresult
11
00
29 0 my $dir = dir($root, @$d);
30 0 ▶ -d $dir and do { say "-> exists : $dir"; next; };
Branch: 1 branch
BranchTrueFalseTotal
-d $dir and do { say "-> exists : $dir"; next } 0 0 0
31 0 my @made = $dir->mkpath;
32 0 say "-> mkdir $_" for @made;
33 }
34
35 0 my $config_root = dir($root)->subdir('etc');
36 0 for my $filename (keys %{$conf->{files}}) {
37 0 my $file = $config_root->file($filename);
38 0 ▶ -e $file and do {
Branch: 1 branch
BranchTrueFalseTotal
-e $file and do { say "-> exists : $file"; next } 0 0 0
39 0 say "-> exists : $file";
40 0 next;
41 };
42 0 say "-> write $file";
43 0 $file->spew($conf->{files}{$filename});
44 }
45  
46 0 1;
47 }
48  
49 1 1;
50  
51 __END__
« blib/lib/Clustericious/Command/start.pm ↑ Summary blib/lib/Clustericious/Client/Meta/Route.pm »