Compiler.pm

filter: Statementstmt 87.5% 49 / 56 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.4% 17 / 18 Podpod 0.0% 0 / 1 totaltotal 82.7% 67 / 81 SCAR 14.1
CC
4
Cov
81%
compiler_for
6.0
__ANON__
2.1
_build_metadata
2.1
CRAP 4.1
« Compiler/Source.pm ↑ Summary
1 # ABSTRACT: Perl Markdown Compiler
2 package Markdown::Compiler;
3 18 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use Markdown::Compiler::Source;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use Markdown::Compiler::Lexer;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 18 ▶use Markdown::Compiler::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Markdown::Compiler::Target::HTML;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use YAML::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 13 has source => (
12 is => 'ro',
13 required => 1,
14 );
15  
16 has _source => (
17 is => 'ro',
18 lazy => 1,
19 builder => sub {
20 14 ▶ Markdown::Compiler::Source->new( source => shift->source );
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _build__source: called CC=1 SCAR=0.0
21 }
22 13 );
23  
24 has lexer => (
25 is => 'ro',
26 lazy => 1,
27 builder => sub {
28 59 ▶ Markdown::Compiler::Lexer->new( source => shift->_source->body );
Subroutine _build_lexer: called CC=1 SCAR=0.0
29 },
30 13 );
31  
32 has parser => (
33 is => 'ro',
34 lazy => 1,
35 builder => sub {
36 64 ▶ Markdown::Compiler::Parser->new( stream => shift->stream );
Subroutine _build_parser: called CC=1 SCAR=1.2
Subroutine __ANON__: called CC=1 SCAR=1.2
37 },
38 13 );
39  
40 has stream => (
41 is => 'ro',
42 lazy => 1,
43 builder => sub {
44 61 ▶ shift->lexer->tokens;
Subroutine _build_stream: called CC=1 SCAR=0.0
45 },
46 13 );
47  
48 has tree => (
49 is => 'ro',
50 lazy => 1,
51 builder => sub {
52 64 ▶ shift->parser->tree;
Subroutine _build_tree: called CC=1 SCAR=1.2
53 },
54 13 );
55  
56 has compiler => (
57 is => 'ro',
58 lazy => 1,
59 builder => sub {
60 24 ▶ Markdown::Compiler::Target::HTML->new( tree => shift->tree );
Subroutine __ANON__: called CC=1 SCAR=1.2
61 },
62 13 );
63  
64 sub compiler_for {
65 0 ▶ my ( $self, $target ) = @_;
Subroutine compiler_for: not called CC=2 SCAR=17.9
Pod undocumented
66  
67 0 ▶ $target = substr($target,0,1) eq '+'
Branch: 1 branch
BranchTrueFalseTotal
substr($target, 0, 1) eq '+' ? : 0 0 0
68 ? substr($target,1)
69 : 'Markdown::Compiler::Target::' . $target;
70  
71 0 return use_module("$target")->new( tree => $self->tree );
72 }
73  
74 has result => (
75 is => 'ro',
76 lazy => 1,
77 builder => sub {
78 41 ▶ shift->compiler->result;
Subroutine _build_result: called CC=1 SCAR=0.0
79 }
80 13 );
81  
82 has metadata => (
83 is => 'ro',
84 lazy => 1,
85 builder => sub {
86 2 ▶ my ( $self ) = @_;
Subroutine _build_metadata: called CC=2 SCAR=7.6
87  
88 # Process YAML files with YAML::XS.
89 2 ▶ if ( $self->_source->metatype eq 'YAML' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_source->metatype eq "YAML") 2 0 2
if ($self->_source->metatype eq "YAML") 0 0 0
90 2 return Load( $self->_source->metadata );
91 }
92  
93 0 return $self->_source->metadata;
94 }
95 13 );
96  
97 13 1;
98  
99 __END__
« Compiler/Source.pm ↑ Summary