Skip to content

Commit

Permalink
Fix .cache-ignore and document it
Browse files Browse the repository at this point in the history
- Before this changes '.cache-ignore' worked the other way around (as a
  whitelist)

References:
  • Loading branch information
antoniogamiz committed Oct 8, 2019
1 parent 9cc5049 commit 4104583
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ $cache.freeze;
- Old
A source name that is in the cache but no longer reflects an existing source.

- **.cache-ignore**: You can create a file named `.cache-ignore` containing Perl 6 regular expressions. Pod6 filenames in `$source` matching at least one of the provided regexes, will be ignored.

Example:
~~~
*podignored*.pod6
~~~
## LICENSE

You can use and distribute this module under the terms of the The Artistic License 2.0. See the LICENSE file included in this distribution for complete details.
Expand Down
2 changes: 1 addition & 1 deletion lib/Pod/To/Cached.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ method filter-pods(:@pods) {
if (IGNORE_FILE.IO.e) {
my @regexs = IGNORE_FILE.IO.slurp.split("\n", :skip-empty);
my @filtered = @pods;
for @regexs -> $regex { @filtered .= grep(/<{$regex}>/); }
for @regexs -> $regex { @filtered .= grep({not /<{$regex}>/}); }
return @filtered;
}
return @pods;
Expand Down
16 changes: 8 additions & 8 deletions t/060-cache-ignore.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ create-pods("test2.pod6");

#--MARKER-- Test 1
$cache .= new( :source( DOC ), :path( REP ), :verbose);
is-deeply $cache.get-pods,
["t/tmp/doc-ignore/test2.pod6",
"t/tmp/doc-ignore/test1.pod6"],
is-deeply $cache.get-pods.sort,
("t/tmp/doc-ignore/test1.pod6",
"t/tmp/doc-ignore/test2.pod6"),
IGNORE_FILE ~ " does not exist";

#--MARKER-- Test 2
IGNORE_FILE.IO.spurt("");
$cache .= new( :source( DOC ), :path( REP ), :verbose);
is-deeply $cache.get-pods,
["t/tmp/doc-ignore/test2.pod6",
"t/tmp/doc-ignore/test1.pod6"],
is-deeply $cache.get-pods.sort,
("t/tmp/doc-ignore/test1.pod6",
"t/tmp/doc-ignore/test2.pod6"),
IGNORE_FILE ~ " is empty";
unlink IGNORE_FILE;

#--MARKER-- Test 3
IGNORE_FILE.IO.spurt("test2");
$cache .= new( :source( DOC ), :path( REP ), :verbose);
is-deeply $cache.get-pods,
["t/tmp/doc-ignore/test2.pod6"],
is-deeply $cache.get-pods.sort,
("t/tmp/doc-ignore/test1.pod6",),
IGNORE_FILE ~ " with simple regex";
unlink IGNORE_FILE;

Expand Down

0 comments on commit 4104583

Please sign in to comment.