blib/lib/YAML/PP/YAMLScript.pm

filter: Statementstmt 100% 37 / 37 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 10 / 10 Podpod 66.6% 2 / 3 totaltotal 94.3% 50 / 53 CC 2 SCAR 1.7
CC
2
Cov
97%
new
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 3 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package YAML::PP::YAMLScript;
3  
4 3 our $VERSION = '0.0.2';
5  
6 3 ▶use base 'YAML::PP';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use YAMLScript::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use YAMLScript::RT;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
14 2 my $class = shift;
15 2 my (%args) = @_;
16 2 ▶ $args{schema} //= ['Failsafe'];
Condition50%1/2
$args{"schema"} //= ["Failsafe"]
l!l
02
MC/DC0%0/1
$args{"schema"} //= ["Failsafe"]
$args{"schema"}
Truth table50%1/2
A
A= $args{"schema"}
Aresult
11
00
17 2 $class->SUPER::new(%args);
18 }
19  
20 2 ▶sub load_file {
Subroutine load_file: called CC=1 SCAR=0.0
Pod documented
21 2 my ($self, $file) = @_;
22  
23 $self->schema->add_mapping_resolver(
24 tag => '!yamlscript',
25 2 ▶ on_create => sub { +{ file => $file }; },
Subroutine __ANON__: called CC=1 SCAR=0.0
26 2 on_data => \&on_data,
27 );
28  
29 2 $self->SUPER::load_file($file);
30 }
31  
32 2 ▶sub on_data {
Subroutine on_data: called CC=1 SCAR=0.0
Pod undocumented
33 2 my ($self, $struct) = @_;
34  
35 2 my $file = $$struct->{file};
36  
37 2 RT->init;
38 2 $YAMLScript::Reader::read_ys = 1;
39 2 RT->rep(qq<
40 yaml-data =:
41 load-file-ys: "$file"
42 >);
43  
44 2 my $data = RT->user_ns->{'yaml-data'}->unbox;
45  
46 2 %{$$struct} = %$data;
47 }
48  
49 3 my $ypp = YAML::PP->new( schema => ['Failsafe'] );
50  
51 3 1;
↑ Summary