line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Assets::Filter::Concat; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
9376
|
use strict; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
455
|
|
4
|
10
|
|
|
10
|
|
54
|
use warnings; |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
432
|
|
5
|
|
|
|
|
|
|
|
6
|
10
|
|
|
10
|
|
70
|
use base qw/File::Assets::Filter::Collect/; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
1967
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub signature { |
9
|
74
|
|
|
74
|
0
|
582
|
return "concat"; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub build_content { |
13
|
23
|
|
|
23
|
0
|
36
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
23
|
|
|
|
|
95
|
my $matched = $self->matched; |
16
|
|
|
|
|
|
|
|
17
|
23
|
|
|
|
|
47
|
my $content = ""; |
18
|
23
|
|
|
|
|
73
|
for my $match (@$matched) { |
19
|
45
|
|
|
|
|
70
|
$content .= ${ $match->{asset}->content }; |
|
45
|
|
|
|
|
192
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
23
|
|
|
|
|
87
|
return \$content; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Digest; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use base qw/File::Assets::Filter/; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub post_process { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
my $assets = shift; |
36
|
|
|
|
|
|
|
my $matched = shift; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return unless @$matched; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return if 1 == @$matched; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $top_match = $matched->[0]; |
43
|
|
|
|
|
|
|
my $top_asset = $top_match->{asset}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
for my $match (reverse @$matched) { |
46
|
|
|
|
|
|
|
my $rank = $match->{rank}; |
47
|
|
|
|
|
|
|
splice @$assets, $rank, 1, (); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $content = ""; |
51
|
|
|
|
|
|
|
for my $match (@$matched) { |
52
|
|
|
|
|
|
|
$content .= ${ $match->{asset}->content }; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $type = $top_asset->type; |
56
|
|
|
|
|
|
|
my $path; |
57
|
|
|
|
|
|
|
if ($self->package) { |
58
|
|
|
|
|
|
|
$path = $self->package->path; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
if (! defined $path) { |
61
|
|
|
|
|
|
|
my $digest = Digest->new("MD5"); |
62
|
|
|
|
|
|
|
$digest->add($content); |
63
|
|
|
|
|
|
|
$path = $digest->hexdigest; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
$path .= "." . ($type->extensions)[0] if $path =~ m/(?:^|\/)[^\.]+/; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $asset = File::Assets->_parse_asset_by_path( |
68
|
|
|
|
|
|
|
path => $path, |
69
|
|
|
|
|
|
|
type => $type, |
70
|
|
|
|
|
|
|
base => $top_asset->resource->base, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $file = $asset->file; |
74
|
|
|
|
|
|
|
my $dir = $file->parent; |
75
|
|
|
|
|
|
|
$dir->mkpath unless -d $dir; |
76
|
|
|
|
|
|
|
$file->openw->print($content); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
splice @$assets, $top_match->{rank}, 0, $asset; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |