| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::AssetPack::Util; |
|
2
|
38
|
|
|
38
|
|
12595925
|
use Mojo::Base 'Exporter'; |
|
|
38
|
|
|
|
|
101
|
|
|
|
38
|
|
|
|
|
317
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
38
|
|
|
38
|
|
12611
|
use Carp 'confess'; |
|
|
38
|
|
|
|
|
89
|
|
|
|
38
|
|
|
|
|
2379
|
|
|
5
|
38
|
|
|
38
|
|
342
|
use Mojo::Util; |
|
|
38
|
|
|
|
|
90
|
|
|
|
38
|
|
|
|
|
2842
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
38
|
|
50
|
38
|
|
247
|
use constant DEBUG => $ENV{MOJO_ASSETPACK_DEBUG} || 0; |
|
|
38
|
|
|
|
|
143
|
|
|
|
38
|
|
|
|
|
5017
|
|
|
8
|
38
|
|
50
|
38
|
|
280
|
use constant TESTING => $ENV{HARNESS_IS_VERBOSE} || 0; |
|
|
38
|
|
|
|
|
92
|
|
|
|
38
|
|
|
|
|
44447
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(checksum diag dumper has_ro load_module $CWD DEBUG); |
|
11
|
|
|
|
|
|
|
our $SUM_LEN = 10; |
|
12
|
|
|
|
|
|
|
our ($TOPIC, %LOADED); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
tie our ($CWD), 'Mojolicious::Plugin::AssetPack::Util::_chdir' or die q(Can't tie $CWD); |
|
15
|
|
|
|
|
|
|
|
|
16
|
47
|
|
|
47
|
1
|
31985
|
sub checksum { substr Mojo::Util::sha1_sum($_[0]), 0, $SUM_LEN } |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub diag { |
|
19
|
2
|
100
|
|
2
|
1
|
1739
|
my $f = @_ > 1 ? shift : '%s'; |
|
20
|
2
|
|
|
|
|
5
|
my ($i, $pkg) = (0); |
|
21
|
2
|
50
|
|
|
|
12
|
while ($pkg = caller $i++) { $pkg =~ s!.*::(AssetPack::)Pipe::!$1! and last } |
|
|
2
|
|
|
|
|
12
|
|
|
22
|
2
|
50
|
|
|
|
9
|
$pkg = 'AssetPack' unless $pkg; |
|
23
|
2
|
50
|
|
|
|
35
|
warn sprintf "%s[%s%s] $f\n", TESTING ? "# " : "", $pkg, $TOPIC ? "/$TOPIC" : "", @_; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub dumper { |
|
27
|
0
|
|
|
0
|
1
|
0
|
Data::Dumper->new([@_])->Indent(0)->Sortkeys(1)->Terse(1)->Useqq(1)->Dump; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub has_ro { |
|
31
|
95
|
|
|
95
|
1
|
232401
|
my ($name, $builder) = @_; |
|
32
|
95
|
|
|
|
|
253
|
my $caller = caller; |
|
33
|
|
|
|
|
|
|
|
|
34
|
95
|
|
66
|
1
|
|
630
|
$builder ||= sub { confess qq("$name" is required in constructor') }; |
|
|
1
|
|
|
|
|
250
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Mojo::Util::monkey_patch( |
|
37
|
|
|
|
|
|
|
$caller => $name => sub { |
|
38
|
596
|
100
|
|
596
|
|
6099
|
confess qq("$name" is read-only") if @_ > 1; |
|
|
|
|
|
591
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
39
|
594
|
|
66
|
|
|
4263
|
$_[0]->{$name} //= $_[0]->$builder(); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
95
|
|
|
|
|
501
|
); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub load_module { |
|
45
|
36
|
|
|
41
|
1
|
96
|
my $module = shift; |
|
46
|
36
|
50
|
50
|
|
|
373
|
confess qq(Invalid module name "$module") if ($module || '') !~ /^\w(?:[\w:']*\w)?$/; |
|
47
|
36
|
50
|
66
|
|
|
3410
|
return $module if $LOADED{$module} ||= eval "require $module; 1"; |
|
48
|
0
|
|
|
|
|
0
|
confess qq(Could not load "$module": $@); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package Mojolicious::Plugin::AssetPack::Util::_chdir; |
|
52
|
38
|
|
|
38
|
|
359
|
use Cwd (); |
|
|
38
|
|
|
|
|
83
|
|
|
|
38
|
|
|
|
|
872
|
|
|
53
|
38
|
|
|
38
|
|
190
|
use File::Spec; |
|
|
38
|
|
|
|
|
80
|
|
|
|
38
|
|
|
|
|
11390
|
|
|
54
|
38
|
|
|
38
|
|
844
|
sub TIESCALAR { bless [Cwd::getcwd], $_[0] } |
|
55
|
3
|
|
|
3
|
|
1026
|
sub FETCH { $_[0]->[0] } |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub STORE { |
|
58
|
3
|
100
|
|
3
|
|
962
|
defined $_[1] or return; |
|
59
|
2
|
|
|
|
|
33
|
my $dir = File::Spec->rel2abs($_[1]); |
|
60
|
2
|
50
|
|
|
|
35
|
chdir $dir or die "chdir $dir: $!"; |
|
61
|
2
|
|
|
|
|
5
|
Mojolicious::Plugin::AssetPack::Util::diag("chdir $dir") if Mojolicious::Plugin::AssetPack::Util::DEBUG >= 3; |
|
62
|
2
|
|
|
|
|
10
|
$_[0]->[0] = $dir; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding utf8 |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Mojolicious::Plugin::AssetPack::Util - Utility functions for pipes |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L holds utility functions. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use Mojolicious::Plugin::AssetPack::Util; |
|
80
|
|
|
|
|
|
|
use Mojolicious::Plugin::AssetPack::Util qw(checksum diag DEBUG) |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 checksum |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$str = checksum $bytes; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Used to calculate checksum of C<$bytes>. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 diag |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
diag "some messsage"; |
|
93
|
|
|
|
|
|
|
diag "some %s", "messsage"; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Same as C, but with a prefix. It will also use C if |
|
96
|
|
|
|
|
|
|
more than one argument is given. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 dumper |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$str = dumper $any; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Dump a Perl data structure into a single line with L. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 has_ro |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Same as L, but creates a read-only attribute. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 load_module |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$module = load_module $module; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Used to load a C<$module>. Will confess on failure. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |