Line.pm

filter: Statementstmt 68.5% 24 / 35 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 75.0% 3 / 4 totaltotal 63.6% 35 / 55 CC 3 SCAR 6.2
CC
3
Cov
65%
new
3.1
clone
2.0
stringify
2.0
CRAP 1.9
« Reader.pm ↑ Summary
1 package Text::Annotated::Line;
2 # $Id: Line.pm,v 1.6 2007-05-12 18:39:16 wim Exp $
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use fields qw(filename linenr content);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 "\"\"" => \&stringify
8 2 );
9 2 $VERSION = '0.04';
10  
11 2 ▶sub new {
Subroutine new: called CC=3 SCAR=11.4
Pod documented
12 2 my $proto = shift;
13 2 ▶ my $pkg = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
14
15 # build the object
16 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 my $this = bless [\%{"${pkg}::FIELDS"}], $pkg;
18  
19 # initialize any specified fields
20 2 my %arg = @_;
21 2 ▶ while(my($k,$v) = each %arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %arg) 2 0 2
22 2 $this->{$k} = $v;
23 }
24  
25 0 return $this;
26 }
27  
28 0 ▶sub clone { # returns a deep copy
Subroutine clone: not called CC=1 SCAR=6.9
Pod undocumented
29 0 my $this = shift;
30 return $this->new(
31 filename => $this->{filename},
32 linenr => $this->{linenr},
33 content => $this->{content},
34 0 );
35 }
36  
37 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
Pod documented
38 0 my Text::Annotated::Line $this = shift;
39 0 $this->{content};
40 }
41  
42 0 ▶sub stringify_annotated {
Subroutine stringify_annotated: not called CC=1 SCAR=6.9
Pod documented
43 0 my Text::Annotated::Line $this = shift;
44 0 my $file = $this->{filename};
45 0 my $linenr = sprintf('%05d',$this->{linenr});
46 0 my $content = $this->{content};
47 0 chomp $content;
48 0 return "[$file\#$linenr]$content";
49 }
50  
51 2 1;
52  
53 __END__
« Reader.pm ↑ Summary