| 1 | # ABSTRACT: Parser for YAML::PP::LibYAML | ||||||||||||||||||||
| 2 | package YAML::PP::LibYAML::Parser; | ||||||||||||||||||||
| 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::Reader; | ||||||||||||||||||
|
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::Parser'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 4 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||
| 15 | 4 | my ($class, %args) = @_; | |||||||||||||||||||
| 16 | 4 | ▶ | my $reader = delete $args{reader} || YAML::PP::Reader->new; | ||||||||||||||||||
|
Condition33%1/3
delete $args{'reader'} || 'YAML::PP::Reader'->new
MC/DC0%0/2
delete $args{'reader'} || 'YAML::PP::Reader'->new
delete $args{'reader'}
'YAML::PP::Reader'->new
Truth table33%1/3
A || B
A= delete $args{'reader'}B= 'YAML::PP::Reader'->new
| |||||||||||||||||||||
| 17 | 4 | my $receiver = delete $args{receiver}; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 4 | my $self = bless { | |||||||||||||||||||
| 20 | reader => $reader, | ||||||||||||||||||||
| 21 | }, $class; | ||||||||||||||||||||
| 22 | 4 | ▶ | if ($receiver) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | 0 | $self->set_receiver($receiver); | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | 4 | return $self; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 5 | ▶ | sub reader { return $_[0]->{reader} } | ||||||||||||||||||
|
Subroutine
reader: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 29 | 5 | ▶ | sub set_reader { | ||||||||||||||||||
|
Subroutine
set_reader: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 30 | 5 | my ($self, $reader) = @_; | |||||||||||||||||||
| 31 | 5 | $self->{reader} = $reader; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 5 | ▶ | sub parse { | ||||||||||||||||||
|
Subroutine
parse: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||
| 35 | 5 | my ($self) = @_; | |||||||||||||||||||
| 36 | 5 | my $reader = $self->reader; | |||||||||||||||||||
| 37 | 5 | my $events = []; | |||||||||||||||||||
| 38 | 5 | ▶ | if ($reader->can('open_handle')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 2 | ▶ | if (openhandle($reader->input)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 1 | my $test = YAML::LibYAML::API::XS::parse_filehandle_events($reader->open_handle, $events); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||
| 43 | 1 | my $test = YAML::LibYAML::API::XS::parse_file_events($reader->input, $events); | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||
| 47 | 3 | my $yaml = $reader->read; | |||||||||||||||||||
| 48 | 3 | my $test = YAML::LibYAML::API::XS::parse_string_events($yaml, $events); | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | 4 | for my $info (@$events) { | |||||||||||||||||||
| 51 | 43 | my $name = $info->{name}; | |||||||||||||||||||
| 52 | 43 | $self->callback->( $self, $name => $info ); | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 4 | 1; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||