line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Assets::Cache; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
133
|
use strict; |
|
24
|
|
|
|
|
65
|
|
|
24
|
|
|
|
|
756
|
|
4
|
24
|
|
|
24
|
|
122
|
use warnings; |
|
24
|
|
|
|
|
52
|
|
|
24
|
|
|
|
|
853
|
|
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
118
|
use Object::Tiny qw/_content_registry/; |
|
24
|
|
|
|
|
47
|
|
|
24
|
|
|
|
|
122
|
|
7
|
24
|
|
|
24
|
|
3502
|
use File::Assets::Carp; |
|
24
|
|
|
|
|
49
|
|
|
24
|
|
|
|
|
202
|
|
8
|
|
|
|
|
|
|
|
9
|
24
|
|
|
24
|
|
3965
|
use File::Assets; |
|
24
|
|
|
|
|
47
|
|
|
24
|
|
|
|
|
198
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %cache; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
41
|
|
|
41
|
0
|
89
|
my $class = shift; |
15
|
41
|
|
|
|
|
160
|
local %_ = @_; |
16
|
|
|
|
|
|
|
|
17
|
41
|
|
|
|
|
119
|
my $name = $_{name}; |
18
|
41
|
50
|
|
|
|
6104
|
if (defined $name) { |
19
|
41
|
50
|
|
|
|
238
|
if (ref $name eq "SCALAR") { |
|
|
50
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
$name = $$name; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif ($name eq 1) { |
23
|
41
|
|
|
|
|
92
|
$name = "__File::Assets::Cache_cache__"; |
24
|
|
|
|
|
|
|
} |
25
|
41
|
100
|
|
|
|
274
|
return $cache{$name} if $cache{$name} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
22
|
|
|
|
|
78
|
my $self = bless {}, $class; |
29
|
|
|
|
|
|
|
|
30
|
22
|
|
|
|
|
166
|
$self->{_content_registry} = {}; |
31
|
|
|
|
|
|
|
|
32
|
22
|
50
|
|
|
|
124
|
$cache{$name} = $self if $name; |
33
|
|
|
|
|
|
|
|
34
|
22
|
|
|
|
|
95
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub assets { |
38
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
39
|
0
|
|
|
|
|
0
|
return File::Assets->new(cache => $self, @_); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub clear { |
43
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
44
|
0
|
|
|
|
|
0
|
$self->{_content_registry} = {}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub content { |
48
|
70
|
|
|
70
|
0
|
503
|
my $self = shift; |
49
|
70
|
|
|
|
|
101
|
my $file = shift; |
50
|
70
|
50
|
|
|
|
178
|
croak "Wasn't given a file" unless $file; |
51
|
70
|
|
66
|
|
|
1984
|
my $content = $self->_content_registry->{$file} ||= File::Assets::Asset::Content->new($file); |
52
|
70
|
|
|
|
|
1014
|
$content->refresh; |
53
|
70
|
|
|
|
|
406
|
return $content; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |