blib/lib/RackMan/Types.pm

filter: Statementstmt 81.8% 27 / 33 Branchbran 16.6% 1 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 100% 4 / 4 totaltotal 62.9% 39 / 62 CC 6 SCAR 19.9
CC
6
Cov
62%
to_racktables
20.0
from_racktables
6.0
implemented
2.0
CRAP 7.3
« blib/lib/RackMan/Device/Server.pm ↑ Summary blib/lib/RackMan/SCM.pm »
1 package RackMan::Types;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use RackMan;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 1 my %racktables2rackman = (
12 "BlackBox" => "BlackBox",
13 "CableOrganizer" => "CableOrganizer",
14 "console" => "Console",
15 "DiskArray" => "DiskArray",
16 "FC switch" => "FCSwitch",
17 "KVM switch" => "KVMSwitch",
18 "MediaConverter" => "MediaConverter",
19 "Modem" => "Modem",
20 "multiplexer" => "Multiplexer",
21 "Network chassis" => "NetworkChassis",
22 "Network security" => "NetworkSecurity",
23 "Network switch" => "Switch",
24 "PatchPanel" => "PatchPanel",
25 "PDU" => "PDU",
26 "Power supply" => "PowerSupply",
27 "Power supply chassis" => "PowerSupplyChassis",
28 "Router" => "Router",
29 "Server" => "Server",
30 "Server chassis" => "ServerChassis",
31 "Server Ext" => "ServerExt",
32 "Shelf" => "Shelf",
33 "spacer" => "Spacer",
34 "TapeLibrary" => "TapeLibrary",
35 "UPS" => "UPS",
36 "VM" => "VM",
37 "VM Cluster" => "VMCluster",
38 "VM Resource Pool" => "VMResourcePool",
39 "VM Virtual Switch" => "VMVirtualSwitch",
40 "Voice/video" => "VoiceVideo",
41 "Wireless" => "Wireless",
42 );
43  
44 1 my %rackman2racktables = reverse %racktables2rackman;
45 my %lowercase2racktables
46 1 = map { lc $racktables2rackman{$_} => $_ } keys %racktables2rackman;
47  
48  
49 #
50 # enum()
51 # ----
52 1 ▶sub enum {
Subroutine enum: called CC=1 SCAR=0.0
Pod documented
53 1 return keys %rackman2racktables
54 }
55  
56 #
57 # from_racktables()
58 # ---------------
59 0 ▶sub from_racktables {
Subroutine from_racktables: not called CC=2 SCAR=17.9
Pod documented
60 0 my ($self, $type) = @_;
61 0 ▶ RackMan->error("unknown type '$type'") unless $racktables2rackman{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless $racktables2rackman{$type} 0 0 0
62 0 return $racktables2rackman{$type}
63 }
64  
65  
66 #
67 # to_racktables()
68 # -------------
69 0 ▶sub to_racktables {
Subroutine to_racktables: not called CC=4 SCAR=30.0
Pod documented
70 0 my ($self, $type) = @_;
71 RackMan->error("unknown type '$type'")
72 0 ▶ if not $rackman2racktables{$type} and not $lowercase2racktables{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless $rackman2racktables{$type} or $lowercase2racktables{$type} 0 0 0
Condition0%0/3
$rackman2racktables{$type} or $lowercase2racktables{$type}
l!l&&r!l&&!r
000
MC/DC0%0/2
$rackman2racktables{$type} or $lowercase2racktables{$type}
$rackman2racktables{$type} $lowercase2racktables{$type}
Truth table0%0/3
A or B
A= $rackman2racktables{$type}B= $lowercase2racktables{$type}
ABresult
1X1
011
000
73 0 ▶ return $rackman2racktables{$type} || $lowercase2racktables{$type}
Condition0%0/3
$rackman2racktables{$type} || $lowercase2racktables{$type}
l!l&&r!l&&!r
000
MC/DC0%0/2
$rackman2racktables{$type} || $lowercase2racktables{$type}
$rackman2racktables{$type} $lowercase2racktables{$type}
Truth table0%0/3
A || B
A= $rackman2racktables{$type}B= $lowercase2racktables{$type}
ABresult
1X1
011
000
74 }
75  
76  
77 #
78 # implemented()
79 # -----------
80 1 ▶sub implemented {
Subroutine implemented: called CC=2 SCAR=7.0
Pod documented
81 1 my $dir = file(__FILE__)->dir->subdir("Device");
82 1 ▶ my $dh = $dir->open or RackMan->error("can't read directory '$dir': $!");
Branch: 1 branch
BranchTrueFalseTotal
my $dh = $dir->open or "RackMan"->error("can't read directory '${dir}': $!") 1 0 1
83 1 my @modules = map { s/\.pm$//; $_ } grep /\.pm$/, $dh->read;
84 return @modules
85 1 }
86  
87  
88 1 __PACKAGE__
89  
90 __END__
« blib/lib/RackMan/Device/Server.pm ↑ Summary blib/lib/RackMan/SCM.pm »