Watcher
NAME
App::Lorea::Watcher - General use file recursive file watching subs
SYNOPSIS
use App::Lorea::Watcher;
my $supply = $path.&watch-recursive(
debounce => 0.5,
exclude => rx{ '~' $ }, # Ignore files ending in ~
);
whenever $supply { ... }
DESCRIPTION
This module exports a single subroutine to make it easier to recursively watch a directory for file changes. It is currently bundled in with App::Lorea, but it does not depend on it for proper use.
SUBROUTINES
watch-recursive
sub watch-recursive(
$root, # The root from where recursion will start
:$exclude, # A matcher to exclude
:$debounce, # Seconds to wait before emitting the same path
) returns Supply
Returns a live Supply of IO::Notification::Change with changes to
any file or directory under $root
recursively. This includes any
changes to the direct contents of $root
. $root
can be anything
on which .IO
can be called.
An optional $debounce
numeric parameter may be provided. If so, the
same path will not be emitted until at least that number of seconds have
passed, or a large enough number of events have been seen. This number
can be set with the $cache-size
parameter.
If provided, $exclude
is matched against the result of calling
App::Lorea::Watcher::normalise
on the path relative to $root
. Any
matching paths will not be sent through the Supply.
Based on https://github.com/zoffixznet/perl6-Ticket-Trakr
AUTHOR
José Joaquín Atria <[email protected]>
COPYRIGHT AND LICENSE
Copyright 2020 José Joaquín Atria
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.