lib/Rex/Pkg/NetBSD.pm

filter: Statementstmt 50.0% 19 / 38 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 0.0% 0 / 3 totaltotal 45.4% 25 / 55 CC 3 SCAR 10.7
CC
3
Cov
46%
new
6.0
get_installed
6.0
remove
2.0
CRAP 2.9
« lib/Rex/Virtualization/LibVirt/status.pm ↑ Summary lib/Rex/Pkg/OpenBSD.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Pkg::NetBSD;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.16.1'; # VERSION
11  
12 1 ▶use Rex::Helper::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Rex::Commands::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Rex::Pkg::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use base qw(Rex::Pkg::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
18 0 my $that = shift;
19 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
20 0 my $self = $proto->SUPER::new(@_);
21  
22 0 bless( $self, $proto );
23  
24 $self->{commands} = {
25 0 install => '. /etc/profile; /usr/sbin/pkg_add %s',
26 install_version => '. /etc/profile; /usr/sbin/pkg_add %s-%s',
27 remove => '/usr/sbin/pkg_delete %s',
28 };
29  
30 0 return $self;
31 }
32  
33 0 ▶sub remove {
Subroutine remove: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my ( $self, $pkg ) = @_;
35  
36 0 my ($pkg_found) = grep { $_->{"name"} eq "$pkg" } $self->get_installed();
37 0 my $pkg_version = $pkg_found->{"version"};
38  
39 0 return $self->SUPER::remove("$pkg-$pkg_version");
40 }
41  
42 0 ▶sub get_installed {
Subroutine get_installed: not called CC=2 SCAR=17.9
Pod undocumented
43 0 my ($self) = @_;
44  
45 0 my @lines = i_run "/usr/sbin/pkg_info";
46  
47 0 my @pkg;
48  
49 0 for my $line (@lines) {
50 0 my ( $pkg_name_v, $descr ) = split( /\s/, $line, 2 );
51  
52 0 my ( $pkg_name, $pkg_version ) = ( $pkg_name_v =~ m/^(.*)-(.*?)$/ );
53  
54 0 push(
55 @pkg,
56 {
57 name => $pkg_name,
58 version => $pkg_version,
59 }
60 );
61 }
62  
63 0 return @pkg;
64 }
65  
66 1 1;
« lib/Rex/Virtualization/LibVirt/status.pm ↑ Summary lib/Rex/Pkg/OpenBSD.pm »