line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Find::Rule::TTMETA; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
384306
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
234
|
|
4
|
4
|
|
|
4
|
|
24
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
581
|
|
5
|
4
|
|
|
4
|
|
32
|
use base qw(File::Find::Rule); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
5496
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
76206
|
use Template::Config; |
|
4
|
|
|
|
|
109935
|
|
|
4
|
|
|
|
|
4641
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $provider; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub File::Find::Rule::ttmeta { |
12
|
13
|
|
|
13
|
0
|
34337
|
my $self = shift->_force_object(); |
13
|
13
|
100
|
|
|
|
357
|
my $meta = UNIVERSAL::isa($_[0], 'HASH') ? shift : { @_ }; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$self->exec( |
16
|
|
|
|
|
|
|
sub { |
17
|
47
|
|
|
47
|
|
19790
|
my $file = shift; |
18
|
47
|
|
|
|
|
67
|
my ($doc, $match, $key); |
19
|
47
|
|
|
|
|
70
|
$match = 0; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Optimization |
22
|
47
|
100
|
|
|
|
449
|
return $match |
23
|
|
|
|
|
|
|
if scalar keys %$meta == 0; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# warn " *** $file ***\n"; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Skip directories |
28
|
40
|
100
|
|
|
|
791
|
return if -d $file; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Set $provider to a Template::Provider instance or workalike |
31
|
|
|
|
|
|
|
# $file contains an absolute path |
32
|
33
|
100
|
|
|
|
493
|
$provider = Template::Config->provider(ABSOLUTE => 1) |
33
|
|
|
|
|
|
|
unless defined $provider; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Attempt to turn the file into a Template::Document instance, |
36
|
|
|
|
|
|
|
# or return -- it can't match if it isn't a valid Template. |
37
|
33
|
|
|
|
|
87237
|
eval { ($doc) = $provider->fetch($file); }; |
|
33
|
|
|
|
|
144
|
|
38
|
33
|
50
|
|
|
|
396768
|
return if $@; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Bad Things Happened. Next! |
41
|
33
|
50
|
33
|
|
|
271
|
return unless defined $doc && |
42
|
|
|
|
|
|
|
UNIVERSAL::isa($doc, 'Template::Document'); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# The intent is to match all of the possibilities; |
45
|
|
|
|
|
|
|
# if someone specifies: |
46
|
|
|
|
|
|
|
# |
47
|
|
|
|
|
|
|
# find(ttmeta => { AUTHOR => 'foo', VERSION => '1.1' }) |
48
|
|
|
|
|
|
|
# |
49
|
|
|
|
|
|
|
# then we only want to return success if all match. |
50
|
|
|
|
|
|
|
# |
51
|
|
|
|
|
|
|
# To support complex (TT-style foo.bar) variables, $key |
52
|
|
|
|
|
|
|
# would need to be split on /\./, and each element treated |
53
|
|
|
|
|
|
|
# as either a hash or array entry. This reimplementing of |
54
|
|
|
|
|
|
|
# Template::Stash::_dotop bugs me, though. |
55
|
33
|
|
|
|
|
109
|
for $key (keys %$meta) { |
56
|
36
|
|
|
|
|
194
|
my $val = $meta->{$key}; |
57
|
|
|
|
|
|
|
|
58
|
36
|
100
|
|
|
|
105
|
if (ref $val eq 'Regexp') { |
59
|
12
|
100
|
|
|
|
79
|
$match++ if $doc->$key() =~ $val; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
24
|
100
|
|
|
|
256
|
$match++ if $doc->$key() eq $val; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
33
|
|
|
|
|
1559
|
return $match == scalar keys %$meta; |
67
|
|
|
|
|
|
|
} |
68
|
13
|
|
|
|
|
534
|
); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |