Chimera/Object.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 52 CC 7 SCAR 23.2
CC
7
Cov
0%
BEGIN
12.0
new
12.0
display
12.0
CRAP 10.2
1 package Crypt::Chimera::Object;
2  
3 use strict;
4 use vars qw($BOLD $RESET);
5  
6 BEGIN {
7 if (1) {
8 *Crypt::Chimera::Object::color = sub { ""; };
9 }
10 else {
11 eval qq{ use Term::ANSIColor; };
12 if ($@) {
13 warn "The output from this program is more readable " .
14 "if you have Term::ANSIColor installed.\n" .
15 "Continuing anyway...";
16 *Crypt::Chimera::Object::color = sub { ""; };
17 }
18 }
19 }
20  
21 $BOLD = color 'cyan';
22 $RESET = color 'reset';
23  
24 sub new {
25 my $class = shift;
26 my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ };
27 $self->{Verbose} = 2 unless $self->{Verbose};
28 return bless $self, $class;
29 }
30  
31 sub display {
32 my ($self, $level, $msg, $data) = @_;
33 return unless $level <= $self->{Verbose};
34 if (length($data) > 50) {
35 my $len = length $data;
36 $data = substr($data, 0, 40);
37 $data =~ s/(...)(...)/$1$BOLD$2$RESET/g;
38 $data .= "... ($len bytes)";
39 }
40 else {
41 $data =~ s/(...)(...)/$1$BOLD$2$RESET/g;
42 }
43 print "$self->{Name}\[$level] ($msg): $data\n";
44 }
45  
46 1;