line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Server::Morbo::Backend::Inotify; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
36454
|
use Mojo::Base 'Mojo::Server::Morbo::Backend'; |
|
1
|
|
|
|
|
13426
|
|
|
1
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2196
|
use Linux::Inotify2; |
|
1
|
|
|
|
|
3537
|
|
|
1
|
|
|
|
|
224
|
|
8
|
1
|
|
|
1
|
|
794
|
use Mojo::File 'path'; |
|
1
|
|
|
|
|
196140
|
|
|
1
|
|
|
|
|
112
|
|
9
|
1
|
|
|
1
|
|
870
|
use IO::Select; |
|
1
|
|
|
|
|
2092
|
|
|
1
|
|
|
|
|
419
|
|
10
|
|
|
|
|
|
|
|
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
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $select = IO::Select->new($self->_inotify->fileno); |
26
|
0
|
|
|
|
|
|
$select->can_read($self->watch_timeout); |
27
|
0
|
|
|
|
|
|
return [map { $_->{w}{name} } $self->_inotify->read]; |
|
0
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|