Skip to content

Commit

Permalink
0.0.33
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Oct 7, 2022
1 parent 21cd3df commit 0561c46
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,9 @@ Revision history for rak

{{$NEXT}}

0.0.33 2022-10-07T23:16:07+02:00
- Add support for --accept and --deny

0.0.32 2022-10-07T12:44:51+02:00
- Support URLs as path/file specifications, needs 'curl'

Expand Down
2 changes: 1 addition & 1 deletion META6.json
Expand Up @@ -29,5 +29,5 @@
],
"test-depends": [
],
"version": "0.0.32"
"version": "0.0.33"
}
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -63,12 +63,16 @@ The result of this step, is a (potentially lazy and hyperable) sequence of objec

Filter down the list of sources from step 1 on any additional filesystem related properties. This assumes that the list of objects created are strings of absolute paths to be checked.

* :accept - given IO, is path acceptable

* :accessed - when was path last accessed

* :blocks- number of filesystem blocks

* :created - when was path created

* :deny - given IO, is path NOT acceptable

* :device-number - device number on which path is located

* :exec - run program, include if successful
Expand Down Expand Up @@ -307,6 +311,10 @@ In a graph:

The following named arguments can be specified (in alphabetical order):

#### :accept(&filter)

If specified, indicates a `Callable` filter that will be given an `IO::Path` of the path. It should return `True` if the path is acceptable.

#### :accessed(&filter)

If specified, indicates the `Callable` filter that should be used to select acceptable paths by the **access** time of the path. The `Callable` is passed a `Num` value of the access time (number of seconds since epoch) and is expected to return a trueish value to have the path be considered for further selection.
Expand Down Expand Up @@ -339,6 +347,10 @@ If specified, indicates the `Callable` filter that should be used to select acce

When hypering over multiple cores, indicate the maximum number of threads that should be used. Defaults to whatever the system thinks is best (which **may** be sub-optimal).

#### :deny(&filter)

If specified, indicates a `Callable` filter that will be given an `IO::Path` of the path. It should return `True` if the path is **NOT** acceptable.

#### :device-number(&filter)

If specified, indicates the `Callable` filter that should be used to select acceptable paths by the **device number** of the path. The `Callable` is passed the device number of the device on which the path is located and is expected to return a trueish value to have the path be considered for further selection.
Expand Down
14 changes: 14 additions & 0 deletions doc/rak.rakudoc
Expand Up @@ -61,9 +61,11 @@ Filter down the list of sources from step 1 on any additional filesystem
related properties. This assumes that the list of objects created are
strings of absolute paths to be checked.

=item :accept - given IO, is path acceptable
=item :accessed - when was path last accessed
=item :blocks- number of filesystem blocks
=item :created - when was path created
=item :deny - given IO, is path NOT acceptable
=item :device-number - device number on which path is located
=item :exec - run program, include if successful
=item :filesize - size of the path in bytes
Expand Down Expand Up @@ -299,6 +301,12 @@ rak(...)
The following named arguments can be specified (in alphabetical
order):

=head4 :accept(&filter)

If specified, indicates a C<Callable> filter that will be given an
C<IO::Path> of the path. It should return C<True> if the path is
acceptable.

=head4 :accessed(&filter)

If specified, indicates the C<Callable> filter that should be used to select
Expand Down Expand Up @@ -350,6 +358,12 @@ When hypering over multiple cores, indicate the maximum number of
threads that should be used. Defaults to whatever the system
thinks is best (which B<may> be sub-optimal).

=head4 :deny(&filter)

If specified, indicates a C<Callable> filter that will be given an
C<IO::Path> of the path. It should return C<True> if the path is
B<NOT> acceptable.

=head4 :device-number(&filter)

If specified, indicates the C<Callable> filter that should be used to select
Expand Down
8 changes: 8 additions & 0 deletions lib/rak.rakumod
Expand Up @@ -274,6 +274,14 @@ my sub make-property-filter($seq is copy, %_) {
!! -> $path { path-is-world-executable($path) ?? Empty !! $path }
}

if %_<accept>:delete -> &code {
$seq = $seq.map: -> $path { code($path.IO) ?? $path !! Empty }
}

if %_<deny>:delete -> &code {
$seq = $seq.map: -> $path { code($path.IO) ?? Empty !! $path }
}

if %_<exec>:delete -> $command {
$seq = $seq.map: -> $path {
run($command.subst('$_', $path, :g)) ?? $path !! Empty
Expand Down
10 changes: 9 additions & 1 deletion xt/02-simple.rakutest
@@ -1,7 +1,7 @@
use Test;
use rak;

plan 51;
plan 53;

my $dir := $*TMPDIR.add("rak");
my @targets := <zero one two three four five six seven eight nine>;
Expand Down Expand Up @@ -223,6 +223,14 @@ lookup '*.subst("w","v",:g)', :paths($dir), :old-new,
"nine" => (o2,),
;

lookup "eight", :accept(*.slurp.contains("nine")), :paths($dir),
"nine" => (l8,)
;

lookup "eight", :deny(*.slurp.contains("nine")), :paths($dir),
"eight" => (l8,)
;

my %b is BagHash;
my $FIRST-matcher-fired;
my $LAST-matcher-fired;
Expand Down

0 comments on commit 0561c46

Please sign in to comment.