VTide/Command/Init.pm

filter: Statementstmt 58.0% 29 / 50 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 72.7% 8 / 11 Podpod 100% 3 / 3 totaltotal 50.6% 40 / 79 CC 6 SCAR 28.0
CC
6
Cov
48%
run
42.0
details_sub
2.0
auto_complete
2.0
CRAP 16.5
« VTide/Command/Split.pm ↑ Summary VTide/Command/Recent.pm »
1 package App::VTide::Command::Init;
2  
3 # Created on: 2016-01-30 15:06:31
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use YAML::Syck;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 extends 'App::VTide::Command';
19  
20 1 our $VERSION = version->new('1.0.6');
21 1 our $NAME = 'init';
22 1 our $OPTIONS = [
23 'name|n=s',
24 'dir|d=s',
25 'windows|w=i',
26 'force|f!',
27 'verbose|v+',
28 ];
29 0 ▶sub details_sub { return ( $NAME, $OPTIONS )};
Subroutine details_sub: not called CC=1 SCAR=6.9
Pod documented
30  
31 0 ▶sub run {
Subroutine run: not called CC=6 SCAR=37.4
Pod documented
32 0 my ($self) = @_;
33 0 ▶ my $dir = path( $self->defaults->{dir} || '.' )->absolute;
Condition0%0/2
$self->defaults->{'dir'} || '.'
l!l
00
MC/DC0%0/1
$self->defaults->{'dir'} || '.'
$self->defaults->{'dir'}
Truth table0%0/2
A
A= $self->defaults->{'dir'}
Aresult
11
00
34 0 my $file = $dir->path( '.vtide.yml' );
35 0 ▶ my $count = $self->defaults->{windows} || 4;
Condition0%0/2
$self->defaults->{'windows'} || 4
l!l
00
MC/DC0%0/1
$self->defaults->{'windows'} || 4
$self->defaults->{'windows'}
Truth table0%0/2
A
A= $self->defaults->{'windows'}
Aresult
11
00
36 0 ▶ my $name = $self->defaults->{name} || $dir->basename;
Condition0%0/3
$self->defaults->{'name'} || $dir->basename
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->defaults->{'name'} || $dir->basename
$self->defaults->{'name'} $dir->basename
Truth table0%0/3
A || B
A= $self->defaults->{'name'}B= $dir->basename
ABresult
1X1
011
000
37  
38 0 $self->hooks->run('init_name', \$name);
39  
40 my $config = {
41 name => $name,
42 count => $count,
43 default => {
44 restart => 0,
45 wait => 0,
46 },
47 editor => {
48 files => {
49 eg => [qw/some-file.eg/],
50 },
51 },
52 terminals => {
53 0 map { $_ => [] } 2 .. $count
54 },
55 };
56  
57 0 $self->hooks->run('init_config', $config);
58  
59 0 ▶ if ( -f $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $file) 0 0 0
60 0 ▶ if ( ! $self->defaults->{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->defaults->{"force"}) 0 0 0
61 0 die "The config file '.vtide.yml' already exists wont overwrite without --force!\n";
62 }
63 0 warn "Overwritting '.vtide.yml'\n";
64 }
65  
66 0 my $yaml = Dump( $config );
67 0 my $now = localtime;
68 0 $yaml =~ s/^(---\s*\n)/$1# Create by App::VTide::Command::Init $now VERSION $App::VTide::Command::Init::VERSION\n/xms;
69  
70 0 $file->spew($yaml);
71  
72 0 $self->save_session( $name, $dir );
73  
74 0 return;
75 }
76  
77 0 ▶sub auto_complete {
Subroutine auto_complete: not called CC=1 SCAR=6.9
Pod documented
78 0 return;
79 }
80  
81 1 1;
82  
83 __END__
« VTide/Command/Split.pm ↑ Summary VTide/Command/Recent.pm »