| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::PerlTidy::WithExclusions; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = v0.001; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1972
|
use v5.10; |
|
|
1
|
|
|
|
|
5
|
|
|
6
|
1
|
|
|
1
|
|
1180
|
use Perl::Tidy qw(); |
|
|
1
|
|
|
|
|
347907
|
|
|
|
1
|
|
|
|
|
55
|
|
|
7
|
1
|
|
|
1
|
|
17
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
|
|
with( |
|
9
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileMunger', |
|
10
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
|
11
|
|
|
|
|
|
|
default_finders => [':AllFiles'], |
|
12
|
|
|
|
|
|
|
}, |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'perltidyrc' => (is => 'ro'); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has exclusions => ( |
|
18
|
|
|
|
|
|
|
is => 'ro', |
|
19
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
|
20
|
|
|
|
|
|
|
default => sub { [] }, |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub mvp_multivalue_args {qw(exclusions)} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub munge_files { |
|
26
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self->munge_file($_) for @{ $self->found_files }; |
|
|
0
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub munge_file { |
|
32
|
0
|
|
|
0
|
1
|
|
my ($self, $file) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
return $self->_munge_perl($file) if $file->name =~ /\.(?:pm|pl|t)$/i; |
|
35
|
0
|
0
|
|
|
|
|
return if -B $file->name; # do not try to read binary file |
|
36
|
0
|
0
|
|
|
|
|
return $self->_munge_perl($file) if $file->content =~ /^#!.*\bperl\b/; |
|
37
|
0
|
|
|
|
|
|
return; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _munge_perl { |
|
41
|
0
|
|
|
0
|
|
|
my ($self, $file) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
return if ref($file) eq 'Dist::Zilla::File::FromCode'; |
|
44
|
0
|
0
|
0
|
|
|
|
return if $file->name && $file->name =~ m{^blib/}; |
|
45
|
|
|
|
|
|
|
return |
|
46
|
|
|
|
|
|
|
if $file->name |
|
47
|
0
|
0
|
0
|
|
|
|
and scalar grep { $file->name =~ /$_/ } @{ $self->exclusions }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $perltidyrc; |
|
50
|
0
|
0
|
|
|
|
|
if (defined $self->perltidyrc) { |
|
51
|
0
|
0
|
|
|
|
|
if (-r $self->perltidyrc) { |
|
52
|
0
|
|
|
|
|
|
$perltidyrc = $self->perltidyrc; |
|
53
|
|
|
|
|
|
|
} else { |
|
54
|
0
|
|
|
|
|
|
$self->log_fatal([ 'specified perltidyrc is not readable: %s', $perltidyrc ]); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# make Perl::Tidy happy |
|
59
|
0
|
|
|
|
|
|
local @ARGV = (); |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->log_debug([ 'Perltidying %s', $file->name, ]); |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $source = $file->content; |
|
64
|
0
|
|
|
|
|
|
my ($destination, $errors); |
|
65
|
0
|
0
|
|
|
|
|
Perl::Tidy::perltidy( |
|
66
|
|
|
|
|
|
|
source => \$source, |
|
67
|
|
|
|
|
|
|
destination => \$destination, |
|
68
|
|
|
|
|
|
|
stderr => \$errors, |
|
69
|
|
|
|
|
|
|
argv => ['--standard-error-output'], |
|
70
|
|
|
|
|
|
|
($perltidyrc ? (perltidyrc => $perltidyrc) : ()), |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
$self->log([ 'Errors from perltidying %s: %s', $file->name, $errors, ]) |
|
74
|
|
|
|
|
|
|
if $errors; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$file->content($destination); |
|
77
|
|
|
|
|
|
|
} ## end sub _munge_perl |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
80
|
1
|
|
|
1
|
|
8611
|
no Moose; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
6
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=pod |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=encoding UTF-8 |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 NAME |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PerlTidy::WithExceptions - PerlTidy in Dist::Zilla |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
version 0.001 |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 METHODS |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 munge_file |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Implements the required munge_file method for the |
|
103
|
|
|
|
|
|
|
L<Dist::Zilla::Role::FileMunger> role, munging each Perl file it finds. |
|
104
|
|
|
|
|
|
|
Files whose names do not end in C<.pm>, C<.pl>, or C<.t>, or whose contents |
|
105
|
|
|
|
|
|
|
do not begin with C<#!perl> are left alone. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 SYNOPSIS |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# dist.ini |
|
110
|
|
|
|
|
|
|
[PerlTidy::WithExclusions] |
|
111
|
|
|
|
|
|
|
exceptions = ^share |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# or |
|
114
|
|
|
|
|
|
|
[PerlTidy::WithExclusions] |
|
115
|
|
|
|
|
|
|
perltidyrc = xt/.perltidyrc |
|
116
|
|
|
|
|
|
|
exceptions = ^share |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 DEFAULTS |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
If you do not specify a specific perltidyrc in dist.ini it will try to use |
|
121
|
|
|
|
|
|
|
the same defaults as Perl::Tidy. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 SEE ALSO |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L<Perl::Tidy> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHORS |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over 4 |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Fayland Lam <fayland@gmail.com> |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Mark Gardner <mjgardner@cpan.org> |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Kent Fredric <kentfredric@gmail.com> |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Curtis Jewell <csjewell@cpan.org> |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Fayland Lam, 2021 by Curtis Jewell |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
154
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |