Snippet/TabStop.pm

filter: Statementstmt 100% 29 / 29 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 94.1% 48 / 51 CC 7 SCAR 8.3
CC
7
Cov
92%
_new
4.1
to_string
3.0
parse
2.1
CRAP 2.3
« Snippet.pm ↑ Summary Snippet/TabStop/Parser.pm »
1 package Text::Snippet::TabStop;
2 15 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 15 $Text::Snippet::TabStop::VERSION = '0.04';
4 }
5  
6 # ABSTRACT: Abstract class for other tab stop classes
7  
8 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use overload '""' => sub { shift->to_string };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
12  
13  
14 1 ▶sub parse {
Subroutine parse: called CC=2 SCAR=7.6
Pod documented
15 1 ▶ croak "must be implemented in sub class" if(shift eq __PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
if shift() eq __PACKAGE__ 1 0 1
16 }
17  
18 70 ▶sub _new {
Subroutine _new: called CC=4 SCAR=14.2
19 70 my $class = shift;
20 70 ▶ croak "this is an abstract class - please instantiate a sub-class of " . __PACKAGE__ if($class eq __PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
if $class eq __PACKAGE__ 0 70 70
21  
22 70 my %args = @_;
23 70 for my $k(qw(src index)){
24 140 ▶ croak "$k is required" unless defined $args{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{$k} 0 140 140
25 }
26 70 return bless \%args, $class;
27 }
28  
29  
30 use Class::XSAccessor
31 15 ▶ getters => { src => 'src', index => 'index', replacement => 'replacement' },
Subroutine BEGIN: called CC=1 SCAR=0.0
32 setters => { replace => 'replacement' },
33 accessors => { parent => 'parent' },
34 15 predicates => { has_parent => 'parent', has_replacement => 'replacement' };
35  
36  
37 133 ▶sub to_string {
Subroutine to_string: called CC=3 SCAR=11.0
Pod documented
38 133 my $self = shift;
39 133 ▶ return $self->parent->to_string if($self->has_parent);
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_parent 30 103 133
40 103 my $replacement = $self->replacement;
41 103 ▶ return defined($replacement) ? $replacement : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $replacement ? : 57 46 103
42 }
43  
44 15 1;
45  
46 __END__
« Snippet.pm ↑ Summary Snippet/TabStop/Parser.pm »