line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::AssetLib::OutputEngine; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
6461662
|
use Method::Signatures; |
|
8
|
|
|
|
|
48945
|
|
|
8
|
|
|
|
|
49
|
|
4
|
8
|
|
|
8
|
|
3161
|
use Moose; |
|
8
|
|
|
|
|
281568
|
|
|
8
|
|
|
|
|
48
|
|
5
|
8
|
|
|
8
|
|
36259
|
use HTML::Element; |
|
8
|
|
|
|
|
19427
|
|
|
8
|
|
|
|
|
69
|
|
6
|
8
|
|
|
8
|
|
3557
|
use Digest; |
|
8
|
|
|
|
|
3541
|
|
|
8
|
|
|
|
|
148
|
|
7
|
8
|
|
|
8
|
|
3549
|
use Encode qw(encode encode_utf8); |
|
8
|
|
|
|
|
55316
|
|
|
8
|
|
|
|
|
516
|
|
8
|
8
|
|
|
8
|
|
41
|
use Carp; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
351
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
66
|
use v5.14; |
|
8
|
|
|
|
|
21
|
|
11
|
8
|
|
|
8
|
|
28
|
no if $] >= 5.018, warnings => "experimental"; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
57
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Web::AssetLib::Role::Logger'; |
14
|
|
|
|
|
|
|
|
15
|
8
|
50
|
|
8
|
|
114393
|
method _export (:$bundle?, :$asset?, :$minifier?) { |
|
5
|
50
|
|
5
|
|
11
|
|
|
5
|
|
|
|
|
31
|
|
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
26
|
|
|
5
|
|
|
|
|
21
|
|
16
|
5
|
50
|
33
|
|
|
58
|
if ( $asset && !$bundle ) { |
|
|
50
|
33
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
return $self->_exportAsset( |
18
|
|
|
|
|
|
|
asset => $asset, |
19
|
|
|
|
|
|
|
minifier => $minifier |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif ( $bundle && !$asset ) { |
23
|
5
|
|
|
|
|
37
|
return $self->_exportBundle( |
24
|
|
|
|
|
|
|
bundle => $bundle, |
25
|
|
|
|
|
|
|
minifier => $minifier |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif ( $bundle && $asset ) { |
29
|
0
|
|
|
|
|
0
|
croak "cannot provide both bundle and asset - dont know what to do"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
0
|
|
|
|
|
0
|
croak "either asset or bundle must be provided"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
8
|
50
|
|
8
|
|
20324
|
method _exportBundle (:$bundle!,:$minifier?) { |
|
5
|
50
|
|
5
|
|
14
|
|
|
5
|
50
|
|
|
|
23
|
|
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
185
|
|
37
|
5
|
|
|
|
|
170
|
my $output = $self->export( |
38
|
|
|
|
|
|
|
assets => $bundle->assets, |
39
|
|
|
|
|
|
|
minifier => $minifier |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
204
|
$bundle->output($output); |
43
|
5
|
|
|
|
|
61
|
return $bundle; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
8
|
0
|
|
8
|
|
18887
|
method _exportAsset (:$asset!,:$minifier?) { |
|
0
|
0
|
|
0
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
47
|
0
|
|
|
|
|
0
|
my $output = $self->export( |
48
|
|
|
|
|
|
|
assets => [$asset], |
49
|
|
|
|
|
|
|
minifier => $minifier |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
$asset->output($output); |
53
|
0
|
|
|
|
|
0
|
return $asset; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
8
|
50
|
|
8
|
|
11635
|
method generateDigest ($contents) { |
|
8
|
50
|
|
8
|
|
14
|
|
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
20
|
|
57
|
8
|
|
|
|
|
62
|
my $digest = Digest->new("MD5"); |
58
|
8
|
|
|
|
|
321
|
$digest->add( encode_utf8($contents) ); |
59
|
8
|
|
|
|
|
1589
|
return $digest->hexdigest; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
8
|
|
|
8
|
|
985
|
no Moose; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
58
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Web::AssetLib::OutputEngine - a base class for writing your own Output Engine |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SYNOPSIS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
package My::Library::OutputEngine; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use Method::Signatures; |
78
|
|
|
|
|
|
|
use Moose; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
extends 'Web::AssetLib::OutputEngine'; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
method export ( :$assets!, :$minifier? ) { |
83
|
|
|
|
|
|
|
# see Web::AssetLib::OutputEngine::LocalFile for examples |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 USAGE |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
If you have a need for a special file output scenario, you can simply extend this |
89
|
|
|
|
|
|
|
class, and it will plug in to the rest of the Web::AssetLib pipeline. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The only requirement is that your Output Engine implements the |
92
|
|
|
|
|
|
|
L<export> method, which returns a properly-formatted HTML tag as a string. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 IMPLEMENTATION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 export |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Process the arrayref of L<Web::AssetLib::Asset> objects, and export a file with type |
99
|
|
|
|
|
|
|
C<< $type >>. If C<< $mininfier >> is provided (will be a |
100
|
|
|
|
|
|
|
L<Web::AssetLib::MinifierEngine> instance), then it is your responsibility to |
101
|
|
|
|
|
|
|
call L<< $minifier->minify()|Web::AssetLib::MinifierEngine/"minify( :$contents!, :$type! )" >>. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
export() should return a properly-formatted HTML tag as a string. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
For help with common ouput operations, see the provided methods below. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 METHODS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 generateDigest |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Pass in an arrayref of L<Web::AssetLib::Asset> objects, and returns |
112
|
|
|
|
|
|
|
a string of the concatenated contents, and an MD5 digest string. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SEE ALSO |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L<Web::AssetLib::OutputEngine::LocalFile> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Ryan Lang <rlang@cpan.org> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |