Simple.pm

filter: Statementstmt 100% 38 / 38 Branchbran 62.5% 5 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 84.3% 54 / 64 CC 7 SCAR 9.6
CC
7
Cov
90%
add_template
4.4
match
4.0
BEGIN
1.0
CRAP 2.6
« Simple/Gesture.pm ↑ Summary Simple/Template.pm »
1 package Gesture::Simple;
2 1 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Gesture::Simple::Gesture;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Gesture::Simple::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.01';
9  
10 1 ▶use constant gesture_class => 'Gesture::Simple::Gesture';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 has templates => (
13 is => 'ro',
14 isa => 'ArrayRef',
15 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
16 1 auto_deref => 1,
17 );
18  
19 4 ▶sub has_templates { @{ shift->templates } > 0 }
Subroutine has_templates: called CC=1 SCAR=0.0
Pod undocumented
20  
21 2 ▶sub add_template {
Subroutine add_template: called CC=4 SCAR=14.9
Pod undocumented
22 2 my $self = shift;
23  
24 2 for (@_) {
25 2 ▶ blessed($_) && $_->isa('Gesture::Simple::Template')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_) and $_->isa("Gesture::Simple::Template") or confess("$_ is not a Gesture::Simple::Template.") 2 0 2
Condition33%1/3
builtin::blessed($_) and $_->isa("Gesture::Simple::Template")
!ll&&!rl&&r
002
MC/DC0%0/2
builtin::blessed($_) and $_->isa("Gesture::Simple::Template")
builtin::blessed($_) $_->isa("Gesture::Simple::Template")
Truth table33%1/3
A and B
A= builtin::blessed($_)B= $_->isa("Gesture::Simple::Template")
ABresult
0X0
100
111
26 or confess "$_ is not a Gesture::Simple::Template.";
27 }
28  
29 2 push @{ $self->templates }, @_;
30 }
31  
32 4 ▶sub match {
Subroutine match: called CC=4 SCAR=14.0
Pod undocumented
33 4 my $self = shift;
34 4 my $gesture = shift;
35  
36 4 ▶ confess "You have no templates to match against!"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_templates 0 4 4
37 unless $self->has_templates;
38  
39 4 ▶ $gesture = $self->gesture_class->new(points => $gesture)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($gesture) 0 4 4
40 if !blessed($gesture);
41  
42 3 my @matches = sort { $b->score <=> $a->score }
43 4 map { $_->match($gesture) }
44 $self->templates;
45  
46 4 ▶ return @matches if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 3 1 4
47 1 return $matches[0];
48 }
49  
50 1 __PACKAGE__->meta->make_immutable;
51 1 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 1 1;
54  
55 __END__
« Simple/Gesture.pm ↑ Summary Simple/Template.pm »