| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
29
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
59
|
|
|
2
|
|
|
|
|
|
|
package WebService::Libris::FileCache; |
|
3
|
1
|
|
|
1
|
|
8
|
use Mojo::Base -base; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
4
|
1
|
|
|
1
|
|
215
|
use Mojo::DOM; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
619
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'directory'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
|
9
|
1
|
|
|
1
|
1
|
3
|
my $class = shift; |
|
10
|
1
|
|
|
|
|
5
|
my $self = bless {@_}, $class; |
|
11
|
1
|
|
|
|
|
4
|
$self->_init; |
|
12
|
1
|
|
|
|
|
6
|
$self |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _init { |
|
16
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
|
17
|
1
|
|
|
|
|
29
|
my $d = $self->directory; |
|
18
|
1
|
50
|
|
|
|
43
|
unless (-d $d) { |
|
19
|
0
|
|
|
|
|
0
|
require File::Path; |
|
20
|
0
|
|
|
|
|
0
|
File::Path::make_path($d) |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _filename { |
|
25
|
3
|
|
|
3
|
|
5
|
my ($self, $key) = @_; |
|
26
|
3
|
|
|
|
|
15
|
$key =~ s{/}{_}g; |
|
27
|
3
|
|
|
|
|
69
|
$self->directory . $key . '.xml' |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get { |
|
31
|
3
|
|
|
3
|
0
|
28
|
my ($self, $key) = @_; |
|
32
|
3
|
|
|
|
|
9
|
my $filename = $self->_filename($key); |
|
33
|
3
|
50
|
|
|
|
228
|
return undef unless open my $h, '<:encoding(UTF-8)', $filename; |
|
34
|
3
|
|
|
|
|
284
|
my $contents = do { local $/; <$h> }; |
|
|
3
|
|
|
|
|
13
|
|
|
|
3
|
|
|
|
|
158
|
|
|
35
|
3
|
50
|
|
|
|
671
|
return undef unless length $contents; |
|
36
|
3
|
|
|
|
|
27
|
Mojo::DOM->new->xml(1)->parse($contents); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub set { |
|
40
|
0
|
|
|
0
|
0
|
|
my ($self, $key, $value) = @_; |
|
41
|
0
|
|
|
|
|
|
my $filename = $self->_filename($key); |
|
42
|
0
|
0
|
|
|
|
|
open my $h, '>', $filename or die "Can't open file '$filename' for writing: $!"; |
|
43
|
0
|
|
|
|
|
|
print { $h } $value->to_xml; |
|
|
0
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
close $h; |
|
45
|
0
|
|
|
|
|
|
$value; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |