Markdent/Role/AnyParser.pm

filter: Statementstmt 86.8% 33 / 38 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 83.0% 44 / 53 CC 5 SCAR 13.8
CC
5
Cov
80%
_debug_look_for
10.2
_make_event
2.0
BEGIN
1.0
CRAP 4.0
« Markdent/Parser/SpanParser.pm ↑ Summary Markdent/Role/HTMLStream.pm »
1 package Markdent::Role::AnyParser;
2  
3 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 35 our $VERSION = '0.39';
8  
9 35 ▶use Markdent::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 35 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 35 with 'Markdent::Role::DebugPrinter';
14  
15 35 has handler => (
16 is => 'ro',
17 does => t('HandlerObject'),
18 required => 1,
19 );
20  
21 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
22 sub _send_event {
23 3326 ▶ my $self = shift;
Subroutine _send_event: called CC=1 SCAR=0.0
24  
25 3326 $self->handler->handle_event( $self->_make_event(@_) );
26 }
27 ## use critic
28  
29 sub _make_event {
30 5245 ▶ my $self = shift;
Subroutine _make_event: called CC=2 SCAR=7.0
31 5245 my $class = shift;
32  
33 5245 ▶ my $real_class = $class =~ /::/ ? $class : 'Markdent::Event::' . $class;
Branch: 1 branch
BranchTrueFalseTotal
$class =~ /::/ ? : 0 5245 5245
34  
35 5245 return $real_class->new(@_);
36 }
37  
38 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
39 sub _detab_text {
40 1624 ▶ my $self = shift;
Subroutine _detab_text: called CC=1 SCAR=0.0
41 1624 my $text = shift;
42  
43 # Ripped off from Text::Mardkown
44 1624 ${$text} =~ s{ ^
45 (.*?)
46 \t
47 }
48 3 { $1 . (q{ } x (4 - length($1) % 4))}xmge;
49  
50 1624 return;
51 }
52  
53 sub _debug_look_for {
54 3312 ▶ my $self = shift;
Subroutine _debug_look_for: called CC=4 SCAR=23.2
55  
56 3312 ▶ return unless $self->debug;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->debug 3312 0 3312
57  
58 0 ▶ my @look_debug = map { ref $_ ? "$_->[0] ($_->[1])" : $_ } @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
59  
60 0 my $msg = "Looking for the following possible matches:\n";
61 0 $msg .= " - $_\n" for @look_debug;
62  
63 0 $self->_print_debug($msg);
64 }
65 ## use critic
66  
67 35 1;
68  
69 # ABSTRACT: A role for block and span parsers
70  
71 __END__
72  
73 =pod
74  
75 =encoding UTF-8
76  
77 =head1 NAME
78  
79 Markdent::Role::AnyParser - A role for block and span parsers
80  
81 =head1 VERSION
82  
83 version 0.39
84  
85 =head1 DESCRIPTION
86  
87 This role implements behavior shared by all types of parser.
88  
89 =head1 ATTRIBUTES
90  
91 This role provides the following attributes:
92  
93 =head2 handler
94  
95 This is a read-only attribute. It is an object which does the
96 L<Markdent::Role::Handler> role.
97  
98 This is required for all parsers.
99  
100 =head1 METHODS
101  
102 =head2 $parser->_detab_text(\$text)
103  
104 This takes a scalar reference to a piece of text that will be outputted and
105 replaces tabs with spaces. This is down I<after> a piece of text is parser for
106 markup.
107  
108 =head1 ROLES
109  
110 This class does the L<Markdent::Role::DebugPrinter> role.
111  
112 =head1 BUGS
113  
114 See L<Markdent> for bug reporting details.
115  
116 Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>.
117  
118 I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
119  
120 =head1 SOURCE
121  
122 The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>.
123  
124 =head1 AUTHOR
125  
126 Dave Rolsky <autarch@urth.org>
127  
128 =head1 COPYRIGHT AND LICENSE
129  
130 This software is copyright (c) 2021 by Dave Rolsky.
131  
132 This is free software; you can redistribute it and/or modify it under
133 the same terms as the Perl 5 programming language system itself.
134  
135 The full text of the license can be found in the
136 F<LICENSE> file included with this distribution.
137  
138 =cut
« Markdent/Parser/SpanParser.pm ↑ Summary Markdent/Role/HTMLStream.pm »