line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::AssetPack::Preprocessor; |
2
|
3
|
|
|
3
|
|
11
|
use Mojo::Base -base; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
18
|
|
3
|
3
|
|
|
3
|
|
732
|
use Mojo::JSON 'encode_json'; |
|
3
|
|
|
|
|
13050
|
|
|
3
|
|
|
|
|
138
|
|
4
|
3
|
|
|
3
|
|
13
|
use Mojo::Util (); |
|
3
|
|
|
|
|
2
|
|
|
3
|
|
|
|
|
31
|
|
5
|
3
|
|
|
3
|
|
12
|
use Cwd (); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
42
|
|
6
|
3
|
|
|
3
|
|
614
|
use POSIX (); |
|
3
|
|
|
|
|
4665
|
|
|
3
|
|
|
|
|
90
|
|
7
|
3
|
|
50
|
3
|
|
11
|
use constant DEBUG => $ENV{MOJO_ASSETPACK_DEBUG} || 0; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
358
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
17
|
use overload (q(&{}) => sub { shift->can('process') }, fallback => 1,); |
|
3
|
|
|
1
|
|
4
|
|
|
3
|
|
|
|
|
41
|
|
|
1
|
|
|
|
|
13
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has cwd => sub {Cwd::getcwd}; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
1
|
0
|
sub can_process {1} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub checksum { |
16
|
3
|
|
|
3
|
1
|
4
|
my ($self, $text, $path) = @_; |
17
|
3
|
|
|
|
|
23
|
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 |