blib/lib/Template/Plugin/MultiMarkdown.pm

filter: Statementstmt 92.3% 36 / 39 Branchbran 60.0% 6 / 10 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 86.1% 56 / 65 SCAR 21.1
CC
8
Cov
85%
filter
5.2
BEGIN
3.2
init
2.0
CRAP 8.2
↑ Summary
1 package Template::Plugin::MultiMarkdown;
2  
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 our $VERSION = "0.11";
7  
8 6 ▶use vars qw($text_mmd_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use parent qw (Template::Plugin::Filter);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 BEGIN {
13 6 ▶ $text_mmd_class = 'Text::MultiMarkdown::XS';
Subroutine BEGIN: called CC=3 SCAR=11.6
14 6 eval 'require Text::MultiMarkdown::XS';
15 6 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 6 0 6
16 6 $text_mmd_class = 'Text::MultiMarkdown';
17 6 eval 'require Text::MultiMarkdown';
18 6 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 6 6
19 0 croak "cannot load either Text::MultiMarkdown::XS or Text::MultiMarkdown";
20 }
21 }
22 }
23
24 sub init {
25 5 ▶ my $self = shift;
Subroutine init: called CC=2 SCAR=7.0
Pod documented
26 5 $self->{_DYNAMIC} = 1;
27 5 ▶ $self->install_filter($self->{_ARGS}->[0] || 'multimarkdown');
Condition50%1/2
$self->{'_ARGS'}[0] || 'multimarkdown'
l!l
05
MC/DC0%0/1
$self->{'_ARGS'}[0] || 'multimarkdown'
$self->{'_ARGS'}[0]
Truth table50%1/2
A
A= $self->{'_ARGS'}[0]
Aresult
11
00
28 5 return $self;
29 }
30  
31 sub filter {
32 5 ▶ my ($self, $text, $args, $config) = @_;
Subroutine filter: called CC=5 SCAR=16.6
Pod documented
33  
34 5 ▶ my $options = { %{$self->{_CONFIG}}, %{$config || {}} };
Branch: 1 branch
BranchTrueFalseTotal
$config or {} 0 5 5
35 5 ▶ my $req_class = delete $options->{implementation} || '';
Condition100%2/2
delete $options->{'implementation'} || ''
l!l
41
MC/DC100%1/1
delete $options->{'implementation'} || ''
delete $options->{'implementation'}
Truth table100%2/2
A
A= delete $options->{'implementation'}
Aresult
11
00
36  
37 5 ▶ if ($req_class eq 'PP') {
Branch: 2 branches
BranchTrueFalseTotal
if ($req_class eq 'PP') { } 4 1 5
elsif ($req_class eq 'XS') { } 0 1 1
38 4 require Text::MultiMarkdown;
39 4 return Text::MultiMarkdown->new(%$options)->markdown($text);
40 } elsif ($req_class eq 'XS') {
41 0 require Text::MultiMarkdown::XS;
42 0 return Text::MultiMarkdown::XS->new($options)->markdown($text);
43 } else {
44 1 return $text_mmd_class->new(%$options)->markdown($text);
45 }
46 }
47  
48 6 1;
49  
50 __END__
↑ Summary