LibYAML/Emitter.pm

filter: Statementstmt 80.7% 63 / 78 Branchbran 25.0% 1 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 84.2% 16 / 19 Podpod 92.3% 12 / 13 totaltotal 81.2% 95 / 117 CC 4 SCAR 4.3
CC
4
Cov
79%
stream_end_event
3.3
new
2.0
sequence_start_event
2.0
CRAP 1.5
« LibYAML/Parser.pm ↑ Summary LibYAML.pm »
1 # ABSTRACT: Emitter for YAML::PP::LibYAML
2 package YAML::PP::LibYAML::Emitter;
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.003'; # VERSION
7  
8 3 ▶use YAML::LibYAML::API::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use YAML::PP::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Scalar::Util qw/ openhandle /;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use base 'YAML::PP::Emitter';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new {
15 2 ▶ my ($class, %args) = @_;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
16 2 ▶ my $indent = delete $args{indent} || 2;
Condition100%2/2
delete $args{'indent'} || 2
l!l
11
MC/DC100%1/1
delete $args{'indent'} || 2
delete $args{'indent'}
Truth table100%2/2
A
A= delete $args{'indent'}
Aresult
11
00
17 2 my $self = bless {
18 indent => $indent,
19 }, $class;
20 2 $self->{events} = [];
21 2 return $self;
22 }
23 41 ▶sub events { return $_[0]->{events} }
Subroutine events: called CC=1 SCAR=0.0
Pod undocumented
24 4 ▶sub indent { return $_[0]->{indent} }
Subroutine indent: called CC=1 SCAR=0.0
Pod documented
25  
26  
27 sub mapping_start_event {
28 5 ▶ my ($self, $info) = @_;
Subroutine mapping_start_event: called CC=1 SCAR=0.0
Pod documented
29 5 $info->{name} = 'mapping_start_event';
30 5 push @{ $self->events }, $info;
31 }
32  
33 sub mapping_end_event {
34 5 ▶ my ($self, $info) = @_;
Subroutine mapping_end_event: called CC=1 SCAR=0.0
Pod documented
35 5 $info->{name} = 'mapping_end_event';
36 5 push @{ $self->events }, $info;
37 }
38  
39 sub sequence_start_event {
40 0 ▶ my ($self, $info) = @_;
Subroutine sequence_start_event: not called CC=1 SCAR=6.9
Pod documented
41 0 $info->{name} = 'sequence_start_event';
42 0 push @{ $self->events }, $info;
43 }
44  
45 sub sequence_end_event {
46 0 ▶ my ($self, $info) = @_;
Subroutine sequence_end_event: not called CC=1 SCAR=6.9
Pod documented
47 0 $info->{name} = 'sequence_end_event';
48 0 push @{ $self->events }, $info;
49 }
50  
51 sub scalar_event {
52 11 ▶ my ($self, $info) = @_;
Subroutine scalar_event: called CC=1 SCAR=0.0
Pod documented
53 11 $info->{name} = 'scalar_event';
54 11 push @{ $self->events }, $info;
55 }
56  
57 sub alias_event {
58 0 ▶ my ($self, $info) = @_;
Subroutine alias_event: not called CC=1 SCAR=6.9
Pod documented
59 0 $info->{name} = 'alias_event';
60 0 push @{ $self->events }, $info;
61 }
62  
63 sub document_start_event {
64 4 ▶ my ($self, $info) = @_;
Subroutine document_start_event: called CC=1 SCAR=0.0
Pod documented
65 4 $info->{name} = 'document_start_event';
66 4 push @{ $self->events }, $info;
67 }
68  
69 sub document_end_event {
70 4 ▶ my ($self, $info) = @_;
Subroutine document_end_event: called CC=1 SCAR=0.0
Pod documented
71 4 $info->{name} = 'document_end_event';
72 4 push @{ $self->events }, $info;
73 }
74  
75 sub stream_start_event {
76 4 ▶ my ($self, $info) = @_;
Subroutine stream_start_event: called CC=1 SCAR=0.0
Pod documented
77 4 $info->{name} = 'stream_start_event';
78 4 push @{ $self->events }, $info;
79 }
80  
81 sub stream_end_event {
82 4 ▶ my ($self, $info) = @_;
Subroutine stream_end_event: called CC=3 SCAR=11.9
Pod documented
83 4 $info->{name} = 'stream_end_event';
84 4 push @{ $self->events }, $info;
85 4 my $events = $self->events;
86 4 my $writer = $self->writer;
87 4 $writer->init();
88 4 my $options = {
89 indent => $self->indent,
90 };
91  
92 4 ▶ if ($writer->can('open_handle')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($writer->can('open_handle')) { } 0 4 4
93 0 ▶ if (openhandle($writer->output)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&openhandle(scalar $writer->output)) { } 0 0 0
94 0 YAML::LibYAML::API::XS::emit_filehandle_events(
95 $writer->open_handle, $events, $options
96 );
97 }
98 else {
99 0 YAML::LibYAML::API::XS::emit_file_events(
100 $writer->output, $events, $options
101 );
102 }
103 }
104 else {
105 4 my $out = YAML::LibYAML::API::XS::emit_string_events($events, $options);
106 4 $self->writer->write($out);
107 }
108  
109 4 @$events = ();
110 }
111  
112 3 1;
113  
114 __END__
« LibYAML/Parser.pm ↑ Summary LibYAML.pm »