ProcessTable/Role/Table/OS/VMS.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::VMS;
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 VMS::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_list);
34 }
35  
36 sub list {
37 my $self = shift;
38 return sort { $a <=> $b } map { $_->{PID} } (process_list);
39 }
40  
41 sub fields {
42 return ( qw/
43 pid uid gid ppid pgrp
44 exe
45 ttlflt start time
46 priority fname state ttydev flags size rss cpuid
47 / );
48 }
49  
50 sub _process_hash {
51 my ($self, $pid) = @_;
52 my $info = process_list({
53 NAME => 'MASTER_PID',
54 VALUE => $pid,
55 });
56 return unless $info;
57 return $self->_convert_hash;
58 }
59  
60 sub _convert_hash {
61 my ($self, $info) = @_;
62 return unless $info;
63  
64 my $hash = {};
65 my $stat_loc = { qw/
66 pid PID
67 uid OWNER
68 gid GRP
69 ppid MASTER_PID
70 pgrp MASTER_PID
71 cpuid CPUID
72 priority PRI
73 flags PHDFLAGS
74 ttlflt PAGEFLTS
75 time CPUTIM
76 size VIRTPEAK
77 rss WSSIZE
78 ttydev TT_PHYDEVNAM
79 fname PRCNAM
80 start LOGINTIM
81 state STATE
82  
83 exe IMAGNAME
84 / };
85  
86 foreach my $key (keys %$stat_loc) {
87 my $item = $info->{ $stat_loc->{$key} };
88 $hash->{$key} = $item if defined $item;
89 }
90  
91 return $hash;
92 }
93  
94 42;