blib/lib/Shipwright/Script.pm

filter: Statementstmt 89.7% 35 / 39 Branchbran 61.1% 11 / 18 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 78.7% 63 / 80 CC 12 SCAR 23.2
CC
12
Cov
79%
prepare
16.3
BEGIN
1.0
BEGIN
1.0
CRAP 10.2
« blib/lib/Shipwright/Backend/Git.pm ↑ Summary blib/lib/Shipwright/Script/Defaultbranch.pm »
1 package Shipwright::Script;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use App::CLI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Shipwright::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use base qw/App::CLI Shipwright::Base/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 __PACKAGE__->mk_accessors(qw/repository log_file log_level/);
9  
10 =head2 alias
11 =cut
12  
13 9 ▶sub alias {
Subroutine alias: called CC=1 SCAR=0.0
Pod documented
14 return (
15 9 ls => 'list',
16 del => 'delete',
17 up => 'update',
18 init => 'create',
19 initialize => 'create',
20 );
21 }
22  
23 =head2 global_options
24  
25 =cut
26  
27 9 ▶sub global_options {
Subroutine global_options: called CC=1 SCAR=0.0
Pod documented
28 (
29 9 'r|repository=s' => 'repository',
30 'l|log-level=s' => 'log_level',
31 'log-file=s' => 'log_file',
32 );
33 }
34  
35 =head2 prepare
36 =cut
37  
38 9 ▶sub prepare {
Subroutine prepare: called CC=12 SCAR=27.9
Pod documented
39 9 my $self = shift;
40 9 ▶ $ARGV[0] = 'help' unless @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV 1 8 9
41  
42 9 ▶ if ( $ARGV[0] =~ /--?h(elp)?/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ARGV[0] =~ /--?h(elp)?/i) { } 2 7 9
elsif ($ARGV[0] =~ /^(-v|--version|version)$/) { } 0 7 7
43 2 $ARGV[0] = 'help';
44 }
45 elsif ( $ARGV[0] =~ /^(-v|--version|version)$/ ) {
46 0 print( "This is Shipwright, version $Shipwright::VERSION" . "\n" );
47 0 exit 0;
48 }
49  
50 9 my $action = $ARGV[0];
51  
52 9 my $cmd = $self->SUPER::prepare(@_);
53  
54 6 ▶ unless ( ref $cmd eq 'Shipwright::Script::Help' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $cmd eq "Shipwright::Script::Help") 3 3 6
55 $cmd->repository( $ENV{SHIPWRIGHT_SHIPYARD} )
56 3 ▶ if !$cmd->repository && $ENV{SHIPWRIGHT_SHIPYARD};
Branch: 1 branch
BranchTrueFalseTotal
if not $cmd->repository and $ENV{"SHIPWRIGHT_SHIPYARD"} 0 3 3
Condition66%2/3
not $cmd->repository and $ENV{"SHIPWRIGHT_SHIPYARD"}
!ll&&!rl&&r
210
MC/DC0%0/2
not $cmd->repository and $ENV{"SHIPWRIGHT_SHIPYARD"}
not $cmd->repository $ENV{"SHIPWRIGHT_SHIPYARD"}
Truth table66%2/3
not(A) and B
A= not $cmd->repositoryB= $ENV{"SHIPWRIGHT_SHIPYARD"}
ABresult
0X0
100
111
57 $cmd->repository( $ENV{SHIPWRIGHT_REPOSITORY} )
58 3 ▶ if !$cmd->repository && $ENV{SHIPWRIGHT_REPOSITORY};
Branch: 1 branch
BranchTrueFalseTotal
if not $cmd->repository and $ENV{"SHIPWRIGHT_REPOSITORY"} 0 3 3
Condition66%2/3
not $cmd->repository and $ENV{"SHIPWRIGHT_REPOSITORY"}
!ll&&!rl&&r
210
MC/DC0%0/2
not $cmd->repository and $ENV{"SHIPWRIGHT_REPOSITORY"}
not $cmd->repository $ENV{"SHIPWRIGHT_REPOSITORY"}
Truth table66%2/3
not(A) and B
A= not $cmd->repositoryB= $ENV{"SHIPWRIGHT_REPOSITORY"}
ABresult
0X0
100
111
59 3 ▶ if ( $cmd->repository ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd->repository) { } 2 1 3
60 2 require Shipwright::Backend;
61 2 my $backend = Shipwright::Backend->new(
62 repository => $cmd->repository,
63 no_sync_local_dir => 1,
64 );
65  
66 # this $shipwright object will do nothing, except for init logging
67 0 my $shipwright = Shipwright->new(
68 repository => $cmd->repository,
69 log_level => $cmd->log_level,
70 log_file => $cmd->log_file,
71 );
72 0 ▶ confess_or_die 'invalid repository: '
Branch: 2 branches
BranchTrueFalseTotal
unless $backend->check_repository("action", $action, $action eq "create" ? ("force", $cmd->force) : ()) 0 0 0
$action eq 'create' ? : 0 0 0
73 . $cmd->repository
74 unless $backend->check_repository(
75 action => $action,
76 $action eq 'create' ? ( force => $cmd->force ) : ()
77 );
78 }
79 else {
80 1 confess_or_die "need repository arg\n";
81 }
82 }
83 3 return $cmd;
84 }
85  
86 =head2 log
87 =cut
88  
89 1 ▶sub log {
Subroutine log: called CC=1 SCAR=0.0
Pod documented
90 1 my $self = shift;
91  
92 # init logging is done in prepare, no need to init here, just returns logger
93 1 return Log::Log4perl->get_logger( ref $self );
94 }
95  
96 2 1;
97  
98 __END__
« blib/lib/Shipwright/Backend/Git.pm ↑ Summary blib/lib/Shipwright/Script/Defaultbranch.pm »