File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/MacOS/Printers.pm
Criterion Covered Total %
statement 12 22 54.5
branch 0 2 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 16 35 45.7


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::MacOS::Printers;
2              
3 1     1   70656980 use strict;
  1         1  
  1         47  
4 1     1   7 use warnings;
  1         4  
  1         48  
5              
6 1     1   370 use FusionInventory::Agent::Tools;
  1         2  
  1         130  
7 1     1   356 use FusionInventory::Agent::Tools::MacOS;
  1         2  
  1         154  
8              
9             sub isEnabled {
10 0     0 0   my (%params) = @_;
11              
12             return
13             !$params{no_category}->{printer} &&
14 0   0       canRun('/usr/sbin/system_profiler');
15             }
16              
17             sub doInventory {
18 0     0 0   my (%params) = @_;
19              
20 0           my $inventory = $params{inventory};
21 0           my $logger = $params{logger};
22              
23 0           my $infos = getSystemProfilerInfos(type => 'SPPrintersDataType', logger => $logger);
24 0           my $info = $infos->{Printers};
25              
26 0           foreach my $printer (keys %$info) {
27 0 0         next unless ref($info->{printer}) eq 'HASH';
28              
29             $inventory->addEntry(
30             section => 'PRINTERS',
31             entry => {
32             NAME => $printer,
33             DRIVER => $info->{$printer}->{PPD},
34             PORT => $info->{$printer}->{URI},
35             }
36 0           );
37             }
38              
39             }
40              
41             1;