lib/Rex/Service/NetBSD.pm

filter: Statementstmt 50.0% 16 / 32 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 38.1% 21 / 55 CC 5 SCAR 21.8
CC
5
Cov
38%
ensure
20.0
new
6.0
BEGIN
1.0
CRAP 8.8
« lib/Rex/Interface/Exec/Local.pm ↑ Summary lib/Rex/Test/Base/has_package.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Service::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::Commands::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use base qw(Rex::Service::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 start => '/etc/rc.d/%s onestart',
26 restart => '/etc/rc.d/%s onerestart',
27 stop => '/etc/rc.d/%s onestop',
28 reload => '/etc/rc.d/%s onereload',
29 status => '/etc/rc.d/%s onestatus',
30 action => '/etc/rc.d/%s %s',
31 };
32  
33 0 return $self;
34 }
35  
36 0 ▶sub ensure {
Subroutine ensure: not called CC=4 SCAR=30.0
Pod undocumented
37 0 my ( $self, $service, $options ) = @_;
38  
39 0 my $what = $options->{ensure};
40  
41 0 ▶ if ( $what =~ /^stop/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($what =~ /^stop/u) { } 0 0 0
elsif ($what =~ /^start/u or $what =~ /^run/u) { } 0 0 0
42 0 $self->stop( $service, $options );
43 0 file "/etc/rc.conf.d/${service}", ensure => "absent";
44 0 delete_lines_matching "/etc/rc.conf",
45 matching => qr/^\s*${service}="?((?i)YES)"?/;
46 }
47 ▶ elsif ( $what =~ /^start/ || $what =~ m/^run/ ) {
Condition0%0/3
$what =~ /^start/u or $what =~ /^run/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$what =~ /^start/u or $what =~ /^run/u
$what =~ /^start/u $what =~ /^run/u
Truth table0%0/3
A or B
A= $what =~ /^start/uB= $what =~ /^run/u
ABresult
1X1
011
000
48 0 $self->start( $service, $options );
49 0 file "/etc/rc.conf.d/${service}", ensure => "absent";
50 0 append_or_amend_line "/etc/rc.conf",
51 line => "${service}=YES",
52 regexp => qr/^\s*${service}="?((?i)YES|NO)"?/;
53 }
54  
55 0 return 1;
56 }
57  
58 1 1;
« lib/Rex/Interface/Exec/Local.pm ↑ Summary lib/Rex/Test/Base/has_package.pm »