| 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
| |||||||||||||||||||||||||||||||||||
| 51 | 45 | my $curval = $self->$field(); | |||||||||||||||||||||||||||||||||
| 52 | 45 | ▶ | my $arg = exists($args{$field}) ? $args{$field} : $defaults{$field}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 53 | 45 | ▶ | if (ref($curval) =~ /ARRAY/) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 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
$self->shell_status or $self->command_status
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
| |||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||