summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-05-21 13:05:39 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-05-21 13:05:39 +0200
commitd737f0e7bc48921960d8a101c4e8d17ec414896a (patch)
treef74065a93b623f33e8e30662ff4a09bad3e2be09
parent474928ed9579e41bc927e4a9980857f28cb25209 (diff)
App/Hashl: Add unignore function (not yet used in hashl itself)
-rw-r--r--lib/App/Hashl.pm12
-rw-r--r--t/29-app-hashl.t15
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/App/Hashl.pm b/lib/App/Hashl.pm
index 468ddb9..da06693 100644
--- a/lib/App/Hashl.pm
+++ b/lib/App/Hashl.pm
@@ -158,6 +158,14 @@ sub ignore {
return 1;
}
+sub unignore {
+ my ( $self, $path ) = @_;
+
+ delete $self->{ignored}->{ $self->hash_file($path) };
+
+ return 1;
+}
+
sub save {
my ( $self, $file ) = @_;
@@ -286,6 +294,10 @@ Returns a list of all ignored file hashes.
Removes I<$file> from the database and adds I<$path> to the list of ignored
file hashes.
+=item $hashl->unignore(I<$path>)
+
+Unignore the hash of I<$path>.
+
=item $hashl->save(I<$file>)
Save the B<App::Hashl> object with all data to I<$file>. It can later be
diff --git a/t/29-app-hashl.t b/t/29-app-hashl.t
index f17fc88..e5b6fe3 100644
--- a/t/29-app-hashl.t
+++ b/t/29-app-hashl.t
@@ -3,7 +3,7 @@ use strict;
use warnings;
use 5.010;
-use Test::More tests => 32;
+use Test::More tests => 35;
use_ok('App::Hashl');
@@ -84,6 +84,19 @@ $hashl->add_file(
is_deeply([$hashl->files()], [], 'ignored file not added');
+$hashl->unignore('t/in/1k');
+is_deeply([$hashl->ignored()], [$test_hash], 'unignore worked');
+
+ok(
+ $hashl->add_file(
+ file => 't/in/1k',
+ path => 't/in/1k',
+ ),
+ 'Re-add file to database',
+);
+
+ok($hashl->file_in_db('t/in/1k', 'file in db again'));
+
undef $hashl;
my $hash_512 = App::Hashl->new(read_size => 512)->hash_file('t/in/1k');