LibYAML/Emitter.pm

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