File Coverage

blib/lib/File/Assets/Filter/Minifier/Base.pm
Criterion Covered Total %
statement 24 24 100.0
branch 3 4 75.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 35 39 89.7


line stmt bran cond sub pod time code
1             package File::Assets::Filter::Minifier::Base;
2              
3 9     9   62 use strict;
  9         18  
  9         299  
4 9     9   46 use warnings;
  9         22  
  9         271  
5              
6 9     9   54 use base qw/File::Assets::Filter::Minifier/;
  9         16  
  9         1628  
7 9     9   64 use File::Assets::Carp;
  9         20  
  9         82  
8              
9             my %minifier_package;
10             sub _minifier_package {
11 3     3   5 my $class = shift;
12 3   33     17 return $minifier_package{$class} ||= do {
13 3         10 my $package = substr $class, length qq/File::Assets::Filter::Minifier::/;
14             # JavaScript
15             # JavaScript::XS
16             # CSS
17             # CSS::XS
18 3         13 my @package = split m/::/, $package;
19 3         17 join qw/::/, (shift @package), qw/Minifier/, @package;
20             };
21             }
22              
23             my %minifier_package_is_available;
24             sub _minifier_package_is_available {
25 4     4   14 my $class = shift;
26 4 100       21 return $minifier_package_is_available{$class} if exists $minifier_package_is_available{$class};
27 3         27 my $package = $class->_minifier_package;
28 3         267 return $minifier_package_is_available{$class} = eval "require $package;";
29             }
30              
31             sub new {
32 2     2 0 5 my $class = shift;
33 2 50       15 croak "You need to install ", $class->_minifier_package, " to use this filter: $class" unless $class->_minifier_package_is_available;
34 2         21 return $class->SUPER::new(@_);
35             }
36              
37             1;