line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::PerlTidy; |
2
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::PerlTidy::VERSION = '0.18'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: PerlTidy in Dist::Zilla |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
15625
|
use Moose; |
|
1
|
|
|
|
|
348457
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileMunger'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'perltidyrc' => ( is => 'ro' ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub munge_file { |
12
|
0
|
|
|
0
|
1
|
|
my ( $self, $file ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
return $self->_munge_perl($file) if $file->name =~ /\.(?:pm|pl|t)$/i; |
15
|
0
|
0
|
|
|
|
|
return if -B $file->name; # do not try to read binary file |
16
|
0
|
0
|
|
|
|
|
return $self->_munge_perl($file) if $file->content =~ /^#!.*\bperl\b/; |
17
|
0
|
|
|
|
|
|
return; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _munge_perl { |
21
|
0
|
|
|
0
|
|
|
my ( $self, $file ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
return if ref($file) eq 'Dist::Zilla::File::FromCode'; |
24
|
|
|
|
|
|
|
return |
25
|
0
|
0
|
0
|
|
|
|
if $file->name |
26
|
|
|
|
|
|
|
and $file->name eq 't/00-compile.t' |
27
|
|
|
|
|
|
|
; # simply skip Dist::Zilla::Plugin::Test::Compile (RT 88601) |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $source = $file->content; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $perltidyrc; |
32
|
0
|
0
|
|
|
|
|
if ( defined $self->perltidyrc ) { |
33
|
0
|
0
|
|
|
|
|
if ( -r $self->perltidyrc ) { |
34
|
0
|
|
|
|
|
|
$perltidyrc = $self->perltidyrc; |
35
|
|
|
|
|
|
|
} else { |
36
|
0
|
|
|
|
|
|
$self->log_fatal( |
37
|
|
|
|
|
|
|
[ "specified perltidyrc is not readable: %s", $perltidyrc ] ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# make Perl::Tidy happy |
42
|
0
|
|
|
|
|
|
local @ARGV = (); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $destination; |
45
|
0
|
|
|
|
|
|
require Perl::Tidy; |
46
|
0
|
0
|
|
|
|
|
Perl::Tidy::perltidy( |
47
|
|
|
|
|
|
|
source => \$source, |
48
|
|
|
|
|
|
|
destination => \$destination, |
49
|
|
|
|
|
|
|
( $perltidyrc ? ( perltidyrc => $perltidyrc ) : () ), |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$file->content($destination); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
56
|
1
|
|
|
1
|
|
6303
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding UTF-8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PerlTidy - PerlTidy in Dist::Zilla |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
version 0.18 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 munge_file |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Implements the required munge_file method for the |
79
|
|
|
|
|
|
|
L<Dist::Zilla::Role::FileMunger> role, munging each Perl file it finds. |
80
|
|
|
|
|
|
|
Files whose names do not end in C<.pm>, C<.pl>, or C<.t>, or whose contents |
81
|
|
|
|
|
|
|
do not begin with C<#!perl> are left alone. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 SYNOPSIS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# dist.ini |
86
|
|
|
|
|
|
|
[PerlTidy] |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# or |
89
|
|
|
|
|
|
|
[PerlTidy] |
90
|
|
|
|
|
|
|
perltidyrc = xt/.perltidyrc |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 DEFAULTS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
If you do not specify a specific perltidyrc in dist.ini it will try to use |
95
|
|
|
|
|
|
|
the same defaults as Perl::Tidy. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 SEE ALSO |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<Perl::Tidy> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHORS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Fayland Lam <fayland@gmail.com> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Mark Gardner <mjgardner@cpan.org> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Kent Fredric <kentfredric@gmail.com> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Fayland Lam. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
124
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |