ProcessTable/Role/Table/OS/os2.pm untested

filter: Statementstmt 0.0% 0 / 51 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 75 CC 4 SCAR 14.8
CC
4
Cov
0%
_convert_hash
12.0
_process_hash
6.0
table
2.0
CRAP 4.4
1 package P9Y::ProcessTable::Role::Table::OS::os2;
2  
3 our $AUTHORITY = 'cpan:BBYRD'; # AUTHORITY
4 our $VERSION = '1.06_01'; # VERSION
5  
6 #############################################################################
7 # Modules
8  
9 # use sanity;
10 use strict qw(subs vars);
11 no strict 'refs';
12 use warnings FATAL => 'all';
13 no warnings qw(uninitialized);
14  
15 use Moo::Role;
16  
17 requires 'process';
18  
19 use OS2::Process;
20  
21 use namespace::clean;
22 no warnings 'uninitialized';
23  
24 #############################################################################
25 # Methods
26  
27 sub table {
28 my $self = shift;
29 return map {
30 my $hash = $self->_convert_hash($_);
31 $hash->{_pt_obj} = $self;
32 P9Y::ProcessTable::Process->new($hash);
33 } (process_hentries);
34 }
35  
36 sub list {
37 my $self = shift;
38 return sort { $a <=> $b } map { $_->{owner_pid} } (process_hentries);
39 }
40  
41 sub fields {
42 return ( qw/
43 pid ppid sess cmdline
44 / );
45 }
46  
47 sub _process_hash {
48 my ($self, $pid) = @_;
49 my $info = process_hentry($pid);
50 return unless $info;
51 return $self->_convert_hash;
52 }
53  
54 sub _convert_hash {
55 my ($self, $info) = @_;
56 return unless $info;
57  
58 my $hash = {};
59 my $stat_loc = { qw/
60 pid owner_pid
61 sess owner_sid
62 cmdline title
63 / };
64  
65 foreach my $key (keys %$stat_loc) {
66 my $item = $info->{ $stat_loc->{$key} };
67 $hash->{$key} = $item if defined $item;
68 }
69  
70 $hash->{ppid} = ppidOf($hash->{pid});
71  
72 return $hash;
73 }
74  
75 42;