lib/Rex/PkgConf.pm

filter: Statementstmt 47.9% 23 / 48 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 37.9% 30 / 79 CC 9 SCAR 38.7
CC
9
Cov
35%
get
90.0
register_package_provider
2.0
BEGIN
1.0
CRAP 48.2
« lib/Rex/Inventory/SMBios.pm ↑ Summary lib/Rex/Commands/Iptables.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::PkgConf;
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::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Rex::Commands::Gather;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Rex::Hardware;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Rex::Hardware::Host;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 my %PKG_PROVIDER;
19  
20 0 ▶sub register_package_provider {
Subroutine register_package_provider: not called CC=1 SCAR=6.9
Pod undocumented
21 0 my ( $class, $service_name, $service_class ) = @_;
22 0 $PKG_PROVIDER{"\L$service_name"} = $service_class;
23 0 return 1;
24 }
25  
26 0 ▶sub get {
Subroutine get: not called CC=9 SCAR=45.0
Pod undocumented
27  
28 0 my ($self) = @_;
29  
30 0 my %_host = %{ Rex::Hardware::Host->get() };
31 0 my $host = {%_host};
32  
33 0 ▶ my $pkg_provider_for = Rex::Config->get("package_provider") || {};
Condition0%0/2
'Rex::Config'->get('package_provider') || {}
l!l
00
MC/DC0%0/1
'Rex::Config'->get('package_provider') || {}
'Rex::Config'->get('package_provider')
Truth table0%0/2
A
A= 'Rex::Config'->get('package_provider')
Aresult
11
00
34  
35 0 ▶ if ( is_redhat() ) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_redhat()) { } 0 0 0
elsif (is_debian()) { } 0 0 0
36 0 $host->{"operatingsystem"} = "Redhat";
37 }
38 elsif ( is_debian() ) {
39 0 $host->{"operatingsystem"} = "Debian";
40 }
41  
42 0 my $class = "Rex::PkgConf::" . $host->{"operatingsystem"};
43  
44 0 my $provider;
45 0 ▶ if ( ref($pkg_provider_for)
Branch: 2 branches
BranchTrueFalseTotal
if (ref $pkg_provider_for and exists $$pkg_provider_for{$host->{'operatingsystem'}}) { } 0 0 0
elsif (exists $PKG_PROVIDER{$pkg_provider_for}) { } 0 0 0
Condition0%0/3
ref $pkg_provider_for and exists $$pkg_provider_for{$host->{"operatingsystem"}}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $pkg_provider_for and exists $$pkg_provider_for{$host->{"operatingsystem"}}
ref $pkg_provider_for exists $$pkg_provider_for{$host->{"operatingsystem"}}
Truth table0%0/3
A and B
A= ref $pkg_provider_forB= exists $$pkg_provider_for{$host->{"operatingsystem"}}
ABresult
0X0
100
111
46 && exists $pkg_provider_for->{ $host->{"operatingsystem"} } )
47 {
48 0 $provider = $pkg_provider_for->{ $host->{"operatingsystem"} };
49 0 $class .= "::$provider";
50 }
51 elsif ( exists $PKG_PROVIDER{$pkg_provider_for} ) {
52 0 $class = $PKG_PROVIDER{$pkg_provider_for};
53 }
54  
55 0 Rex::Logger::debug("Using $class for package management");
56 0 eval "use $class";
57  
58 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
59  
60 0 ▶ if ($provider) {
Branch: 1 branch
BranchTrueFalseTotal
if ($provider) { } 0 0 0
61 0 Rex::Logger::info( "Provider not supported (" . $provider . ")" );
62 }
63 else {
64 Rex::Logger::info(
65 0 "OS not supported (" . $host->{"operatingsystem"} . ")" );
66 }
67 0 die("OS/Provider not supported");
68  
69 }
70  
71 0 return $class->new;
72  
73 }
74  
75 1 1;
« lib/Rex/Inventory/SMBios.pm ↑ Summary lib/Rex/Commands/Iptables.pm »