- Timestamp:
- 02/14/06 20:19:23 (19 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r10 r12 1 1 Revision history for Perl extension MP3::Find. 2 2 3 0.0 1 29 Jan 20064 - first CPAN release3 0.03 4 - added "exclude_path" option to filesystem backend 5 5 6 6 0.02 1 Feb 2006 … … 9 9 - DB management functions are now in the DB backend 10 10 - rewrote (and documented) mp3db to use the new DB backend functions 11 12 0.01 29 Jan 2006 13 - first CPAN release -
trunk/lib/MP3/Find/DB.pm
r10 r12 123 123 warn "Multiple records for $$mp3{FILENAME}\n" if @$records > 1; 124 124 125 #TODO: maybe print status updates somewhere else? 125 126 if (@$records == 0) { 126 127 $insert_sth->execute(map { $mp3->{$$_[0]} } @COLUMNS); … … 138 139 # (see http://rt.cpan.org/Ticket/Display.html?id=9643#txn-120724) 139 140 foreach ($mtime_sth, $insert_sth, $update_sth) { 141 $_->{RaiseError} = 0; # don't die on error 140 142 $_->{Active} = 1; 141 143 $_->finish; -
trunk/lib/MP3/Find/Filesystem.pm
r3 r12 30 30 } 31 31 32 if ($$options{exclude_path}) { 33 my $ref = ref $$options{exclude_path}; 34 if ($ref eq 'ARRAY') { 35 $$options{exclude_path} = '(' . join('|', @{ $$options{exclude_path} }) . ')'; 36 } 37 unless ($ref eq 'Regexp') { 38 $$options{exclude_path} = qr[$$options{exclude_path}]; 39 } 40 } 41 32 42 # run the actual find 33 43 my @results; 34 find(sub { match_mp3($File::Find::name, $query, \@results ) }, $_) foreach @$dirs;44 find(sub { match_mp3($File::Find::name, $query, \@results, $options) }, $_) foreach @$dirs; 35 45 36 46 # sort the results … … 54 64 55 65 sub match_mp3 { 56 my ($filename, $query, $results ) = @_;66 my ($filename, $query, $results, $options) = @_; 57 67 58 68 return unless $filename =~ m{[^/]\.mp3$}; 69 if ($$options{exclude_path}) { 70 return if $filename =~ $$options{exclude_path}; 71 } 72 59 73 my $mp3 = { 60 74 FILENAME => $filename, … … 103 117 =head2 Special Options 104 118 105 There are no special options for B<MP3::Find::Filesystem>. See 106 L<MP3::Find> for the description of the general options. 119 =over 120 121 =item C<exclude_path> 122 123 Scalar or arrayref; any file whose name matches any of these paths 124 will be skipped. 107 125 108 126 =head1 SEE ALSO -
trunk/t/02-filesystem.t
r8 r12 2 2 use strict; 3 3 4 use Test::More 'no_plan'; #tests => 4;4 use Test::More tests => 6; 5 5 BEGIN { use_ok('MP3::Find::Filesystem') }; 6 6 7 7 my $SEARCH_DIR = 't/mp3s'; 8 my $MP3_COUNT = 0; 8 my $EXCLUDE_DIR = 't/mp3s/dont_look_here'; 9 my $MP3_COUNT = 1; 10 my $EXCLUDED_MP3_COUNT = 1; 9 11 10 12 # exercise the object … … 20 22 is(scalar(@res), $MP3_COUNT, 'dir as ARRAY ref'); 21 23 24 # exclude 25 @res = $finder->find_mp3s(dir => $SEARCH_DIR, exclude_path => $EXCLUDE_DIR); 26 is(scalar(@res), $MP3_COUNT - $EXCLUDED_MP3_COUNT, 'excluded directory'); 27 28 @res = $finder->find_mp3s(dir => $SEARCH_DIR, exclude_path => [$EXCLUDE_DIR]); 29 is(scalar(@res), $MP3_COUNT - $EXCLUDED_MP3_COUNT, 'excluded directory as array'); 30 22 31 #TODO: get some test mp3s -
trunk/t/03-db.t
r10 r12 19 19 my $SEARCH_DIR = 't/mp3s'; 20 20 my $DB_FILE = 't/mp3.db'; 21 my $MP3_COUNT = 0;21 my $MP3_COUNT = 1; 22 22 23 23 # exercise the object
Note: See TracChangeset
for help on using the changeset viewer.