| 1 | package DateTime::Format::Builder::Parser::Dispatch; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 24 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 24 | our $VERSION = '0.83'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 24 | our %dispatch_data; | |||||||||||||||||||||||||||
| 9 | 24 | ▶ | use Params::Validate qw( CODEREF validate ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 24 | ▶ | use DateTime::Format::Builder::Parser; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||
| 13 | 24 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 24 | *dispatch_data = *DateTime::Format::Builder::dispatch_data; | |||||||||||||||||||||||||||
| 15 | 24 | *params = *DateTime::Format::Builder::Parser::params; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | DateTime::Format::Builder::Parser->valid_params( | ||||||||||||||||||||||||||||
| 19 | 24 | Dispatch => { | |||||||||||||||||||||||||||
| 20 | type => CODEREF, | ||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | sub create_parser { | ||||||||||||||||||||||||||
|
Subroutine
create_parser: called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 2 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||
| 26 | 2 | my $coderef = $args{Dispatch}; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 3 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=23.7
| |||||||||||||||||||||||||||||
| 29 | 3 | my ( $self, $date, $p, @args ) = @_; | |||||||||||||||||||||||||||
| 30 | 3 | ▶ | return unless defined $date; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 3 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 3 | my @results = $coderef->($date); | |||||||||||||||||||||||||||
| 34 | 3 | ▶ | return unless @results; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 3 | ▶ | return unless defined $results[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 3 | for my $group (@results) { | |||||||||||||||||||||||||||
| 38 | 4 | my $parser = $dispatch_data{$class}{$group}; | |||||||||||||||||||||||||||
| 39 | 4 | ▶ | die "Unknown parsing group: $class\n" unless defined $parser; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 4 | my $rv = eval { $parser->parse( $self, $date, $p, @args ) }; | |||||||||||||||||||||||||||
| 41 | 4 | ▶ | return $rv unless $@ or not defined $rv; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ or not defined $rv
MC/DC50%1/2
$@ or not defined $rv
$@
not defined $rv
Truth table66%2/3
A or not(B)
A= $@B= not defined $rv
| |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | return; | |||||||||||||||||||||||||||
| 44 | 2 | }; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 24 | 1; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # ABSTRACT: Dispatch parsers by group | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||