| 1 | package Net::ADB::Shell::Result; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use v5.16; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | our $VERSION = '0.01'; | |||||||||
| 11 | 2 | our @CARP_NOT = qw(Net::ADB Net::ADB::Device); | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 1 | my ($class, %params) = @_; | |||||||||
| 15 | |||||||||||
| 16 | 1 | my $self = \%params; | |||||||||
| 17 | 1 | return bless $self, $class; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | sub stdout { shift->{stdout} } | ||||||||
|
Subroutine
stdout: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 1 | ▶ | sub stderr { shift->{stderr} } | ||||||||
|
Subroutine
stderr: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 1 | ▶ | sub exit_code { shift->{exit} } | ||||||||
|
Subroutine
exit_code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 0 | ▶ | sub command { shift->{command} } | ||||||||
|
Subroutine
command: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 24 | 0 | ▶ | sub duration { shift->{duration} } | ||||||||
|
Subroutine
duration: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub is_success { (shift->{exit} == 0) ? 1 : 0 } | ||||||||
|
Subroutine
is_success: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 27 | 0 | ▶ | sub is_error { !shift->is_success } | ||||||||
|
Subroutine
is_error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub _split { | ||||||||
|
Subroutine
_split: not called CC=2 SCAR=17.9
| |||||||||||
| 30 | 0 | my ($self, $ch) = @_; | |||||||||
| 31 | 0 | my @lines = split /\n/, $self->{$ch}; | |||||||||
| 32 | 0 | ▶ | return wantarray ? @lines : \@lines; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub lines { shift->_split('stdout') } | ||||||||
|
Subroutine
lines: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 36 | 0 | ▶ | sub stdout_lines { shift->_split('stdout') } | ||||||||
|
Subroutine
stdout_lines: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 37 | 0 | ▶ | sub stderr_lines { shift->_split('stderr') } | ||||||||
|
Subroutine
stderr_lines: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub assert_success { | ||||||||
|
Subroutine
assert_success: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 40 | 0 | my $self = shift; | |||||||||
| 41 | 0 | ▶ | return $self if $self->is_success; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | |||||||||||
| 43 | 0 | chomp(my $err = $self->stderr); | |||||||||
| 44 | 0 | Carp::croak(sprintf "Command '%s' failed (exit %d): %s", $self->{command}, $self->{exit}, $err); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub TO_JSON { | ||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | 0 | my $self = shift; | |||||||||
| 49 | return { | ||||||||||
| 50 | stdout => $self->{stdout}, | ||||||||||
| 51 | stderr => $self->{stderr}, | ||||||||||
| 52 | exit => $self->{exit}, | ||||||||||
| 53 | command => $self->{command}, | ||||||||||
| 54 | duration => $self->{duration}, | ||||||||||
| 55 | 0 | }; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 2 | 1; | |||||||||
| 59 | |||||||||||
| 60 | __END__ | ||||||||||