1Dist::Zilla::Role::FileUWsaetrchCeorn(t3r)ibuted Perl DoDciusmte:n:tZaitliloan::Role::FileWatcher(3)
2
3
4

NAME

6       Dist::Zilla::Role::FileWatcher - Receive notification when something
7       changes a file's contents
8

VERSION

10       version 0.006
11

SYNOPSIS

13           package Dist::Zilla::Plugin::MyPlugin;
14           use Moose;
15           with 'Dist::Zilla::Role::SomeRole', 'Dist::Zilla::Role::FileWatcher';
16
17           sub some_phase
18           {
19               my $self = shift;
20
21               my (file) = grep { $_->name eq 'some_name' } @{$self->zilla->files};
22               # ... do something with this file ...
23
24               $self->lock_file($file, 'KEEP OUT!');
25
26               # or:
27
28               $self->watch_file(
29                   $file,
30                   sub {
31                       my ($plugin, $file) = @_;
32                       ... do something with the file object ...
33                   },
34               );
35           }
36

DESCRIPTION

38       This is a role for Dist::Zilla plugins which gives you a mechanism for
39       detecting and acting on files changing their content. This is useful if
40       your plugin performs an action based on a file's content (perhaps
41       copying that content to another file), and then later in the build
42       process, that source file's content is later modified.
43

METHODS

45       This role adds the following methods to your plugin class:
46
47   "watch_file($file, $subref)"
48       This method takes two arguments: the $file object to watch, and a
49       subroutine which is invoked when the file's contents change. It is
50       called as a method on your plugin, and is passed one additional
51       argument: the $file object that changed.
52
53   "lock_file($file, $message?)"
54       This method takes the $file object to watch, and an optional message
55       string; when the file is modified after it is locked, the build dies.
56

SUPPORT

58       Bugs may be submitted through the RT bug tracker
59       <https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Role-
60       FileWatcher> (or bug-Dist-Zilla-Role-FileWatcher@rt.cpan.org
61       <mailto:bug-Dist-Zilla-Role-FileWatcher@rt.cpan.org>).  I am also
62       usually active on irc, as 'ether' at "irc.perl.org".
63

SEE ALSO

65       •   Dist::Zilla::Role::File::ChangeNotification - in this distribution,
66           the underlying implementation for watching the file
67
68       •   Dist::Zilla::File::OnDisk
69
70       •   Dist::Zilla::File::InMemory
71

AUTHOR

73       Karen Etheridge <ether@cpan.org>
74

CONTRIBUTOR

76       Yanick Champoux <yanick@babyl.dyndns.org>
77
79       This software is copyright (c) 2013 by Karen Etheridge.
80
81       This is free software; you can redistribute it and/or modify it under
82       the same terms as the Perl 5 programming language system itself.
83
84
85
86perl v5.36.0                      2022-07-22 Dist::Zilla::Role::FileWatcher(3)
Impressum