line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::AssetPack::Preprocessor; |
2
|
1
|
|
|
1
|
|
5
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
701
|
use Mojo::JSON 'encode_json'; |
|
1
|
|
|
|
|
19552
|
|
|
1
|
|
|
|
|
120
|
|
4
|
1
|
|
|
1
|
|
13
|
use Mojo::Util (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
4
|
use Cwd (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
1019
|
use POSIX (); |
|
1
|
|
|
|
|
7869
|
|
|
1
|
|
|
|
|
64
|
|
7
|
1
|
|
50
|
1
|
|
9
|
use constant DEBUG => $ENV{MOJO_ASSETPACK_DEBUG} || 0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
130
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use overload (q(&{}) => sub { shift->can('process') }, fallback => 1,); |
|
1
|
|
|
0
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has cwd => sub {Cwd::getcwd}; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
1
|
|
sub can_process {1} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub checksum { |
16
|
0
|
|
|
0
|
1
|
|
my ($self, $text, $path) = @_; |
17
|
0
|
|
|
|
|
|
Mojo::Util::md5_sum($$text); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub process { |
21
|
0
|
|
|
0
|
1
|
|
my ($self, $assetpack, $text, $path) = @_; |
22
|
0
|
0
|
|
|
|
|
die "No pre-processor defined for $path" unless $self->{processor}; |
23
|
0
|
|
|
|
|
|
$self->{processor}->($assetpack, $text, $path); |
24
|
0
|
|
|
|
|
|
$self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _run { |
28
|
0
|
|
|
0
|
|
|
my ($self, $cmd, $in, $out) = @_; |
29
|
0
|
|
|
|
|
|
my $err = ''; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
local ($!, $?) = (0, -1); |
32
|
0
|
|
|
|
|
|
IPC::Run3::run3($cmd, $in, $out, \$err, {return_if_system_error => 1}); |
33
|
0
|
0
|
0
|
|
|
|
$! = 0 if !$? and $! == POSIX::ENOTTY; |
34
|
0
|
|
|
|
|
|
warn "[AssetPack] @$cmd \$?=$? \$!=$! $err\n" if DEBUG; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
return $self unless $?; |
37
|
0
|
0
|
|
|
|
|
die sprintf "Cannot execute '%s'. See %s\n", $cmd->[0], $self->_url if $! == 2; |
38
|
0
|
|
|
|
|
|
die sprintf "Failed to run '%s' (\$?=%s, \$!=%s) %s", join(' ', @$cmd), $? >> 8, |
39
|
|
|
|
|
|
|
int($!), $err; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
|
|
sub _url {'https://metacpan.org/pod/Mojolicious::Plugin::AssetPack::Preprocessors'} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding utf8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Mojolicious::Plugin::AssetPack::Preprocessor - DEPRECATED |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L will be DEPRECATED. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 cwd |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 can_process |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 checksum |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 process |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |