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.03';
3             # ABSTRACT: Registers public asset directories from plugin share directories
4              
5 13     13   76 use Mojo::Base 'Mojolicious::Plugin::Fondation::Action::Base', -signatures;
  13         21  
  13         79  
6              
7 13     13   3311 use Mojolicious::Plugin::Fondation::Utils qw(share_relative);
  13         23  
  13         2780  
8              
9 152     152 0 254 sub after_load ($self, $long, $conf, $share_dir) {
  152         219  
  152         200  
  152         214  
  152         178  
  152         177  
10 152 100 66     521 return unless $share_dir && -d $share_dir;
11              
12 131         4418 my $public_dir = $share_dir->child('public');
13 131 100       2416 return unless -d $public_dir;
14              
15 18         307 my $manager = $self->manager;
16 18         93 my $app = $manager->app;
17              
18             # Add public directory to static file paths
19 18         79 push @{$app->static->paths}, $public_dir->to_string;
  18         62  
20 18         233 $self->log->debug("Added public path: " . share_relative($public_dir));
21              
22             # Store in registry for other consumers (e.g. Asset plugin)
23 18         204 my $entry = $manager->registry->{$long};
24 18         205 $entry->{public_dir} = $public_dir;
25             }
26              
27             1;
28              
29             __END__