| 1 | package Mojo::Server::Morbo::Backend; | ||||||||||
| 2 | 1 | ▶ | use Mojo::Base -base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 0 | ▶ | has watch => sub { [qw(lib templates)] }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 7 | 0 | ▶ | has watch_timeout => sub { $ENV{MOJO_MORBO_TIMEOUT} || 1 }; | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub modified_files { croak 'Method "modified_files" not implemented by subclass' } | ||||||||
|
Subroutine
modified_files: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | 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<Mojo::Server::Morbo::Backend> is an abstract base class for Morbo backends, like | ||||||||||
| 29 | L<Mojo::Server::Morbo::Backend::Poll>. | ||||||||||
| 30 | |||||||||||
| 31 | =head1 ATTRIBUTES | ||||||||||
| 32 | |||||||||||
| 33 | L<Mojo::Server::Morbo::Backend> 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<lib> and C<templates> | ||||||||||
| 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<MOJO_MORBO_TIMEOUT> environment variable or C<1>. | ||||||||||
| 50 | |||||||||||
| 51 | =head1 METHODS | ||||||||||
| 52 | |||||||||||
| 53 | L<Mojo::Server::Morbo::Backend> inherits all methods from L<Mojo::Base> 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</"watch"> 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<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>. | ||||||||||
| 68 | |||||||||||
| 69 | =cut | ||||||||||