line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1815
|
use 5.008008; |
|
3
|
|
|
|
|
8
|
|
2
|
3
|
|
|
3
|
|
12
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
52
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
124
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package portable::loader::TOML; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
13
|
use portable::lib; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
11
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $decoder; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init { |
15
|
3
|
|
|
3
|
0
|
5
|
my $me = shift; |
16
|
3
|
|
|
|
|
4
|
my ($loader) = @_; |
17
|
3
|
|
|
|
|
9
|
$loader->register_extension('portable.toml'); |
18
|
3
|
|
|
|
|
8
|
$loader->register_extension('portable'); |
19
|
3
|
|
|
|
|
4
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub parse { |
23
|
1
|
|
|
1
|
0
|
2
|
my $me = shift; |
24
|
1
|
|
|
|
|
2
|
my ($filename) = @_; |
25
|
1
|
|
|
|
|
345
|
require JSON::Eval; |
26
|
1
|
|
33
|
|
|
919
|
$decoder ||= JSON::Eval->new($me->_get_parser); |
27
|
1
|
|
|
|
|
32
|
my $tomltext = do { |
28
|
1
|
50
|
|
|
|
36
|
open my $fh, '<', $filename |
29
|
|
|
|
|
|
|
or die "Could not open $filename: $!"; |
30
|
1
|
|
|
|
|
5
|
local $/; |
31
|
1
|
|
|
|
|
27
|
<$fh>; |
32
|
|
|
|
|
|
|
}; |
33
|
1
|
|
|
|
|
7
|
$me->_munge_toml(\$tomltext); |
34
|
1
|
|
|
|
|
3
|
my $decoded = $decoder->decode($tomltext); |
35
|
1
|
|
|
|
|
7892
|
return ($filename => $decoded); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _munge_toml { |
39
|
1
|
|
|
1
|
|
2
|
my $ref = $_[1]; |
40
|
1
|
|
|
|
|
17
|
$$ref =~ s{ |
41
|
|
|
|
|
|
|
\{\{\{ |
42
|
|
|
|
|
|
|
(.*?) |
43
|
|
|
|
|
|
|
\}\}\} |
44
|
|
|
|
|
|
|
}{ \{\"\$eval\"=''' sub \{ $1 \} ''' \} }xsgo; |
45
|
1
|
|
|
|
|
3
|
return; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# create method alias |
49
|
|
|
|
|
|
|
my $p; |
50
|
|
|
|
|
|
|
sub _get_parser { |
51
|
1
|
|
33
|
1
|
|
81
|
$p ||= eval q{ |
|
1
|
|
|
1
|
|
30
|
|
52
|
|
|
|
|
|
|
package portable::loader::TOML::_Parser; |
53
|
|
|
|
|
|
|
require TOML::Parser; |
54
|
|
|
|
|
|
|
our @ISA = 'TOML::Parser'; |
55
|
|
|
|
|
|
|
sub decode { shift->parse(@_) }; |
56
|
|
|
|
|
|
|
__PACKAGE__->new; |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|