| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::Find::Rule::PPI; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
File::Find::Rule::PPI - Add support for PPI queries to File::Find::Rule |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use File::Find::Rule (); |
|
12
|
|
|
|
|
|
|
use File::Find::Rule::PPI (); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Find all perl modules that use here-docs |
|
15
|
|
|
|
|
|
|
my $Find = File::Find::Rule->file |
|
16
|
|
|
|
|
|
|
->name('*.pm') |
|
17
|
|
|
|
|
|
|
->ppi_find_any('Token::HereDoc'); |
|
18
|
|
|
|
|
|
|
my @heredoc = $Find->in( $dir ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
File::Find::Rule::PPI allows you to integrate PPI content queries |
|
23
|
|
|
|
|
|
|
into your L searches. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Initially, it provides the one additional method C, |
|
26
|
|
|
|
|
|
|
which takes an argument identical to the L method C |
|
27
|
|
|
|
|
|
|
and checks each file as a perl document to see if matches the query. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
|
|
33
|
2
|
|
|
2
|
|
60320
|
use 5.005; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
86
|
|
|
34
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
86
|
|
|
35
|
2
|
|
|
2
|
|
2418
|
use Params::Util 0.10 '_INSTANCE'; |
|
|
2
|
|
|
|
|
10439
|
|
|
|
2
|
|
|
|
|
163
|
|
|
36
|
2
|
|
|
2
|
|
1044
|
use File::Find::Rule 0.20 (); |
|
|
2
|
|
|
|
|
13610
|
|
|
|
2
|
|
|
|
|
55
|
|
|
37
|
2
|
|
|
2
|
|
2193
|
use PPI 1.000 (); |
|
|
2
|
|
|
|
|
337915
|
|
|
|
2
|
|
|
|
|
70
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
2
|
|
|
2
|
|
21
|
use vars qw{$VERSION @ISA @EXPORT}; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
183
|
|
|
40
|
|
|
|
|
|
|
BEGIN { |
|
41
|
2
|
|
|
2
|
|
5
|
$VERSION = '1.06'; |
|
42
|
2
|
|
|
|
|
36
|
@ISA = 'File::Find::Rule'; |
|
43
|
2
|
|
|
|
|
5
|
@EXPORT = @File::Find::Rule::EXPORT; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Preload PPI::Find module if needed and possible |
|
46
|
2
|
|
|
|
|
543
|
eval "use prefork => 'PPI::Find';"; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
##################################################################### |
|
54
|
|
|
|
|
|
|
# Add the methods to File::Find::Rule |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 ppi_find_any $condition | $PPI::Find |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The C method causes a query identical to (and implemented |
|
61
|
|
|
|
|
|
|
using) L's C method. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
It takes as argument any condition that would also be valid for the above |
|
64
|
|
|
|
|
|
|
method. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
In addition, it can also take as argument an instantiated L |
|
67
|
|
|
|
|
|
|
object, and will use that object's C method to achieve the |
|
68
|
|
|
|
|
|
|
same effect. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
If you provide no or an illegal condition to ppi_find_any, the check will |
|
71
|
|
|
|
|
|
|
always fail, and B files will be returned when you execute the search. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub File::Find::Rule::ppi_find_any { |
|
76
|
2
|
|
|
2
|
0
|
1336
|
require PPI; |
|
77
|
2
|
|
|
|
|
8
|
my $self = shift()->_force_object; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Is this a PPI::Find object |
|
80
|
2
|
50
|
|
|
|
21
|
if ( _INSTANCE($_[0], 'PPI::Find') ) { |
|
81
|
0
|
|
|
|
|
0
|
require PPI::Find; |
|
82
|
0
|
|
|
|
|
0
|
my $Find = shift; |
|
83
|
|
|
|
|
|
|
return $self->exec( sub { |
|
84
|
0
|
0
|
|
0
|
|
0
|
my $Document = PPI::Document->new($_) or return; |
|
85
|
0
|
0
|
|
|
|
0
|
$Find->any_matches or return; |
|
86
|
0
|
|
|
|
|
0
|
1; |
|
87
|
0
|
|
|
|
|
0
|
} ); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Normal Document->find_any test |
|
91
|
2
|
|
|
|
|
18
|
my $condition = PPI::Node->_wanted(shift); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# If you want to find crap, you never will |
|
94
|
2
|
50
|
|
|
|
530
|
return $self->discard unless $condition; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Add the query for a valid condition |
|
97
|
|
|
|
|
|
|
$self->exec( sub { |
|
98
|
6
|
50
|
|
6
|
|
3718
|
my $Document = PPI::Document->new($_) or return; |
|
99
|
6
|
100
|
|
|
|
8427
|
$Document->find_any( $condition ) or return; |
|
100
|
5
|
|
|
|
|
1168
|
1; |
|
101
|
2
|
|
|
|
|
19
|
} ); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=pod |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SUPPORT |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Bugs should always be submitted via the CPAN bug tracker |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
For other issues, contact the maintainer |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Funding provided by The Perl Foundation |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L, L, L |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Copyright 2005 - 2010 Adam Kennedy. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
133
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
136
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |