EnvImporter/Result.pm

filter: Statementstmt 86.0% 37 / 43 Branchbran 50.0% 4 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 8 / 10 Podpod 66.6% 2 / 3 totaltotal 69.8% 51 / 73 CC 8 SCAR 16.0
CC
8
Cov
72%
failed
12.0
init
6.6
succeeded
2.0
CRAP 5.0
« EnvImporter/Shell.pm ↑ Summary EnvImporter.pm »
1 package Shell::EnvImporter::Result;
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 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Shell::EnvImporter::Change;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Class::MethodMaker 2.0 [
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 new => [qw(-hash -init new)],
11 scalar => [qw(
12 shell_status
13 command_status
14 env_status
15  
16 shell_output
17 command_output
18 stderr
19 )],
20 array => [qw(
21 imported
22 )],
23 hash => [qw(
24 start_env
25  
26 changed
27 )],
28 1 ];
29  
30 1 ▶use constant DEFAULTS => (
Subroutine BEGIN: called CC=1 SCAR=0.0
31 shell_status => -255,
32 command_status => -255,
33 env_status => -255,
34 1 );
35  
36  
37 ##########
38 15 ▶sub init {
Subroutine init: called CC=6 SCAR=18.8
Pod undocumented
39 ##########
40 15 my $self = shift;
41 15 my %args = @_;
42 15 my %defaults = (DEFAULTS);
43  
44 # Set supplied fields with defaults
45 15 my @fields = (keys %args, keys %defaults);
46 15 my %fields; @fields{@fields} = (1) x @fields;
47 15 @fields = keys %fields;
48  
49 15 foreach my $field (@fields) {
50 45 ▶ if ($self->can($field)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($field)) 45 0 45
51 45 my $curval = $self->$field();
52 45 ▶ my $arg = exists($args{$field}) ? $args{$field} : $defaults{$field};
Branch: 1 branch
BranchTrueFalseTotal
exists $args{$field} ? : 0 45 45
53 45 ▶ if (ref($curval) =~ /ARRAY/) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref($curval) =~ /ARRAY/) { } 0 45 45
elsif (ref($curval) =~ /HASH/) { } 0 45 45
54 0 $self->$field(@$arg);
55 } elsif (ref($curval) =~ /HASH/) {
56 0 $self->$field(%$arg);
57 } else {
58 45 $self->$field($arg);
59 }
60 }
61 }
62  
63 # Copy the environment when constructed
64 15 $self->_copy_env;
65  
66  
67 }
68  
69  
70 ############
71 0 ▶sub failed {
Subroutine failed: not called CC=3 SCAR=24.8
Pod documented
72 ############
73 0 my $self = shift;
74  
75 0 ▶ return $self->shell_status ||
Condition0%0/6
$self->shell_status || $self->command_status || $self->env_status
l!l&&r!l&&!r
000
$self->shell_status or $self->command_status
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->shell_status || $self->command_status || $self->env_status
$self->shell_status $self->command_status $self->env_status
Truth table0%0/4
A or B || C
A= $self->shell_statusB= $self->command_statusC= $self->env_status
ABCresult
1XX1
01X1
0011
0000
76 $self->command_status ||
77 $self->env_status;
78  
79 }
80  
81  
82 ###############
83 0 ▶sub succeeded {
Subroutine succeeded: not called CC=1 SCAR=6.9
Pod documented
84 ###############
85 0 my $self = shift;
86  
87 0 return $self->shell_status == 0 and
88 $self->command_status == 0 and
89 $self->env_status == 0;
90  
91 }
92  
93  
94  
95  
96  
97 ##############################################################################
98 ########################### Private subroutines #############################
99 ##############################################################################
100  
101  
102 ###############
103 15 ▶sub _copy_env {
Subroutine _copy_env: called CC=1 SCAR=0.0
104 ###############
105 15 my $self = shift;
106  
107 15 my %envbak;
108 15 @envbak{keys %ENV} = values %ENV;
109
110 15 $self->start_env(%envbak);
111  
112 }
113  
114  
115  
116  
117 1 1;
118  
119  
120 __END__
« EnvImporter/Shell.pm ↑ Summary EnvImporter.pm »