File Coverage

blib/lib/Devel/Monitor/Trace.pm
Criterion Covered Total %
statement 42 42 100.0
branch 5 6 83.3
condition n/a
subroutine 9 9 100.0
pod 0 6 0.0
total 56 63 88.8


line stmt bran cond sub pod time code
1             package Devel::Monitor::Trace;
2 1     1   6 use strict;
  1         1  
  1         33  
3 1     1   5 use warnings;
  1         1  
  1         26  
4            
5 1     1   5 use Devel::Monitor::Common qw(:all);
  1         2  
  1         475  
6            
7             sub new {
8 13     13 0 24 my ($class) = @_;
9 13         20 my $self = {};
10 13         32 bless($self => $class);
11 13         51 $self->{_traceItems} = [];
12 13         33 return $self;
13             }
14            
15             sub push {
16 155     155 0 163 my $self = shift;
17 155         144 my $varRef = shift;
18 155         161 my $source = shift;
19 155         439 my $trace = Devel::Monitor::TraceItem->new($varRef,$source);
20 155         174 push(@{$self->{_traceItems}},$trace);
  155         425  
21             }
22            
23             sub pop {
24 155     155 0 173 my $self = shift;
25 155         151 pop @{$self->{_traceItems}};
  155         418  
26             }
27            
28             sub getTraceItems {
29 19     19 0 46 return shift->{_traceItems};
30             }
31            
32             sub getCircularPath {
33 20     20 0 29 my $self = shift;
34 20         28 my $tmp = '';
35 20         23 my $isFirst = 1;
36 20         29 foreach my $trace (@{$self->{_traceItems}}) {
  20         44  
37 74 100       110 if ($isFirst) {
38 20         48 $tmp .= $trace->getVarRef();
39 20         43 $isFirst = 0;
40             } else {
41 54 50       119 $tmp .= $trace->getSource() if $trace->getSource();
42             }
43             }
44 20         90 return $tmp;
45             }
46            
47             sub dump {
48 20     20 0 26 my $self = shift;
49 20         23 my $i = 1;
50 20         21 foreach my $trace (@{$self->{_traceItems}}) {
  20         47  
51 74 100       195 if ($trace->getSource()) {
52 54         143 Devel::Monitor::Common::printMsg($i.' - Source : '.$trace->getSource()."\n".
53             ' Item : '.$trace->getVarRef()."\n");
54             } else {
55 20         78 Devel::Monitor::Common::printMsg($i.' - Item : '.$trace->getVarRef()."\n");
56             }
57 74         218 $i++;
58             }
59             }
60            
61             1;