| 1 | package File::Serialize; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 10 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: DWIM file serialization/deserialization | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | $File::Serialize::VERSION = '1.5.0'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use v5.16.0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use feature 'current_sub'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Class::Load qw/ load_class /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use List::AllUtils qw/ uniq /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use List::Util 1.41 qw/ pairgrep first none any pairmap /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 10 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | use Module::Pluggable | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 10 | require => 1, | |||||||||||||||||||||||||||||||||||||||||
| 19 | sub_name => '_all_serializers', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | search_path => __PACKAGE__ . '::Serializer' | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 10 | ▶ | ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 10 | ▶ | use parent 'Exporter::Tiny'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 10 | our @EXPORT = qw/ serialize_file deserialize_file transerialize_file /; | |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 10 | our $implicit_transform; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | sub _generate_serialize_file { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 39 | ▶ | my( undef, undef, undef, $global )= @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_serialize_file: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 30 | ▶ | my( $file, $content, $options ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=17 SCAR=29.7
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 30 | ▶ | $options = { format => $options } if $options and not ref $options; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$options and not ref $options
MC/DC0%0/2
$options and not ref $options
$options
not ref $options
Truth table66%2/3
A and not(B)
A= $optionsB= not ref $options
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 30 | ▶ | $options = { %$global, %{ $options||{} } } if $global; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | # default to utf8 => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 30 | ▶ | $options->{utf8} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{"utf8"} //= 1
MC/DC100%1/1
$options->{"utf8"} //= 1
$options->{"utf8"}
Truth table100%2/2
A
A= $options->{"utf8"}
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 30 | ▶ | $options->{allow_nonref} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options->{"allow_nonref"} //= 1
MC/DC0%0/1
$options->{"allow_nonref"} //= 1
$options->{"allow_nonref"}
Truth table50%1/2
A
A= $options->{"allow_nonref"}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 30 | ▶ | $options->{pretty} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{"pretty"} //= 1
MC/DC100%1/1
$options->{"pretty"} //= 1
$options->{"pretty"}
Truth table100%2/2
A
A= $options->{"pretty"}
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 30 | ▶ | $options->{canonical} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{"canonical"} //= 1
MC/DC100%1/1
$options->{"canonical"} //= 1
$options->{"canonical"}
Truth table100%2/2
A
A= $options->{"canonical"}
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 30 | ▶ | $file = path($file) unless $file =~ /^-/ or ref $file eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$file =~ /^-/u or ref $file eq "SCALAR"
MC/DC50%1/2
$file =~ /^-/u or ref $file eq "SCALAR"
$file =~ /^-/u
ref $file eq "SCALAR"
Truth table66%2/3
A or B
A= $file =~ /^-/uB= ref $file eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 30 | my $serializer = _serializer($file, $options); | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | $file = path( join '.', $file, $serializer->extension ) | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 29 | ▶ | if $options->{add_extension} and $file ne '-' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$options->{"add_extension"} and $file ne "-" and ref $file ne "SCALAR"
$options->{"add_extension"} and $file ne "-"
MC/DC0%0/3
$options->{"add_extension"} and $file ne "-" and ref $file ne "SCALAR"
$options->{"add_extension"}
$file ne "-"
ref $file ne "SCALAR"
Truth table25%1/4
A and B and C
A= $options->{"add_extension"}B= $file ne "-"C= ref $file ne "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | and ref $file ne 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 29 | ▶ | my $method = $options->{utf8} ? 'spew_utf8' : 'spew'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 29 | my $serialized = $serializer->serialize($content,$options); | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 29 | ▶ | return print $serialized if $file eq '-'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 29 | ▶ | if( ref $file eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | $$file = $serialized; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 25 | $file->$method($serialized); | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 39 | } | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | sub _generate_deserialize_file { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 39 | ▶ | my( undef, undef, undef, $global ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_deserialize_file: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 36 | ▶ | my( $file, $options ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 36 | ▶ | $file = path($file) unless $file eq '-' or ref $file eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$file eq "-" or ref $file eq "SCALAR"
MC/DC50%1/2
$file eq "-" or ref $file eq "SCALAR"
$file eq "-"
ref $file eq "SCALAR"
Truth table66%2/3
A or B
A= $file eq "-"B= ref $file eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 36 | ▶ | $options = { %$global, %{ $options||{} } } if $global; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 36 | ▶ | $options->{utf8} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options->{"utf8"} //= 1
MC/DC0%0/1
$options->{"utf8"} //= 1
$options->{"utf8"}
Truth table50%1/2
A
A= $options->{"utf8"}
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 36 | ▶ | $options->{allow_nonref} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{"allow_nonref"} //= 1
MC/DC100%1/1
$options->{"allow_nonref"} //= 1
$options->{"allow_nonref"}
Truth table100%2/2
A
A= $options->{"allow_nonref"}
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 36 | my $method = 'slurp' . ( '_utf8' ) x !! $options->{utf8}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 36 | my $serializer = _serializer($file, $options); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | $file = path( join '.', $file, $serializer->extension ) | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 36 | ▶ | if $options->{add_extension} and $file ne '-' and ref $file ne 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$options->{"add_extension"} and $file ne "-" and ref $file ne "SCALAR"
$options->{"add_extension"} and $file ne "-"
MC/DC0%0/3
$options->{"add_extension"} and $file ne "-" and ref $file ne "SCALAR"
$options->{"add_extension"}
$file ne "-"
ref $file ne "SCALAR"
Truth table25%1/4
A and B and C
A= $options->{"add_extension"}B= $file ne "-"C= ref $file ne "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | return $serializer->deserialize( | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 36 | ▶ | $file =~ /^-/ ? do { local $/ = <STDIN> } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | : ref $file eq 'SCALAR' ? $$file | ||||||||||||||||||||||||||||||||||||||||||
| 89 | : $file->$method, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | $options | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 39 | } | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | sub _generate_transerialize_file { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 16 | ▶ | my $serialize_file = _generate_serialize_file(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_transerialize_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 16 | my $deserialize_file = _generate_deserialize_file(@_); | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 12 | ▶ | my( $in, @chain ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=27.0
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | ▶ | my $data = ref($in) ? $in : $deserialize_file->($in); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 12 | ▶ | while( my $step = shift @chain) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 22 | ▶ | if ( ref $step eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | local $_ = $data; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | ▶ | if( $implicit_transform ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $step->($data); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $data = $_; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 8 | $data = $step->($data); | |||||||||||||||||||||||||||||||||||||||||
| 114 | }} | ||||||||||||||||||||||||||||||||||||||||||
| 115 | elsif ( ref $step eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | die "subranch step can only be the last step of the chain" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | if @chain; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | for my $branch( @$step ) { | |||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | __SUB__->($data,@$branch); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | ▶ | elsif ( not ref $step or ref($step) =~ /Path::Tiny/ ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
not ref $step or ref($step) =~ /Path::Tiny/u
MC/DC100%2/2
not ref $step or ref($step) =~ /Path::Tiny/u
not ref $step
ref($step) =~ /Path::Tiny/u
Truth table100%3/3
not(A) or B
A= not ref $stepB= ref($step) =~ /Path::Tiny/u
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 8 | ▶ | die "filename '$step' not at the end of the chain" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | unless @chain <= 1; | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 8 | $serialize_file->( $step, $data, shift @chain ); | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | elsif ( ref $step eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | ▶ | while( my ($f,$o) = each %$step ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | $serialize_file->($f,$data,$o); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | elsif ( ref $step eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | $$step = $data; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | die "wrong chain argument"; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 16 | } | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | sub _all_operative_formats { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_all_operative_formats: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return uniq map { $_->extension } $self->_all_operative_formats; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | sub _all_operative_serializers { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | sort { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 448 | ▶ | $b->precedence <=> $a->precedence | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | or | ||||||||||||||||||||||||||||||||||||||||||
| 153 | $a cmp $b | ||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 504 | grep { $_->is_operative } | |||||||||||||||||||||||||||||||||||||||||
| 156 | 56 | ▶ | grep { $_->precedence } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_all_operative_serializers: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | __PACKAGE__->_all_serializers; | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | sub _serializer { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 66 | ▶ | my( $self, $options ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serializer: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 10 | ▶ | no warnings qw/ uninitialized /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 66 | ▶ | my $serializers = $options->{serializers} || [ __PACKAGE__->_all_operative_serializers ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->{'serializers'} || [__PACKAGE__->_all_operative_serializers]
MC/DC0%0/1
$options->{'serializers'} || [__PACKAGE__->_all_operative_serializers]
$options->{'serializers'}
Truth table50%1/2
A
A= $options->{'serializers'}
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 66 | s/^\+/File::Serialize::Serializer::/ for @$serializers; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 66 | ▶ | my $format = $options->{format} || ( ( ref $self ? $self->basename : $self ) =~ /\.(\w+)$/ )[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$options->{'format'} || ((ref $self ? $self->basename : $self) =~ /\.(\w+)$/u)[0]
MC/DC100%2/2
$options->{'format'} || ((ref $self ? $self->basename : $self) =~ /\.(\w+)$/u)[0]
$options->{'format'}
((ref $self ? $self->basename : $self) =~ /\.(\w+)$/u)[0]
Truth table100%3/3
A || B
A= $options->{'format'}B= ((ref $self ? $self->basename : $self) =~ /\.(\w+)$/u)[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 66 | ▶ | return( first { $_->does_extension($format) } @$serializers | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition100%2/2
&first(sub {
$_->does_extension($format);
}
, @$serializers) || die("no serializer found for $format")
MC/DC100%1/1
&first(sub {
$_->does_extension($format);
}
, @$serializers) || die("no serializer found for $format")
&first(sub {
$_->does_extension($format);
}
, @$serializers)
Truth table100%2/2
A
A= &first(sub {
$_->does_extension($format);
}
, @$serializers)
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | or die "no serializer found for $format" | ||||||||||||||||||||||||||||||||||||||||||
| 172 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | __END__ | ||||||||||||||||||||||||||||||||||||||||||