| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||