loader/TOML.pm

filter: Statementstmt 100% 37 / 37 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 81.6% 49 / 60 CC 4 SCAR 5.5
CC
4
Cov
89%
parse
3.1
_get_parser
2.3
decode
1.1
CRAP 1.7
« alias.pm ↑ Summary loader/Perl.pm »
1 3 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package portable::loader::TOML;
6  
7 2 our $AUTHORITY = 'cpan:TOBYINK';
8 2 our $VERSION = '0.003';
9  
10 3 ▶use portable::lib;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $decoder;
13  
14 3 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
15 3 my $me = shift;
16 3 my ($loader) = @_;
17 3 $loader->register_extension('portable.toml');
18 3 $loader->register_extension('portable');
19 3 return;
20 }
21  
22 1 ▶sub parse {
Subroutine parse: called CC=3 SCAR=11.2
Pod undocumented
23 1 my $me = shift;
24 1 my ($filename) = @_;
25 1 require JSON::Eval;
26 1 ▶ $decoder ||= JSON::Eval->new($me->_get_parser);
Condition33%1/3
$portable::loader::TOML::decoder ||= "JSON::Eval"->new($me->_get_parser)
l!l&&r!l&&!r
010
MC/DC0%0/2
$portable::loader::TOML::decoder ||= "JSON::Eval"->new($me->_get_parser)
$portable::loader::TOML::decoder "JSON::Eval"->new($me->_get_parser)
Truth table33%1/3
A ||= B
A= $portable::loader::TOML::decoderB= "JSON::Eval"->new($me->_get_parser)
ABresult
1X1
011
000
27 1 my $tomltext = do {
28 1 ▶ open my $fh, '<', $filename
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $filename or die "Could not open ${filename}: $!" 1 0 1
29 or die "Could not open $filename: $!";
30 1 local $/;
31 1 <$fh>;
32 };
33 1 $me->_munge_toml(\$tomltext);
34 1 my $decoded = $decoder->decode($tomltext);
35 1 return ($filename => $decoded);
36 }
37  
38 1 ▶sub _munge_toml {
Subroutine _munge_toml: called CC=1 SCAR=0.0
39 1 my $ref = $_[1];
40 1 $$ref =~ s{
41 \{\{\{
42 (.*?)
43 \}\}\}
44 }{ \{\"\$eval\"=''' sub \{ $1 \} ''' \} }xsgo;
45 1 return;
46 }
47  
48 # create method alias
49 2 my $p;
50 1 ▶sub _get_parser {
Subroutine _get_parser: called CC=2 SCAR=8.1
51 1 ▶ $p ||= eval q{
Subroutine decode: called CC=1 SCAR=0.6
Condition33%1/3
$p ||= eval "\n\t\tpackage portable::loader::TOML::_Parser;\n\t\trequire TOML::Parser;\n\t\tour \@ISA = 'TOML::Parser';\n\t\tsub decode { shift->parse(\@_) };\n\t\t__PACKAGE__->new;\n\t"
l!l&&r!l&&!r
010
MC/DC0%0/2
$p ||= eval "\n\t\tpackage portable::loader::TOML::_Parser;\n\t\trequire TOML::Parser;\n\t\tour \@ISA = 'TOML::Parser';\n\t\tsub decode { shift->parse(\@_) };\n\t\t__PACKAGE__->new;\n\t"
$p eval "\n\t\tpackage portable::loader::TOML::_Parser;\n\t\trequire TOML::Parser;\n\t\tour \@ISA = 'TOML::Parser';\n\t\tsub decode { shift->parse(\@_) };\n\t\t__PACKAGE__->new;\n\t"
Truth table33%1/3
A ||= B
A= $pB= eval "\n\t\tpackage portable::loader::TOML::_Parser;\n\t\trequire TOML::Parser;\n\t\tour \@ISA = 'TOML::Parser';\n\t\tsub decode { shift->parse(\@_) };\n\t\t__PACKAGE__->new;\n\t"
ABresult
1X1
011
000
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 2 1;
61  
« alias.pm ↑ Summary loader/Perl.pm »