line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Assets::Filter::Minifier; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
23319
|
use strict; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
364
|
|
4
|
9
|
|
|
9
|
|
56
|
use warnings; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
363
|
|
5
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
48
|
use base qw/File::Assets::Filter::Collect/; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
1136
|
|
7
|
9
|
|
|
9
|
|
53
|
use File::Assets::Carp; |
|
9
|
|
|
|
|
24
|
|
|
9
|
|
|
|
|
94
|
|
8
|
|
|
|
|
|
|
|
9
|
9
|
|
|
9
|
|
7502
|
use File::Assets::Filter::Minifier::CSS; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
214
|
|
10
|
9
|
|
|
9
|
|
8082
|
use File::Assets::Filter::Minifier::JavaScript; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
128
|
|
11
|
9
|
|
|
9
|
|
6849
|
use File::Assets::Filter::Minifier::CSS::XS; |
|
9
|
|
|
|
|
31
|
|
|
9
|
|
|
|
|
108
|
|
12
|
9
|
|
|
9
|
|
6977
|
use File::Assets::Filter::Minifier::JavaScript::XS; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
115
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub signature { |
15
|
15
|
|
|
15
|
0
|
2453
|
return "minifier"; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
8
|
|
|
8
|
0
|
22
|
my $class = shift; |
20
|
8
|
|
|
|
|
63
|
my $self = $class->SUPER::new(@_); |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
|
|
48
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub build_content { |
26
|
7
|
|
|
7
|
0
|
15
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
25
|
my $matched = $self->matched; |
29
|
7
|
|
|
|
|
29
|
my $output_asset = $self->output_asset; |
30
|
7
|
|
|
|
|
27
|
my $file = $output_asset->file; |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
126
|
my $input = ""; |
33
|
7
|
|
|
|
|
26
|
for my $match (@$matched) { |
34
|
17
|
|
|
|
|
31
|
my $asset = $match->{asset}; |
35
|
17
|
|
|
|
|
19
|
$input .= ${ $asset->content }; |
|
17
|
|
|
|
|
52
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
7
|
|
|
|
|
48
|
my $minifier = $self->minifier; |
39
|
7
|
|
|
|
|
13
|
my $output; |
40
|
7
|
|
|
|
|
34
|
$output = $minifier->($input); |
41
|
|
|
|
|
|
|
|
42
|
7
|
50
|
|
|
|
23055
|
$file->parent->mkpath unless -d $file->parent; |
43
|
7
|
|
|
|
|
442
|
$file->openw->print("$output\n"); |
44
|
|
|
|
|
|
|
|
45
|
7
|
|
|
|
|
2831
|
return undef; # We already put the content in the asset file, so we return undef here. |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub minifier { |
49
|
7
|
|
|
7
|
0
|
13
|
my $self = shift; |
50
|
7
|
|
33
|
|
|
32
|
return $self->stash->{minifier} ||= do { # Only kept around in the stash |
51
|
7
|
|
|
|
|
15
|
my $minifier; |
52
|
7
|
100
|
|
|
|
91
|
if ($minifier = $self->can(qw/minify/)) { |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
6
|
|
|
|
|
21
|
my $kind = $self->kind; |
56
|
6
|
100
|
|
|
|
37
|
if ($kind->extension eq "css") { |
|
|
50
|
|
|
|
|
|
57
|
3
|
|
|
|
|
40
|
$minifier = $self->_css_minifier; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
elsif ($kind->extension eq "js") { |
60
|
3
|
|
|
|
|
40
|
$minifier = $self->_js_minifier; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
0
|
|
|
|
|
0
|
croak "Don't know how to minify for type ", $kind->type->type, " (", $kind->kind, ")"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
7
|
|
|
|
|
30
|
$minifier; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _css_minifier { |
71
|
1
|
|
|
1
|
|
3
|
return \&File::Assets::Filter::Minifier::CSS::minify; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _js_minifier { |
75
|
1
|
|
|
1
|
|
4
|
return \&File::Assets::Filter::Minifier::JavaScript::minify; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |