| 1 | package Mojolicious::Plugin::AssetPack::Pipe::HTML; | ||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Mojolicious::Plugin::AssetPack::Util qw(diag DEBUG); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use HTML::Packer; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||
| 6 | 1 | my $packer = HTML::Packer->init(); | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | has config => sub { my $self = shift; my $config = $self->assetpack->config || $self->assetpack->config({}); $config->{HTML} ||= {} }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
Condition40%2/5
$self->assetpack->config || $self->assetpack->config({})
$config->{"HTML"} ||= {}
MC/DC0%0/2
$self->assetpack->config || $self->assetpack->config({})
$self->assetpack->config
$self->assetpack->config({})
MC/DC0%0/1
$config->{"HTML"} ||= {}
$config->{"HTML"}
Truth table33%1/3
A || B
A= $self->assetpack->configB= $self->assetpack->config({})
Truth table50%1/2
A
A= $config->{"HTML"}
| |||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | has minify_opts => sub { {remove_comments => 1, remove_newlines => 0, no_compress_comment => 1, html5 => 1, %{shift->config->{minify_opts} ||= {}}, } };# do_javascript => 'clean', do_stylesheet => 'minify' , | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Condition50%1/2
+(shift())->config->{"minify_opts"} ||= {}
MC/DC0%0/1
+(shift())->config->{"minify_opts"} ||= {}
+(shift())->config->{"minify_opts"}
Truth table50%1/2
A
A= +(shift())->config->{"minify_opts"}
| |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | sub process { | ||||||||||||||||||||||||||||
|
Subroutine
process: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 12 | 2 | my ($self, $assets) = @_; | |||||||||||||||||||||||||||||
| 13 | 2 | my $store = $self->assetpack->store; | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | return unless $self->assetpack->minify;# skip development | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | 2 | my $content; | |||||||||||||||||||||||||||||
| 18 | return $assets->each( | ||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||
| 20 | 4 | my ($asset, $index) = @_; | |||||||||||||||||||||||||||||
| 21 | 4 | my $attrs = $asset->TO_JSON; | |||||||||||||||||||||||||||||
| 22 | 4 | $attrs->{key} = 'html-min'; | |||||||||||||||||||||||||||||
| 23 | 4 | $attrs->{minified} = 1; | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||
| 25 | #~ | ||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||
| 27 | return | ||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | if $asset->format ne 'html' || $asset->minified; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$asset->format ne "html" or $asset->minified
MC/DC50%1/2
$asset->format ne "html" or $asset->minified
$asset->format ne "html"
$asset->minified
Truth table66%2/3
A or B
A= $asset->format ne "html"B= $asset->minified
| |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||
| 30 | 2 | DEBUG && diag "Process HTML: [%s]", $asset->url;#$self->assetpack->app->dumper($asset) | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | ($content = $store->load($attrs)) && return $asset->content($content)->minified(1); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | length($content = $asset->content) || return; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||
| 35 | 2 | DEBUG && diag "Minify asset=[%s] with checksum=[%s] and minify_opts=[@{[ %{$self->minify_opts} ]}]", $asset->url, $asset->checksum, ; | |||||||||||||||||||||||||||||
| 36 | 2 | $packer->minify(\$content, $self->minify_opts); | |||||||||||||||||||||||||||||
| 37 | 2 | $asset->content($store->save(\$content, $attrs))->minified(1); | |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||
| 39 | 2 | ); | |||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||
| 42 | 1 | 1; | |||||||||||||||||||||||||||||