AssetPack/Pipe/Css.pm

filter: Statementstmt 100% 22 / 22 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 86.8% 33 / 38 CC 5 SCAR 10.3
CC
5
Cov
90%
__ANON__
4.1
process
2.0
BEGIN
1.0
CRAP 2.8
« AssetPack/Util.pm ↑ Summary AssetPack/Asset/Null.pm »
1 package Mojolicious::Plugin::AssetPack::Pipe::Css;
2 10 ▶use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 10 ▶use Mojolicious::Plugin::AssetPack::Util qw(diag load_module DEBUG);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶sub process {
Subroutine process: called CC=2 SCAR=7.0
Pod documented
7 15 my ($self, $assets) = @_;
8 15 my $store = $self->assetpack->store;
9 15 my $file;
10  
11 15 ▶ return unless $self->assetpack->minify;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->assetpack->minify 12 3 15
12 6 ▶ return $assets->each(sub {
Subroutine __ANON__: called CC=4 SCAR=14.1
13 6 my ($asset, $index) = @_;
14 6 my $attrs = $asset->TO_JSON;
15 6 $attrs->{key} = 'css-min';
16 6 $attrs->{minified} = 1;
17 6 ▶ return if $asset->format ne 'css' or $asset->minified;
Branch: 1 branch
BranchTrueFalseTotal
if $asset->format ne "css" or $asset->minified 0 6 6
Condition33%1/3
$asset->format ne "css" or $asset->minified
l!l&&r!l&&!r
006
MC/DC0%0/2
$asset->format ne "css" or $asset->minified
$asset->format ne "css" $asset->minified
Truth table33%1/3
A or B
A= $asset->format ne "css"B= $asset->minified
ABresult
1X1
011
000
18 6 ▶ return $asset->content($file)->minified(1) if $file = $store->load($attrs);
Branch: 1 branch
BranchTrueFalseTotal
if $file = $store->load($attrs) 3 3 6
19 3 load_module 'CSS::Minifier::XS';
20 3 diag 'Minify "%s" with checksum %s.', $asset->url, $asset->checksum if DEBUG;
21 3 my $css = CSS::Minifier::XS::minify($asset->content);
22 3 $asset->content($store->save(\$css, $attrs))->minified(1);
23 3 });
24 }
25  
26 10 1;
27  
28 =encoding utf8
29  
30 =head1 NAME
31  
32 Mojolicious::Plugin::AssetPack::Pipe::Css - Minify CSS
33  
34 =head1 DESCRIPTION
35  
36 L<Mojolicious::Plugin::AssetPack::Pipe::Css> will minify your "css" assets
37 if L<Mojolicious::Plugin::AssetPack/minify> is true and the asset is not
38 already minified.
39  
40 This module requires the optional module L<CSS::Minifier::XS> to minify.
41  
42 =head1 METHODS
43  
44 =head2 process
45  
46 See L<Mojolicious::Plugin::AssetPack::Pipe/process>.
47  
48 =head1 SEE ALSO
49  
50 L<Mojolicious::Plugin::AssetPack>.
51  
52 =cut
« AssetPack/Util.pm ↑ Summary AssetPack/Asset/Null.pm »