File Coverage

blib/lib/System/Introspector/Probe/FileHandles.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 24 25 96.0


line stmt bran cond sub pod time code
1             package System::Introspector::Probe::FileHandles;
2 1     1   30890 use Moo;
  1         26402  
  1         6  
3              
4 1         352 use System::Introspector::Util qw(
5             lines_from_command
6             transform_exceptions
7 1     1   3467 );
  1         5  
8              
9             has lsof_command => (is => 'ro', default => sub { 'lsof' });
10              
11             sub gather {
12 2     2 0 12506 my ($self) = @_;
13             return transform_exceptions {
14 2     2   13 my @lines = lines_from_command [$self->_lsof_command_call];
15 1         11 my @handles;
16 1         5 for my $line (@lines) {
17 4         12 chomp $line;
18 4         19 my @fields = split m{\0}, $line;
19 21         93 push @handles, { map {
20 4         9 m{^(.)(.*)$};
21 21         133 ($1, $2);
22             } @fields };
23             }
24 1         19 return { handles => \@handles };
25 2         31 };
26             }
27              
28             sub _lsof_command_call {
29 2     2   4 my ($self) = @_;
30 2         22 return $self->lsof_command, '-F0';
31             }
32              
33             1;
34              
35             __END__