line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Server::Morbo::Backend::Inotify; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
13901
|
use Mojo::Base 'Mojo::Server::Morbo::Backend'; |
|
1
|
|
|
|
|
6939
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1334
|
use Linux::Inotify2; |
|
1
|
|
|
|
|
1877
|
|
|
1
|
|
|
|
|
102
|
|
8
|
1
|
|
|
1
|
|
390
|
use Mojo::File 'path'; |
|
1
|
|
|
|
|
99140
|
|
|
1
|
|
|
|
|
57
|
|
9
|
1
|
|
|
1
|
|
482
|
use IO::Select; |
|
1
|
|
|
|
|
1142
|
|
|
1
|
|
|
|
|
903
|
|
10
|
|
|
|
|
|
|
U |
11
|
|
|
|
|
|
|
has _inotify => sub { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
my $i = Linux::Inotify2->new(); |
14
|
|
|
|
|
|
|
$i->watch($_, IN_MODIFY) |
15
|
|
|
|
|
|
|
or die "Could not watch $_: $!" |
16
|
|
|
|
|
|
|
for grep { -e $_ } |
17
|
|
|
|
|
|
|
map { path($_)->list_tree({dir => 1})->each, $_ } @{$self->watch}; |
18
|
|
|
|
|
|
|
$i->blocking(0); |
19
|
|
|
|
|
|
|
return $i; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub modified_files { |
23
|
|
|
|
|
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $select = IO::Select->new($self->_inotify->fileno); |
26
|
|
|
|
|
|
|
$select->can_read($self->watch_timeout); |
27
|
|
|
|
|
|
|
return [map { $_->{w}{name} } $self->_inotify->read]; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding utf8 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Mojo::Server::Morbo::Backend::Inotify - Sample Morbo Inotify watcher |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $backend=Mojo::Server::Morbo::Backend::Inotify->new(); |
41
|
|
|
|
|
|
|
if ($backend->modified_files) {...} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
To use this module, start morbo with the argument -b Inotify |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L inherits all methods from |
50
|
|
|
|
|
|
|
L. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 modified_files |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Looks for modified files using L |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SEE ALSO |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
L, L, L. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Copyright (C) 2008-2017, Marcus Ramberg |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
66
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|