line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Markdent::Role::BalancedEvent; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
47
|
|
30230
|
use strict; |
|
35
|
|
|
|
|
95
|
|
|
35
|
|
|
|
|
1340
|
|
4
|
35
|
|
|
47
|
|
221
|
use warnings; |
|
35
|
|
|
|
|
88
|
|
|
35
|
|
|
|
|
1014
|
|
5
|
35
|
|
|
35
|
|
216
|
use namespace::autoclean; |
|
35
|
|
|
|
|
200
|
|
|
35
|
|
|
|
|
268
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.40'; |
8
|
|
|
|
|
|
|
|
9
|
35
|
|
|
35
|
|
3331
|
use List::AllUtils qw( all ); |
|
35
|
|
|
|
|
111
|
|
|
35
|
|
|
|
|
2497
|
|
10
|
35
|
|
|
35
|
|
289
|
use Markdent::Types; |
|
35
|
|
|
|
|
91
|
|
|
35
|
|
|
|
|
342
|
|
11
|
35
|
|
|
35
|
|
911855
|
use Params::ValidationCompiler qw( validation_for ); |
|
35
|
|
|
|
|
112
|
|
|
35
|
|
|
|
|
2748
|
|
12
|
35
|
|
|
35
|
|
268
|
use Specio::Declare; |
|
35
|
|
|
|
|
87
|
|
|
35
|
|
|
|
|
433
|
|
13
|
|
|
|
|
|
|
|
14
|
35
|
|
|
35
|
|
8238
|
use MooseX::Role::Parameterized; |
|
35
|
|
|
|
|
93
|
|
|
35
|
|
|
|
|
470
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
parameter compare => ( |
17
|
|
|
|
|
|
|
isa => t( 'ArrayRef', of => t('Str') ), |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
role { |
21
|
|
|
|
|
|
|
my $p = shift; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @compare = @{ $p->compare || [] }; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $validator = validation_for( |
26
|
|
|
|
|
|
|
params => [ |
27
|
|
|
|
|
|
|
{ type => t('EventObject') }, |
28
|
|
|
|
|
|
|
], |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
method balances_event => sub { |
32
|
537
|
|
|
537
|
|
925
|
my $self = shift; |
|
|
|
|
537
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
|
537
|
|
|
|
33
|
537
|
|
|
|
|
11539
|
my ($other) = $validator->(@_); |
34
|
|
|
|
|
|
|
|
35
|
537
|
50
|
|
|
|
40912
|
return 0 unless $self->name eq $other->name; |
36
|
|
|
|
|
|
|
|
37
|
537
|
50
|
33
|
|
|
1495
|
return 0 |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
38
|
|
|
|
|
|
|
unless ( $self->is_start && $other->is_end ) |
39
|
|
|
|
|
|
|
|| ( $self->is_end && $other->is_start ); |
40
|
|
|
|
|
|
|
|
41
|
537
|
100
|
|
|
|
1687
|
return 1 unless @compare; |
42
|
|
|
|
|
|
|
|
43
|
473
|
|
|
473
|
|
2985
|
return all { $self->$_() eq $other->$_() } @compare; |
|
473
|
|
|
|
|
14542
|
|
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# ABSTRACT: A parameterized role for events which can check if they balance another event |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding UTF-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Markdent::Role::BalancedEvent - A parameterized role for events which can check if they balance another event |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 0.40 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 DESCRIPTION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This role provides behavior for start and end events which can be checked for a |
68
|
|
|
|
|
|
|
balancing event. This includes things like strong, emphasis, and code start/end |
69
|
|
|
|
|
|
|
events. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 ROLE PARAMETERS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This role accepts the following parameters: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over 4 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * compare => [ ... ] |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This should be a list of attribute names which will be compared between the |
80
|
|
|
|
|
|
|
start and end events. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This role provides the following methods: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 $event->balances_event($event2) |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Given an event, this returns true if two events balance each other. This is |
91
|
|
|
|
|
|
|
done by comparing types (StartCode matches EndCode), as well as the attributes |
92
|
|
|
|
|
|
|
provided in the compare parameter. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 BUGS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
See L<Markdent> for bug reporting details. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SOURCE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Dave Rolsky. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
115
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The full text of the license can be found in the |
118
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |