| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::Find::Rule::SAUCE; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
File::Find::Rule::SAUCE - Rule to match on title, author, etc from a file's SAUCE record |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use File::Find::Rule::SAUCE; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# get all files where 'Brian' is the author |
|
12
|
|
|
|
|
|
|
my @files = find( sauce => { author => qr/Brian/ }, in => '/ansi' ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# get all files without a SAUCE rec |
|
15
|
|
|
|
|
|
|
@files = find( sauce => { has_sauce => 0 }, in => '/ansi' ); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This module will search through a file's SAUCE metadata (using File::SAUCE) and match on the |
|
21
|
|
|
|
|
|
|
specified fields. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
|
179142
|
use strict; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
233
|
|
|
26
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
120
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
|
4914
|
use File::Find::Rule; |
|
|
4
|
|
|
|
|
60985
|
|
|
|
4
|
|
|
|
|
48
|
|
|
29
|
4
|
|
|
4
|
|
251
|
use base qw( File::Find::Rule ); |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
6356
|
|
|
30
|
4
|
|
|
4
|
|
28
|
use vars qw( @EXPORT $VERSION ); |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
626
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
@EXPORT = @File::Find::Rule::EXPORT; |
|
33
|
|
|
|
|
|
|
$VERSION = '0.06'; |
|
34
|
|
|
|
|
|
|
|
|
35
|
4
|
|
|
4
|
|
36561
|
use File::SAUCE; |
|
|
4
|
|
|
|
|
354479
|
|
|
|
4
|
|
|
|
|
40
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 sauce( %options ) |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my @files = find( sauce => { title => qr/My Ansi/ }, in => '/ansi' ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
If more than one field is specified, it will only return the file if ALL of the criteria |
|
44
|
|
|
|
|
|
|
are met. You can specify a regex (qr//) or just a string. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Matching on the comments field will search each line of comments for the requested string. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has_sauce is a special field which should be matched against true or false values (no regexes). |
|
49
|
|
|
|
|
|
|
has_sauce => 1 is implied if not specified. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
See File::SAUCE for a list of all the fields that can be matched. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub File::Find::Rule::sauce { |
|
56
|
12
|
|
|
12
|
0
|
9355
|
my $self = shift()->_force_object; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Procedural interface allows passing arguments as a hashref. |
|
59
|
12
|
50
|
|
|
|
119
|
my %criteria = UNIVERSAL::isa( $_[ 0 ], 'HASH' ) ? %{ $_[ 0 ] } : @_; |
|
|
12
|
|
|
|
|
129
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->exec( sub { |
|
62
|
60
|
|
|
60
|
|
14517
|
my $file = shift; |
|
63
|
|
|
|
|
|
|
|
|
64
|
60
|
100
|
|
|
|
1041
|
return if -d $file; |
|
65
|
|
|
|
|
|
|
|
|
66
|
48
|
|
|
|
|
242
|
my $info = File::SAUCE->new( file => $file ); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# deal with files (not) having SAUCE records first |
|
69
|
48
|
100
|
|
|
|
39440
|
if( exists $criteria{ has_sauce } ) { |
|
|
|
100
|
|
|
|
|
|
|
70
|
8
|
100
|
|
|
|
23
|
return 0 unless $info->has_sauce == $criteria{ has_sauce }; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
# if has_sauce was not specified, there's no point in continuing |
|
73
|
|
|
|
|
|
|
# when the file has no SAUCE record |
|
74
|
|
|
|
|
|
|
elsif( $info->has_sauce == 0 ) { |
|
75
|
20
|
|
|
|
|
807
|
return 0; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# passed has_sauce - check the other criteria |
|
79
|
24
|
|
|
|
|
252
|
for my $field ( keys %criteria ) { |
|
80
|
28
|
|
|
|
|
103
|
$field = lc( $field ); |
|
81
|
28
|
100
|
|
|
|
74
|
next if $field eq 'has_sauce'; |
|
82
|
|
|
|
|
|
|
|
|
83
|
24
|
100
|
|
|
|
64
|
if ( $field eq 'comments' ) { |
|
|
|
100
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
12
|
|
|
|
|
30
|
my $comments = $info->comments; |
|
86
|
|
|
|
|
|
|
|
|
87
|
12
|
100
|
|
|
|
121
|
if ( ref $criteria{ $field } eq 'Regexp' ) { |
|
88
|
6
|
100
|
|
|
|
14
|
if ( scalar @$comments > 0 ) { |
|
89
|
3
|
100
|
|
|
|
3
|
return unless grep( $_ =~ $criteria{ $field }, @{ $comments } ); |
|
|
3
|
|
|
|
|
81
|
|
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
else { |
|
92
|
3
|
100
|
|
|
|
83
|
return unless '' =~ $criteria{ $field }; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
else { |
|
96
|
6
|
100
|
|
|
|
14
|
if ( scalar @$comments > 0 ) { |
|
97
|
3
|
100
|
|
|
|
4
|
return unless grep( $_ eq $criteria{ $field }, @{ $comments } ); |
|
|
3
|
|
|
|
|
71
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
else { |
|
100
|
3
|
100
|
|
|
|
80
|
return unless $criteria{ $field } eq ''; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
elsif ( ref $criteria{ $field } eq 'Regexp' ) { |
|
105
|
6
|
100
|
|
|
|
16
|
return unless $info->$field =~ $criteria{ $field }; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
else { |
|
108
|
6
|
100
|
|
|
|
24
|
return unless $info->$field eq $criteria{ $field }; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
12
|
|
|
|
|
406
|
return 1; |
|
112
|
12
|
|
|
|
|
102
|
} ); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * Brian Cassidy Ebricas@cpan.orgE |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Copyright 2007 by Brian Cassidy |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
128
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=over 4 |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * File::SAUCE |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * File::Find::Rule |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * File::Find::Rule::MP3Info |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1; |