ZofCMS/Plugin/JavaScriptMinifier.pm

filter: Statementstmt 50.0% 14 / 28 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 36.0% 18 / 50 CC 7 SCAR 34.3
CC
7
Cov
34%
_do
56.0
_key
2.0
_defaults
2.0
CRAP 30.8
« ZofCMS/Plugin/CSSMinifier.pm ↑ Summary ZofCMS/Plugin/GoogleCalculator.pm »
1 package App::ZofCMS::Plugin::JavaScriptMinifier;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use JavaScript::Minifier (qw/minify/);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use base 'App::ZofCMS::Plugin::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub _key { 'plug_js_minifier' }
Subroutine _key: not called CC=1 SCAR=6.9
12 0 ▶sub _defaults {
Subroutine _defaults: not called CC=1 SCAR=6.9
13 0 auto_output => 1,
14 cache => 1,
15 file => undef,
16 }
17 0 ▶sub _do {
Subroutine _do: not called CC=7 SCAR=40.3
18 0 my ( $self, $conf, $t ) = @_;
19  
20 return
21 unless defined $conf->{file}
22 0 ▶ and length $conf->{file};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"file"} and length $conf->{"file"} 0 0 0
Condition0%0/3
defined $conf->{"file"} and length $conf->{"file"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conf->{"file"} and length $conf->{"file"}
defined $conf->{"file"} length $conf->{"file"}
Truth table0%0/3
A and B
A= defined $conf->{"file"}B= length $conf->{"file"}
ABresult
0X0
100
111
23  
24 -e $conf->{file}
25 0 ▶ or die "$conf->{file} was not found";
Branch: 1 branch
BranchTrueFalseTotal
-e $conf->{"file"} or die qq[$conf->{"file"} was not found] 0 0 0
26  
27 open my $fh, '<', $conf->{file}
28 0 ▶ or die "$conf->{file} could not be opened for reading: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $conf->{"file"} or die qq[$conf->{"file"} could not be opened for reading: $!] 0 0 0
29  
30 0 my $js = minify( input => $fh );
31  
32 0 ▶ if ( $conf->{auto_output} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'auto_output'}) { } 0 0 0
33 0 ▶ if ( $conf->{cache} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"cache"}) 0 0 0
34 0 print "Expires: Fri, 29 Oct 2038 14:19:41 GMT\n"
35 }
36 0 print "Content-type: text/javascript\n\n";
37 0 print $js;
38 0 exit;
39 }
40 else {
41 0 $t->{t}{plug_js_minifier} = $js;
42 }
43 }
44 1 1;
45 __END__
« ZofCMS/Plugin/CSSMinifier.pm ↑ Summary ZofCMS/Plugin/GoogleCalculator.pm »