File Coverage

blib/lib/Mojo/Server/Morbo/Backend.pm
Criterion Covered Total %
statement 6 7 85.7
branch n/a
condition n/a
subroutine 2 3 66.6
pod 1 1 100.0
total 9 11 81.8


line stmt bran cond sub pod time code
1             package Mojo::Server::Morbo::Backend;
2 1     1   580 use Mojo::Base -base;
  1         2  
  1         7  
3              
4 1     1   6 use Carp qw(croak);
  1         3  
  1         194  
5              
6             has watch => sub { [qw(lib templates)] };
7             has watch_timeout => sub { $ENV{MOJO_MORBO_TIMEOUT} || 1 };
8              
9 0     0 1   sub modified_files { croak 'Method "modified_files" not implemented by subclass' }
10              
11             1;
12              
13             =encoding utf8
14              
15             =head1 NAME
16              
17             Mojo::Server::Morbo::Backend - Morbo backend base class
18              
19             =head1 SYNOPSIS
20              
21             package Mojo::Server::Morbo::Backend::Inotify:
22             use Mojo::Base 'Mojo::Server::Morbo::Backend';
23              
24             sub modified_files {...}
25              
26             =head1 DESCRIPTION
27              
28             L is an abstract base class for Morbo backends, like
29             L.
30              
31             =head1 ATTRIBUTES
32              
33             L implements the following attributes.
34              
35             =head2 watch
36              
37             my $watch = $backend->watch;
38             $backend = $backend->watch(['/home/sri/my_app']);
39              
40             Files and directories to watch for changes, defaults to the application script as well as the C and C
41             directories in the current working directory.
42              
43             =head2 watch_timeout
44              
45             my $timeout = $backend->watch_timeout;
46             $backend = $backend->watch_timeout(10);
47              
48             Maximum amount of time in seconds a backend may block when waiting for files to change, defaults to the value of the
49             C environment variable or C<1>.
50              
51             =head1 METHODS
52              
53             L inherits all methods from L and implements the following new ones.
54              
55             =head2 modified_files
56              
57             my $files = $backend->modified_files;
58              
59             Check if files from L have been modified since the last check and return an array reference with the results.
60             Meant to be overloaded in a subclass.
61              
62             # All files that have been modified
63             say for @{$backend->modified_files};
64              
65             =head1 SEE ALSO
66              
67             L, L, L.
68              
69             =cut