| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Tidy::Sweetened::Pluggable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Simple object to facilitate a pluggable filter architecture |
|
4
|
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
110
|
use strict; |
|
|
13
|
|
|
|
|
42
|
|
|
|
13
|
|
|
|
|
409
|
|
|
6
|
13
|
|
|
13
|
|
88
|
use warnings; |
|
|
13
|
|
|
|
|
44
|
|
|
|
13
|
|
|
|
|
4134
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
13
|
|
|
13
|
0
|
46
|
my ( $class, %args ) = @_; |
|
12
|
13
|
|
|
|
|
79
|
return bless {%args}, $class; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
331
|
|
100
|
331
|
0
|
1474
|
sub filters { return ( $_[0]->{filters} ||= [] ) } |
|
16
|
|
|
|
|
|
|
|
|
17
|
2068
|
|
50
|
2068
|
0
|
7627
|
sub args { return ( $_[0]->{args} ||= {} ) } |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub add_filter { |
|
20
|
143
|
|
|
143
|
0
|
228
|
my $self = shift; |
|
21
|
143
|
|
|
|
|
201
|
push @{ $self->filters }, @_; |
|
|
143
|
|
|
|
|
276
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub prefilter { |
|
25
|
94
|
|
|
94
|
0
|
298
|
my ( $self, $code ) = @_; |
|
26
|
94
|
|
|
|
|
180
|
for my $filter ( @{ $self->filters } ) { |
|
|
94
|
|
|
|
|
264
|
|
|
27
|
1034
|
|
|
|
|
2483
|
$code = $filter->prefilter($code, $self->args); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# warn "After prefilter, before tidy\n"; |
|
31
|
|
|
|
|
|
|
# warn $code; |
|
32
|
|
|
|
|
|
|
|
|
33
|
94
|
|
|
|
|
310
|
return $code; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub postfilter { |
|
37
|
94
|
|
|
94
|
0
|
290
|
my ( $self, $code ) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# warn "After tidy, before postfilter\n"; |
|
40
|
|
|
|
|
|
|
# warn $code; |
|
41
|
|
|
|
|
|
|
|
|
42
|
94
|
|
|
|
|
160
|
for my $filter ( @{ $self->filters } ) { |
|
|
94
|
|
|
|
|
264
|
|
|
43
|
1034
|
|
|
|
|
2511
|
$code = $filter->postfilter($code, $self->args); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
94
|
|
|
|
|
310
|
return $code; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub add_args { |
|
49
|
94
|
|
|
94
|
0
|
255
|
my ( $self, $args ) = @_; |
|
50
|
94
|
|
|
|
|
347
|
my ( $body_parts, $msg ) = Perl::Tidy::parse_args($args); |
|
51
|
|
|
|
|
|
|
$self->{args} = |
|
52
|
94
|
|
|
|
|
13153
|
{ map { my ( $k, $v ) = split /=/, $_, 2; ( $k => $v ) } @$body_parts }; |
|
|
385
|
|
|
|
|
993
|
|
|
|
385
|
|
|
|
|
1411
|
|
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Perl::Tidy::Sweetened::Pluggable - Simple object to facilitate a pluggable filter architecture |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 VERSION |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
version 1.19 |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
our $plugins = Perl::Tidy::Sweetened::Pluggable->new(); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$plugins->add_filter( |
|
74
|
|
|
|
|
|
|
Perl::Tidy::Sweetened::Keyword::SubSignature->new( |
|
75
|
|
|
|
|
|
|
keyword => 'method', |
|
76
|
|
|
|
|
|
|
marker => 'METHOD', |
|
77
|
|
|
|
|
|
|
) ); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$plugins->prefilter( $code ); |
|
80
|
|
|
|
|
|
|
$plugins->postfilter( $code ); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Builds a pluggable, chainable list of filters. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Mark Grimes <mgrimes@cpan.org> |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SOURCE |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Source repository is at L<https://github.com/mvgrimes/Perl-Tidy-Sweetened>. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 BUGS |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://github.com/mvgrimes/Perl-Tidy-Sweetened/issues> |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
99
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
100
|
|
|
|
|
|
|
feature. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Mark Grimes <mgrimes@cpan.org>. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
107
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |