| 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'}
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'}
| |||||||||||||||||||||
| 26 | 0 | my $conf = $self->app->generate_config(@args); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | for my $d (@{$conf->{dirs} || []}) { | ||||||||||||||||||
|
Condition0%0/2
$conf->{'dirs'} || []
MC/DC0%0/1
$conf->{'dirs'} || []
$conf->{'dirs'}
Truth table0%0/2
A
A= $conf->{'dirs'}
| |||||||||||||||||||||
| 29 | 0 | my $dir = dir($root, @$d); | |||||||||||||||||||
| 30 | 0 | ▶ | -d $dir and do { say "-> exists : $dir"; next; }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||