blib/lib/MARC/Spec/Comparisonstring.pm

filter: Statementstmt 88.4% 23 / 26 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 33.3% 1 / 3 totaltotal 82.0% 32 / 39 SCAR 11.1
CC
3
Cov
87%
BUILDARGS
2.0
BUILD
2.0
to_string
2.0
CRAP 3.0
« blib/lib/MARC/Spec/Subspec.pm ↑ Summary blib/lib/MARC/Spec/Subfield.pm »
1 package MARC::Spec::Comparisonstring;
2  
3 14 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 14 our $VERSION = '1.0.0';
8  
9 14 has raw => (
10 is => 'rwp',
11 required => 1
12 );
13  
14 14 has comparable => (
15 is => 'rwp'
16 );
17  
18 sub BUILDARGS {
19 87 ▶ my ( $class, @args ) = @_;
Subroutine BUILDARGS: called CC=2 SCAR=7.1
Pod undocumented
20 87 ▶ unshift @args, "raw" if @args % 2 == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 == 1 87 0 87
21 87 return { @args };
22 }
23  
24 sub BUILD {
25 87 ▶ my ($self, $args) = @_;
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
26
27 # char of list ${}!=~?|\s must be escaped if not at index 0*
28 87 ▶ croak "MARCspec Comparisonstring exception. Unescaped character detected. Tried to parse: ".$self->raw
Branch: 1 branch
BranchTrueFalseTotal
unless $self->raw =~ /^(.(?:[^\$\{\}\!\=\~\?\|\s]|(?<=\\\\)[\$\{\}\!\=\~\?\|])*)$/s 1 86 87
29 unless($self->raw =~ /^(.(?:[^\$\{\}\!\=\~\?\|\s]|(?<=\\\\)[\$\{\}\!\=\~\?\|])*)$/s);
30  
31 86 my $comparable = $self->raw;
32 86 my $replace = ' ';
33 86 $comparable =~ s{\\s}{$replace}g;
34 86 $self->_set_comparable($comparable);
35 86 return;
36 }
37  
38 sub to_string {
39 0 ▶ my ($self) = @_;
Subroutine to_string: not called CC=1 SCAR=6.9
Pod documented
40 0 my $string = '\\'.$self->raw;
41 0 return $string;
42 }
43 14 1;
44  
45 __END__
« blib/lib/MARC/Spec/Subspec.pm ↑ Summary blib/lib/MARC/Spec/Subfield.pm »