File Coverage

lib/Mojolicious/Plugin/Fondation/Action/Static.pm
Criterion Covered Total %
statement 22 22 100.0
branch 4 4 100.0
condition 2 3 66.6
subroutine 3 3 100.0
pod 0 1 0.0
total 31 33 93.9


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::Fondation::Action::Static;
2             $Mojolicious::Plugin::Fondation::Action::Static::VERSION = '0.02';
3             # ABSTRACT: Registers public asset directories from plugin share directories
4              
5 13     13   73 use Mojo::Base 'Mojolicious::Plugin::Fondation::Action::Base', -signatures;
  13         21  
  13         78  
6              
7 13     13   3338 use Mojolicious::Plugin::Fondation::Utils qw(share_relative);
  13         22  
  13         3001  
8              
9 152     152 0 240 sub after_load ($self, $long, $conf, $share_dir) {
  152         206  
  152         219  
  152         194  
  152         196  
  152         168  
10 152 100 66     552 return unless $share_dir && -d $share_dir;
11              
12 131         4329 my $public_dir = $share_dir->child('public');
13 131 100       2508 return unless -d $public_dir;
14              
15 18         319 my $manager = $self->manager;
16 18         116 my $app = $manager->app;
17              
18             # Add public directory to static file paths
19 18         51 push @{$app->static->paths}, $public_dir->to_string;
  18         65  
20 18         244 $self->log->debug("Added public path: " . share_relative($public_dir));
21              
22             # Store in registry for other consumers (e.g. Asset plugin)
23 18         197 my $entry = $manager->registry->{$long};
24 18         179 $entry->{public_dir} = $public_dir;
25             }
26              
27             1;
28              
29             __END__