line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Web::AssetLib::InputEngine::Content; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
9722863
|
use Method::Signatures; |
|
6
|
|
|
|
|
49648
|
|
|
6
|
|
|
|
|
51
|
|
4
|
6
|
|
|
6
|
|
2855
|
use Moose; |
|
6
|
|
|
|
|
294407
|
|
|
6
|
|
|
|
|
38
|
|
5
|
6
|
|
|
6
|
|
26490
|
use Carp; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
366
|
|
6
|
6
|
|
|
6
|
|
24
|
use Digest::MD5 'md5_hex'; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
290
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Web::AssetLib::InputEngine'; |
9
|
|
|
|
|
|
|
|
10
|
6
|
0
|
|
6
|
|
102167
|
method load ($asset!) { |
|
0
|
0
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
croak sprintf( "%s requires 'content' asset input_arg", ref($self) ) |
12
|
0
|
0
|
|
|
|
|
unless $asset->input_args->{content}; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $contents = $asset->input_args->{content}; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
$contents =~ s/^(<script type="text\/javascript">|<script>)//g; |
17
|
0
|
|
|
|
|
|
$contents =~ s/<\/script>$//g; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $digest = md5_hex $contents; |
20
|
0
|
|
|
|
|
|
$self->addAssetToCache( $digest => $contents ); |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$self->storeAssetContents( |
23
|
|
|
|
|
|
|
asset => $asset, |
24
|
|
|
|
|
|
|
digest => $digest, |
25
|
|
|
|
|
|
|
contents => $contents |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
6
|
|
1415
|
no Moose; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
29
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding UTF-8 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Web::AssetLib::InputEngine::Content - allows importing an asset as a raw string |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $library = My::AssetLib::Library->new( |
43
|
|
|
|
|
|
|
input_engines => [ |
44
|
|
|
|
|
|
|
Web::AssetLib::InputEngine::Content->new() |
45
|
|
|
|
|
|
|
] |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $asset = Web::AssetLib::Asset->new( |
49
|
|
|
|
|
|
|
type => 'javascript', |
50
|
|
|
|
|
|
|
input_engine => 'Content', |
51
|
|
|
|
|
|
|
input_args => { content => "console.log('hello world');", } |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$library->compile( asset => $asset ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 USAGE |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
No configuration required. Simply instantiate, and include in your library's |
59
|
|
|
|
|
|
|
list of input engines. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Assets using the Content input engine must provide C<< content >> input arg. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SEE ALSO |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
L<Web::AssetLib::InputEngine> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
L<Web::AssetLib::InputEngine::RemoteFile> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
L<Web::AssetLib::InputEngine::LocalFile> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Ryan Lang <rlang@cpan.org> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |