File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/Solaris/Softwares.pm
Criterion Covered Total %
statement 9 26 34.6
branch 0 12 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 0 2 0.0
total 12 48 25.0


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::Solaris::Softwares;
2              
3 1     1   99328552 use strict;
  1         4  
  1         43  
4 1     1   5 use warnings;
  1         4  
  1         60  
5              
6 1     1   390 use FusionInventory::Agent::Tools;
  1         4  
  1         481  
7              
8             sub isEnabled {
9 0     0 0   my (%params) = @_;
10              
11             return
12             !$params{no_category}->{software} &&
13 0   0       canRun('pkginfo');
14             }
15              
16             sub doInventory {
17 0     0 0   my (%params) = @_;
18              
19 0           my $inventory = $params{inventory};
20 0           my $logger = $params{logger};
21              
22 0           my $handle = getFileHandle(
23             command => 'pkginfo -l',
24             logger => $logger,
25             );
26              
27 0 0         return unless $handle;
28              
29 0           my $software;
30 0           while (my $line = <$handle>) {
31 0 0         if ($line =~ /^\s*$/) {
    0          
    0          
    0          
    0          
32 0           $inventory->addEntry(
33             section => 'SOFTWARES',
34             entry => $software
35             );
36 0           undef $software;
37             } elsif ($line =~ /PKGINST:\s+(.+)/) {
38 0           $software->{NAME} = $1;
39             } elsif ($line =~ /VERSION:\s+(.+)/) {
40 0           $software->{VERSION} = $1;
41             } elsif ($line =~ /VENDOR:\s+(.+)/) {
42 0           $software->{PUBLISHER} = $1;
43             } elsif ($line =~ /DESC:\s+(.+)/) {
44 0           $software->{COMMENTS} = $1;
45             }
46             }
47              
48 0           close $handle;
49             }
50              
51             1;