line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::AssetLib::OutputEngine::String; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
13224003
|
use Method::Signatures; |
|
6
|
|
|
|
|
51926
|
|
|
6
|
|
|
|
|
39
|
|
4
|
6
|
|
|
6
|
|
2593
|
use Moose; |
|
6
|
|
|
|
|
284266
|
|
|
6
|
|
|
|
|
44
|
|
5
|
6
|
|
|
6
|
|
26047
|
use Carp; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
382
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
533
|
use Web::AssetLib::Util; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
87
|
|
8
|
6
|
|
|
6
|
|
420
|
use Web::AssetLib::Output::Link; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
84
|
|
9
|
6
|
|
|
6
|
|
2409
|
use Web::AssetLib::Output::Content; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
109
|
|
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
113
|
use v5.14; |
|
6
|
|
|
|
|
17
|
|
12
|
6
|
|
|
6
|
|
25
|
no if $] >= 5.018, warnings => "experimental"; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
47
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'Web::AssetLib::OutputEngine'; |
15
|
|
|
|
|
|
|
|
16
|
6
|
50
|
|
6
|
|
18226
|
method export (:$assets!, :$minifier?) { |
|
1
|
50
|
|
1
|
|
3
|
|
|
1
|
50
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
196
|
|
17
|
1
|
|
|
|
|
6
|
my $types = {}; |
18
|
1
|
|
|
|
|
3
|
my $output = []; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# categorize into type groups, and seperate concatenated |
21
|
|
|
|
|
|
|
# assets from those that stand alone |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
9
|
foreach my $asset ( sort { $a->rank <=> $b->rank } @$assets ) { |
|
1
|
|
|
|
|
34
|
|
24
|
2
|
50
|
|
|
|
52
|
if ( $asset->isPassthru ) { |
25
|
0
|
|
|
|
|
0
|
push @$output, |
26
|
|
|
|
|
|
|
Web::AssetLib::Output::Link->new( |
27
|
|
|
|
|
|
|
type => $asset->type, |
28
|
|
|
|
|
|
|
src => $asset->link_path |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
2
|
|
|
|
|
9
|
for ( $asset->type ) { |
33
|
2
|
|
|
|
|
12
|
when (/css|js/) { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# should concatenate |
36
|
|
|
|
|
|
|
$$types{ $asset->type }{_CONCAT_} |
37
|
2
|
|
|
|
|
5
|
.= $asset->contents . "\n\r\n\r"; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
0
|
default { |
40
|
0
|
|
|
|
|
0
|
$$types{ $asset->type }{ $asset->digest } |
41
|
|
|
|
|
|
|
= $asset->contents; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
7
|
foreach my $type ( keys %$types ) { |
48
|
2
|
|
|
|
|
28
|
foreach my $id ( keys %{ $$types{$type} } ) { |
|
2
|
|
|
|
|
8
|
|
49
|
2
|
|
|
|
|
5
|
my $output_contents = $$types{$type}{$id}; |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
10
|
if ($minifier) { |
52
|
2
|
|
|
|
|
11
|
$output_contents = $minifier->minify( |
53
|
|
|
|
|
|
|
contents => $output_contents, |
54
|
|
|
|
|
|
|
type => $type |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
104
|
push @$output, |
59
|
|
|
|
|
|
|
Web::AssetLib::Output::Content->new( |
60
|
|
|
|
|
|
|
type => $type, |
61
|
|
|
|
|
|
|
content => $output_contents |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
289
|
return $output; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
6
|
|
|
6
|
|
2503
|
no Moose; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
39
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Web::AssetLib::OutputEngine::String - allows exporting an asset or bundle to a string |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SYNOPSIS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $library = My::AssetLib::Library->new( |
83
|
|
|
|
|
|
|
output_engines => [ |
84
|
|
|
|
|
|
|
Web::AssetLib::OutputEngine::String->new() |
85
|
|
|
|
|
|
|
] |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 USAGE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Include in your library's output engine list. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L<Web::AssetLib::OutputEngine> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Ryan Lang <rlang@cpan.org> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |