Markdent/Role/Simple.pm

filter: Statementstmt 100% 40 / 40 Branchbran 50.0% 3 / 6 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 94.7% 54 / 57 CC 5 SCAR 7.8
CC
5
Cov
94%
_parse_markdown
4.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.2
« Markdent/Dialect/GitHub/BlockParser.pm ↑ Summary Markdent.pm »
1 package Markdent::Role::Simple;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '0.41';
8  
9 3 ▶use Encode qw( decode );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Markdent::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 requires 'markdown_to_html';
15  
16 3 ▶around markdown_to_html => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
17 3 my $orig = shift;
18 3 my $self = shift;
19 3 my %p = @_;
20  
21 # XXX - should warn eventually.
22 $p{dialects} = delete $p{dialect}
23 3 ▶ if exists $p{dialect};
Branch: 1 branch
BranchTrueFalseTotal
if exists $p{"dialect"} 0 3 3
24  
25 3 return $self->$orig(%p);
26 3 };
27  
28 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
29 3 ▶sub _parse_markdown {
Subroutine _parse_markdown: called CC=4 SCAR=13.9
30 3 my $self = shift;
31 3 my $markdown = shift;
32 3 my $dialects = shift;
33 3 my $handler_class = shift;
34 3 my $handler_p = shift;
35  
36 3 my $capture = q{};
37  
38 ## no critic (InputOutput::RequireBriefOpen)
39 3 ▶ open my $fh, '>:encoding(UTF-8)', \$capture
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">:encoding(UTF-8)", \$capture or die $! 3 0 3
40 or die $!;
41  
42 my $handler = $handler_class->new(
43 3 ▶ %{ $handler_p || {} },
Condition100%2/2
$handler_p || {}
l!l
12
MC/DC100%1/1
$handler_p || {}
$handler_p
Truth table100%2/2
A
A= $handler_p
Aresult
11
00
44 output => $fh,
45 );
46  
47 3 my $parser
48 = Markdent::Parser->new( dialects => $dialects, handler => $handler );
49  
50 3 $parser->parse( markdown => $markdown );
51  
52 3 ▶ close $fh
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die $! 3 0 3
53 or die $!;
54  
55 3 return decode( 'UTF-8', $capture );
56 }
57  
58 3 1;
59  
60 # ABSTRACT: A role for simple markdown to html converter classes
61  
62 __END__
« Markdent/Dialect/GitHub/BlockParser.pm ↑ Summary Markdent.pm »