« blib/lib/Mojolicious/Plugin/AssetPack/Pipe/VueTemplateCompiler.pm
↑ Summary
lib/Mojolicious/Plugin/AssetPack/Pipe/CombineFile.pm »
| 1 | package Mojolicious::Plugin::AssetPack::Pipe::JavaScriptPacker; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Mojolicious::Plugin::AssetPack::Util qw(diag load_module DEBUG); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use JavaScript::Packer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | my $packer = JavaScript::Packer->init(); | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 0 | ▶ | has config => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 9 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 10 | 0 | ▶ | my $config = $self->assetpack->config || $self->assetpack->config({}); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->assetpack->config || $self->assetpack->config({})
MC/DC0%0/2
$self->assetpack->config || $self->assetpack->config({})
$self->assetpack->config
$self->assetpack->config({})
Truth table0%0/3
A || B
A= $self->assetpack->configB= $self->assetpack->config({})
| |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | $config->{JavaScriptPacker} ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$config->{"JavaScriptPacker"} ||= {}
MC/DC0%0/1
$config->{"JavaScriptPacker"} ||= {}
$config->{"JavaScriptPacker"}
Truth table0%0/2
A
A= $config->{"JavaScriptPacker"}
| |||||||||||||||||||||||||||||
| 12 | 2 | }; | |||||||||||||||||||||||||||
| 13 | 0 | ▶ | has minify_opts => sub { { %{shift->config->{minify_opts} ||= {}}, } };# | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.6
Condition0%0/2
+(shift())->config->{"minify_opts"} ||= {}
MC/DC0%0/1
+(shift())->config->{"minify_opts"} ||= {}
+(shift())->config->{"minify_opts"}
Truth table0%0/2
A
A= +(shift())->config->{"minify_opts"}
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=2 SCAR=8.7
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 4 | my ($self, $assets) = @_; | |||||||||||||||||||||||||||
| 17 | 4 | my $store = $self->assetpack->store; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | return unless $self->assetpack->minify; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | my $file; | |||||||||||||||||||||||||||
| 22 | return $assets->each( | ||||||||||||||||||||||||||||
| 23 | 2 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=24.2
| |||||||||||||||||||||||||||||
| 24 | 2 | my ($asset, $index) = @_; | |||||||||||||||||||||||||||
| 25 | 2 | my $attrs = $asset->TO_JSON; | |||||||||||||||||||||||||||
| 26 | 2 | $attrs->{key} = 'js-min'; | |||||||||||||||||||||||||||
| 27 | 2 | $attrs->{minified} = 1; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 2 | ▶ | return if $asset->format ne 'js' || $asset->minified; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$asset->format ne "js" or $asset->minified
MC/DC0%0/2
$asset->format ne "js" or $asset->minified
$asset->format ne "js"
$asset->minified
Truth table33%1/3
A or B
A= $asset->format ne "js"B= $asset->minified
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | return $asset->content($file)->minified(1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | if $file = $store->load($attrs); | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | return unless length(my $content = $asset->content); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | DEBUG && diag "Minify javascript=[%s] with checksum=[%s] and minify_opts=[@{[ %{$self->minify_opts} ]}]", $asset->url, $asset->checksum, ; | |||||||||||||||||||||||||||
| 34 | 0 | $packer->minify(\$content, $self->minify_opts); | |||||||||||||||||||||||||||
| 35 | 0 | $asset->content($store->save(\$content, $attrs))->minified(1); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 2 | ); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2 | 1; | |||||||||||||||||||||||||||